aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_ext_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2022-09-08 12:55:42 +0200
committerDmitry Vyukov <dvyukov@google.com>2022-11-01 10:23:09 -0700
commit08977f5d5e344fa0ac0b80af0b72fc3f1468d6a5 (patch)
tree073d5136049228b4a279d9bca98d678f1a7afe12 /executor/common_ext_test.go
parent75eae5a7ef67781b73f2b9038416542c7ea0612c (diff)
executor: add setup_ext_test extension point
The extension point allows to setup the test process in a custom way without overwriting any of the existing files.
Diffstat (limited to 'executor/common_ext_test.go')
-rw-r--r--executor/common_ext_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/executor/common_ext_test.go b/executor/common_ext_test.go
index 45ba3a3cf..2815b095a 100644
--- a/executor/common_ext_test.go
+++ b/executor/common_ext_test.go
@@ -10,6 +10,8 @@ import (
"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"
)
@@ -31,4 +33,31 @@ func TestCommonExt(t *testing.T) {
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
+ cfg.Flags |= 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)
+ }
}