From 1856cdc9b3652a082c5bfa0e08a9f883baece8ec Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 15 Sep 2022 09:05:13 +0000 Subject: 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. --- prog/minimization_test.go | 4 ++-- prog/prog.go | 5 +++++ prog/test_util.go | 9 +++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'prog') 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) } -- cgit mrf-deployment