From af9f337ea645491c9ec8db05d305887a51e419fe Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 18 Jun 2018 19:45:45 +0200 Subject: pkg/host: support trial supported syscall detection Detect supported syscall by directly executing them if kallsyms is not present. This is required for gvisor testing. --- pkg/host/host_test.go | 52 +++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'pkg/host/host_test.go') diff --git a/pkg/host/host_test.go b/pkg/host/host_test.go index 8a16d5e5d..c44b9bbce 100644 --- a/pkg/host/host_test.go +++ b/pkg/host/host_test.go @@ -4,6 +4,7 @@ package host import ( + "fmt" "runtime" "testing" @@ -13,28 +14,35 @@ import ( func TestDetectSupportedSyscalls(t *testing.T) { t.Parallel() - target, err := prog.GetTarget(runtime.GOOS, runtime.GOARCH) - if err != nil { - t.Fatal(err) - } - // Dump for manual inspection. - supp, disabled, err := DetectSupportedSyscalls(target, "none") - if err != nil { - t.Skipf("skipping: %v", err) - } - for c, ok := range supp { - if !ok { - t.Fatalf("map contains false value for %v", c.Name) - } - } - t.Logf("unsupported:") - for c, reason := range disabled { - t.Logf("%v: %v", c.Name, reason) - } - _, disabled = target.TransitivelyEnabledCalls(supp) - t.Logf("\n\ntransitively unsupported:") - for c, reason := range disabled { - t.Logf("%v: %v", c.Name, reason) + for _, fallback := range []bool{false, true} { + t.Run(fmt.Sprintf("fallback=%v", fallback), func(t *testing.T) { + oldFallback := testFallback + testFallback = fallback + defer func() { testFallback = oldFallback }() + target, err := prog.GetTarget(runtime.GOOS, runtime.GOARCH) + if err != nil { + t.Fatal(err) + } + // Dump for manual inspection. + supp, disabled, err := DetectSupportedSyscalls(target, "none") + if err != nil { + t.Fatal(err) + } + for c, ok := range supp { + if !ok { + t.Fatalf("map contains false value for %v", c.Name) + } + } + t.Logf("unsupported:") + for c, reason := range disabled { + t.Logf("%v: %v", c.Name, reason) + } + _, disabled = target.TransitivelyEnabledCalls(supp) + t.Logf("\n\ntransitively unsupported:") + for c, reason := range disabled { + t.Logf("%v: %v", c.Name, reason) + } + }) } } -- cgit mrf-deployment