diff options
| author | Andrey Konovalov <andreyknvl@google.com> | 2017-05-18 18:17:16 +0200 |
|---|---|---|
| committer | Andrey Konovalov <andreyknvl@google.com> | 2017-06-12 19:48:23 +0200 |
| commit | c99b02d2248fbdcd6f44037326b16c928f4423f1 (patch) | |
| tree | 5e60a5df686a1160d6c88e40bc05223805a13749 /csource | |
| parent | 73a895df6168bc12559d1fa16aae7e52646d7ec3 (diff) | |
csource: try to simplify repeat loop
Diffstat (limited to 'csource')
| -rw-r--r-- | csource/common.go | 13 | ||||
| -rw-r--r-- | csource/csource.go | 4 | ||||
| -rw-r--r-- | csource/csource_test.go | 23 |
3 files changed, 28 insertions, 12 deletions
diff --git a/csource/common.go b/csource/common.go index 74f4aba35..b4d3f0a33 100644 --- a/csource/common.go +++ b/csource/common.go @@ -1728,7 +1728,7 @@ static int do_sandbox_namespace(int executor_pid, bool enable_tun) } #endif -#if defined(SYZ_EXECUTOR) || defined(SYZ_REPEAT) +#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT)) static void remove_dir(const char* dir) { DIR* dp; @@ -1797,9 +1797,7 @@ retry: exitf("rmdir(%s) failed", dir); } } -#endif -#if defined(SYZ_EXECUTOR) || defined(SYZ_REPEAT) static uint64_t current_time_ms() { struct timespec ts; @@ -1830,6 +1828,7 @@ static int inject_fault(int nth) #if defined(SYZ_REPEAT) static void test(); +#if defined(SYZ_WAIT_REPEAT) void loop() { int iter; @@ -1870,5 +1869,13 @@ void loop() remove_dir(cwdbuf); } } +#else +void loop() +{ + while (1) { + test(); + } +} +#endif #endif ` diff --git a/csource/csource.go b/csource/csource.go index 603cb37f5..ae3e54df8 100644 --- a/csource/csource.go +++ b/csource/csource.go @@ -36,6 +36,7 @@ type Options struct { EnableTun bool UseTmpDir bool HandleSegv bool + WaitRepeat bool // Generate code for use with repro package to prints log messages, // which allows to distinguish between a hang and an absent crash. @@ -381,6 +382,9 @@ func preprocessCommonHeader(opts Options, handled map[string]int, useBitmasks bo if opts.HandleSegv { defines = append(defines, "SYZ_HANDLE_SEGV") } + if opts.WaitRepeat { + defines = append(defines, "SYZ_WAIT_REPEAT") + } for name, _ := range handled { defines = append(defines, "__NR_"+name) } diff --git a/csource/csource_test.go b/csource/csource_test.go index ca39b162a..097e014ec 100644 --- a/csource/csource_test.go +++ b/csource/csource_test.go @@ -39,16 +39,21 @@ func allOptionsPermutations() []Options { for _, opt.EnableTun = range []bool{false, true} { for _, opt.UseTmpDir = range []bool{false, true} { for _, opt.HandleSegv = range []bool{false, true} { - if opt.Collide && !opt.Threaded { - continue + for _, opt.WaitRepeat = range []bool{false, true} { + if opt.Collide && !opt.Threaded { + continue + } + if !opt.Repeat && opt.Procs != 1 { + continue + } + if !opt.Repeat && opt.WaitRepeat { + continue + } + if testing.Short() && opt.Procs != 1 { + continue + } + options = append(options, opt) } - if !opt.Repeat && opt.Procs != 1 { - continue - } - if testing.Short() && opt.Procs != 1 { - continue - } - options = append(options, opt) } } } |
