aboutsummaryrefslogtreecommitdiffstats
path: root/host/host_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-06-17 12:37:05 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-06-17 14:41:15 +0200
commit4b2a9e225c495475272e8a67f525329afa5f892a (patch)
tree49eec6c9fa0bedf654961466e9d21dbb1901a08e /host/host_test.go
parenta853b91c58c5403428499f5cdc661033ac7a91ce (diff)
pkg/host: move from host
Diffstat (limited to 'host/host_test.go')
-rw-r--r--host/host_test.go74
1 files changed, 0 insertions, 74 deletions
diff --git a/host/host_test.go b/host/host_test.go
deleted file mode 100644
index 9b44d8e36..000000000
--- a/host/host_test.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2015 syzkaller project authors. All rights reserved.
-// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
-
-package host
-
-import (
- "syscall"
- "testing"
-
- "github.com/google/syzkaller/sys"
-)
-
-func TestLog(t *testing.T) {
- t.Parallel()
- // Dump for manual inspection.
- supp, err := DetectSupportedSyscalls()
- if err != nil {
- t.Skipf("skipping: %v", err)
- }
- t.Logf("unsupported:")
- for _, c := range sys.Calls {
- s, ok := supp[c]
- if ok && !s {
- t.Fatalf("map contains false value")
- }
- if !s {
- t.Logf("\t%v", c.Name)
- }
- }
- trans := sys.TransitivelyEnabledCalls(supp)
- t.Logf("transitively unsupported:")
- for _, c := range sys.Calls {
- s, ok := trans[c]
- if ok && !s {
- t.Fatalf("map contains false value")
- }
- if !s && supp[c] {
- t.Logf("\t%v", c.Name)
- }
- }
-}
-
-func TestSupportedSyscalls(t *testing.T) {
- t.Parallel()
- supp, err := DetectSupportedSyscalls()
- if err != nil {
- t.Skipf("skipping: %v", err)
- }
- // These are safe to execute with invalid arguments.
- safe := []string{
- "memfd_create",
- "sendfile",
- "bpf$MAP_CREATE",
- "open",
- "openat",
- "read",
- "write",
- "stat",
- }
- for _, name := range safe {
- c := sys.CallMap[name]
- if c == nil {
- t.Fatalf("can't find syscall '%v'", name)
- }
- a := ^uintptr(0) - 4097 // hopefully invalid
- _, _, err := syscall.Syscall6(uintptr(c.NR), a, a, a, a, a, a)
- if err == 0 {
- t.Fatalf("%v did not fail", name)
- }
- if ok := err != syscall.ENOSYS; ok != supp[c] {
- t.Fatalf("syscall %v: perse=%v kallsyms=%v", name, ok, supp[c])
- }
- }
-}