aboutsummaryrefslogtreecommitdiffstats
path: root/prog
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-09-15 09:05:13 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2022-09-27 13:07:37 +0200
commit1856cdc9b3652a082c5bfa0e08a9f883baece8ec (patch)
treeb929711cc5e8da196a11dd85141f7d374b132eff /prog
parent87840e0023f7adfb7ff928a8a5057932ea9aeab9 (diff)
executor: move syz_mount_image's sanity checks to syz-fuzzer
It will simplify the C code and let us extract the raw images in a more convenient way.
Diffstat (limited to 'prog')
-rw-r--r--prog/minimization_test.go4
-rw-r--r--prog/prog.go5
-rw-r--r--prog/test_util.go9
3 files changed, 14 insertions, 4 deletions
diff --git a/prog/minimization_test.go b/prog/minimization_test.go
index de58ad217..93ccdc7bb 100644
--- a/prog/minimization_test.go
+++ b/prog/minimization_test.go
@@ -231,13 +231,13 @@ func TestMinimize(t *testing.T) {
// Ensure `no_minimize` calls are untouched.
{
"linux", "amd64",
- "syz_mount_image$ext4(&(0x7f0000000000)='ext4\\x00', &(0x7f0000000100)='./file0\\x00', 0x40000, 0x2a, &(0x7f0000000200)=[{&(0x7f0000010000)='test\\x00'/32, 0x20, 0x400}], 0x0, &(0x7f0000010020), 0x1)\n",
+ "syz_mount_image$ext4(&(0x7f0000000000)='ext4\\x00', &(0x7f0000000100)='./file0\\x00', 0x40000, 0x1, &(0x7f0000000200)=[{&(0x7f0000010000)='test\\x00'/32, 0x20, 0x400}], 0x0, &(0x7f0000010020), 0x1)\n",
0,
func(p *Prog, callIndex int) bool {
// Anything is allowed except removing a call.
return len(p.Calls) > 0
},
- "syz_mount_image$ext4(&(0x7f0000000000)='ext4\\x00', &(0x7f0000000100)='./file0\\x00', 0x40000, 0x2a, &(0x7f0000000200)=[{&(0x7f0000010000)='test\\x00'/32, 0x20, 0x400}], 0x0, &(0x7f0000010020), 0x1)\n",
+ "syz_mount_image$ext4(&(0x7f0000000000)='ext4\\x00', &(0x7f0000000100)='./file0\\x00', 0x40000, 0x1, &(0x7f0000000200)=[{&(0x7f0000010000)='test\\x00'/32, 0x20, 0x400}], 0x0, &(0x7f0000010020), 0x1)\n",
0,
},
}
diff --git a/prog/prog.go b/prog/prog.go
index 87b9998b8..bb7caa7c5 100644
--- a/prog/prog.go
+++ b/prog/prog.go
@@ -414,6 +414,11 @@ func removeArg(arg0 Arg) {
})
}
+// The public alias for the removeArg method.
+func RemoveArg(arg Arg) {
+ removeArg(arg)
+}
+
// removeCall removes call idx from p.
func (p *Prog) RemoveCall(idx int) {
c := p.Calls[idx]
diff --git a/prog/test_util.go b/prog/test_util.go
index 07f24141a..71a52c809 100644
--- a/prog/test_util.go
+++ b/prog/test_util.go
@@ -66,9 +66,14 @@ func TestDeserializeHelper(t *testing.T, OS, arch string, transform func(*Target
transform(target, p)
}
output := strings.TrimSpace(string(p.Serialize()))
+ outputVerbose := strings.TrimSpace(string(p.SerializeVerbose()))
want := strings.TrimSpace(test.Out)
- if want != output {
- t.Fatalf("wrong serialized data:\n%s\nexpect:\n%s\n", output, want)
+ // We want to compare both verbose & non verbose mode.
+ // Otherwise we cannot have just In: field for the calls where
+ // the verbose and non-verbose output don't match -- the strict parsing
+ // mode does not accept the non-verbose output as input.
+ if want != output && want != outputVerbose {
+ t.Fatalf("wrong serialized data:\n%s\nexpect:\n%s\n", outputVerbose, want)
}
p.SerializeForExec(buf)
}