diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-05-08 12:47:20 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-05-08 12:26:59 +0000 |
| commit | dc488c459880e3f3af557dc336697138ecb8228b (patch) | |
| tree | 8567aaee8876d5118b2ac4d9c227bf0fb5d616f2 /executor/common_ext_test.go | |
| parent | 5d520cbcca77cacf034dba2f30042e419bc978f6 (diff) | |
pkg/ipc: move executor common_ext test
Move the test from executor to pkg/ipc to prevent import cycle
in the next change.
pkg/ipc looks like the most reasonable place for it (besides executor),
it already builds executor binary.
The test cannot be moved to pkg/csource b/c it will create csource<->ipc cycle.
Diffstat (limited to 'executor/common_ext_test.go')
| -rw-r--r-- | executor/common_ext_test.go | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/executor/common_ext_test.go b/executor/common_ext_test.go deleted file mode 100644 index d92eff00c..000000000 --- a/executor/common_ext_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 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 executor - -import ( - "bytes" - "testing" - "time" - - "github.com/google/syzkaller/pkg/csource" - "github.com/google/syzkaller/pkg/ipc" - "github.com/google/syzkaller/pkg/ipc/ipcconfig" - "github.com/google/syzkaller/pkg/osutil" - "github.com/google/syzkaller/prog" - "github.com/google/syzkaller/sys/targets" -) - -func TestCommonExt(t *testing.T) { - target, err := prog.GetTarget("test", "64_fork") - if err != nil { - t.Fatal(err) - } - sysTarget := targets.Get(target.OS, target.Arch) - if sysTarget.BrokenCompiler != "" { - t.Skipf("skipping, broken cross-compiler: %v", sysTarget.BrokenCompiler) - } - bin := csource.BuildExecutor(t, target, "..", "-DSYZ_TEST_COMMON_EXT_EXAMPLE=1") - out, err := osutil.RunCmd(time.Minute, "", bin, "setup") - if err != nil { - t.Fatal(err) - } - if !bytes.Contains(out, []byte("example setup_ext called")) { - t.Fatalf("setup_ext wasn't called:\n%s", out) - } - - // The example setup_ext_test does: - // *(uint64*)(SYZ_DATA_OFFSET + 0x1234) = 0xbadc0ffee; - // The following program tests that that value is present at 0x1234. - test := `syz_compare(&(0x7f0000001234)="", 0x8, &(0x7f0000000000)=@blob="eeffc0ad0b000000", AUTO)` - p, err := target.Deserialize([]byte(test), prog.Strict) - if err != nil { - t.Fatal(err) - } - cfg, opts, err := ipcconfig.Default(target) - if err != nil { - t.Fatal(err) - } - cfg.Executor = bin - opts.EnvFlags |= ipc.FlagDebug - env, err := ipc.MakeEnv(cfg, 0) - if err != nil { - t.Fatalf("failed to create env: %v", err) - } - defer env.Close() - _, info, _, err := env.Exec(opts, p) - if err != nil { - t.Fatal(err) - } - if call := info.Calls[0]; (call.Flags&ipc.CallFinished) == 0 || call.Errno != 0 { - t.Fatalf("bad call result: flags=%x errno=%v", call.Flags, call.Errno) - } -} |
