gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/acpi/tables_linux_test.go (about) 1 // Copyright 2019 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package acpi 6 7 import ( 8 "reflect" 9 "testing" 10 11 "github.com/u-root/u-root/pkg/testutil" 12 ) 13 14 // TestTable tests whether any method for getting a table works. 15 // If it succeeds, it is called again with the method it returns 16 // to verify at least that much is the same. 17 func TestTable(t *testing.T) { 18 testutil.SkipIfNotRoot(t) 19 20 m, tg, err := GetTable() 21 if err != nil { 22 t.Skip("no table to get") 23 } 24 25 f, ok := Methods[m] 26 if !ok { 27 t.Fatalf("method type returned from GetTable: got not found in Methods, expect to find it") 28 } 29 tt, err := f() 30 if err != nil { 31 t.Fatalf("Getting table via %q: got %v, want nil", m, err) 32 } 33 if !reflect.DeepEqual(tg, tt) { 34 t.Fatalf("Getting table via GetTable and %q: got different(%s, %s), want same", m, tg, tt) 35 } 36 37 }