deviceinfo: add tests for ReadDeviceinfo (MR 37)
This commit is contained in:
committed by
Clayton Craft
parent
b1e44d8ec2
commit
2f4937c52d
@@ -10,6 +10,32 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Test ReadDeviceinfo and the logic of reading from multiple files
|
||||||
|
func TestReadDeviceinfo(t *testing.T) {
|
||||||
|
modules_expected := "panfrost foo bar bazz"
|
||||||
|
mesa_expected := "msm"
|
||||||
|
|
||||||
|
var devinfo DeviceInfo
|
||||||
|
err := devinfo.ReadDeviceinfo("./test_resources/deviceinfo-missing")
|
||||||
|
if !strings.Contains(err.Error(), "required by mkinitfs") {
|
||||||
|
t.Errorf("received an unexpected err: %s", err)
|
||||||
|
}
|
||||||
|
err = devinfo.ReadDeviceinfo("./test_resources/deviceinfo-first")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("received an unexpected err: %s", err)
|
||||||
|
}
|
||||||
|
err = devinfo.ReadDeviceinfo("./test_resources/deviceinfo-msm")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("received an unexpected err: %s", err)
|
||||||
|
}
|
||||||
|
if devinfo.ModulesInitfs != modules_expected {
|
||||||
|
t.Errorf("expected %q, got: %q", modules_expected, devinfo.ModulesInitfs)
|
||||||
|
}
|
||||||
|
if devinfo.MesaDriver != mesa_expected {
|
||||||
|
t.Errorf("expected %q, got: %q", mesa_expected, devinfo.MesaDriver)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test conversion of name to DeviceInfo struct field format
|
// Test conversion of name to DeviceInfo struct field format
|
||||||
func TestNameToField(t *testing.T) {
|
func TestNameToField(t *testing.T) {
|
||||||
tables := []struct {
|
tables := []struct {
|
||||||
|
2
pkgs/deviceinfo/test_resources/deviceinfo-first
Normal file
2
pkgs/deviceinfo/test_resources/deviceinfo-first
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
deviceinfo_modules_initfs="panfrost foo bar bazz"
|
||||||
|
deviceinfo_mesa_driver="panfrost"
|
1
pkgs/deviceinfo/test_resources/deviceinfo-msm
Normal file
1
pkgs/deviceinfo/test_resources/deviceinfo-msm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
deviceinfo_mesa_driver="msm"
|
Reference in New Issue
Block a user