1
0
out-of-tree/distro/debian/kernel_test.go

68 lines
1.3 KiB
Go
Raw Normal View History

2023-05-11 19:26:54 +00:00
package debian
import (
"testing"
2023-05-14 14:06:04 +00:00
"github.com/davecgh/go-spew/spew"
"github.com/stretchr/testify/assert"
2023-05-29 11:21:20 +00:00
"code.dumpstack.io/tools/out-of-tree/distro/debian/snapshot"
2023-05-11 19:26:54 +00:00
)
func TestGetDebianKernel(t *testing.T) {
assert := assert.New(t)
2023-05-11 19:26:54 +00:00
dk, err := getDebianKernel("4.6.4-1")
assert.Nil(err)
assert.Equal(getRelease(dk.Image), Stretch)
2023-05-14 14:06:04 +00:00
t.Logf("%s", spew.Sdump(dk))
2023-05-11 19:26:54 +00:00
}
func TestParseKernelVersion(t *testing.T) {
assert := assert.New(t)
2023-05-29 11:47:40 +00:00
kernels, err := GetKernelsWithLimit(16, NoMode)
assert.Nil(err)
assert.NotEmpty(kernels)
versions := make(map[string]bool)
for _, dk := range kernels {
dkv, err := ParseKernelVersion(dk.Image.Deb.Name)
assert.Nil(err)
_, found := versions[dkv.Package]
assert.True(!found)
versions[dkv.Package] = true
}
}
2023-05-29 11:21:20 +00:00
func TestKbuildVersion(t *testing.T) {
assert := assert.New(t)
2023-05-29 11:47:40 +00:00
kernels, err := GetKernelsWithLimit(16, NoMode)
2023-05-29 11:21:20 +00:00
assert.Nil(err)
assert.NotEmpty(kernels)
toolsVersions, err := snapshot.SourcePackageVersions("linux-tools")
assert.Nil(err)
for _, dk := range kernels {
if !kver(dk.Version.Package).LessThan(kver("4.5-rc0")) {
continue
}
version := kbuildVersion(
toolsVersions,
dk.Version.Package,
)
assert.Nil(err)
assert.NotEmpty(version)
t.Log(dk.Version.Package, "->", version)
}
}