aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/host/host_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-06-18 19:45:45 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-06-18 19:45:45 +0200
commitaf9f337ea645491c9ec8db05d305887a51e419fe (patch)
tree5d4507d383e2bd2d476042d6e867f281f99a0516 /pkg/host/host_test.go
parent7bd97c6ff6472db1e2ad9f279fe517cd7b5daee2 (diff)
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.
Diffstat (limited to 'pkg/host/host_test.go')
-rw-r--r--pkg/host/host_test.go52
1 files changed, 30 insertions, 22 deletions
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)
+ }
+ })
}
}