From db0f57870523a9bff1629dad1a340ba8aac79d82 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 1 Oct 2021 14:43:02 +0000 Subject: pkg/csource: remove calls instead of skipping them Currently csource skips calls at the very last moment, which has an unpleasant consequence - if we make choice of enabled defines depend on the individual calls or call properties, we may end up with defined yet unused functions. The perfect solution would be to untie syz_emit_ethernet/syz_extract_tcp_res and NetInjection, and also to untie VhciInjection and syz_emit_vhci. For the time being, move these checks to the very beginning of csource processing, so that these calls could be removed before we construct our defines. Adjust pkg/csource/csource_test.go to better cover fault injection generation problems. --- pkg/csource/csource_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pkg/csource/csource_test.go') diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index ebf22d5f9..aa242e876 100644 --- a/pkg/csource/csource_test.go +++ b/pkg/csource/csource_test.go @@ -58,10 +58,6 @@ func testTarget(t *testing.T, target *prog.Target, full bool) { // Testing 2 programs takes too long since we have lots of options permutations and OS/arch. // So we use the as-is in short tests and minimized version in full tests. syzProg := target.GenerateAllSyzProg(rs) - if len(syzProg.Calls) > 0 { - // Test fault injection generation as well. - p.Calls[0].Props.FailNth = 1 - } var opts []Options if !full || testing.Short() { p.Calls = append(p.Calls, syzProg.Calls...) @@ -74,6 +70,10 @@ func testTarget(t *testing.T, target *prog.Target, full bool) { p.Calls = append(p.Calls, minimized.Calls...) opts = allOptionsPermutations(target.OS) } + if len(p.Calls) > 0 { + // Test fault injection code generation as well. + p.Calls[0].Props.FailNth = 1 + } for opti, opts := range opts { if testing.Short() && opts.HandleSegv { // HandleSegv can radically increase compilation time/memory consumption on large programs. -- cgit mrf-deployment