]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/fuzzer/afl-driver-extra-stats.test
Vendor import of compiler-rt trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / fuzzer / afl-driver-extra-stats.test
1 # AFL doesn't work on Windows. No reason to test the driver.
2 UNSUPPORTED: windows
3 XFAIL: ios
4 RUN: %no_fuzzer_cpp_compiler %S/AFLDriverTest.cpp %libfuzzer_src/afl/afl_driver.cpp -o %t-AFLDriverTest
5
6 ; Test that not specifying an extra stats file isn't broken.
7 RUN: unset AFL_DRIVER_EXTRA_STATS_FILENAME
8 RUN: %run %t-AFLDriverTest
9
10 ; Test that specifying an invalid extra stats file causes a crash.
11 RUN: ASAN_OPTIONS= AFL_DRIVER_EXTRA_STATS_FILENAME=%T not --crash %t-AFLDriverTest
12
13 ; Test that specifying a corrupted stats file causes a crash.
14 echo "peak_rss_mb :0" > %t
15 ASAN_OPTIONS= AFL_DRIVER_EXTRA_STATS_FILENAME=%t not --crash %t-AFLDriverTest
16
17 ; Test that specifying a valid nonexistent stats file works.
18 RUN: rm -f %t
19 RUN: AFL_DRIVER_EXTRA_STATS_FILENAME=%t %t-AFLDriverTest
20 RUN: [[ $(grep "peak_rss_mb\|slowest_unit_time_sec" %t | wc -l) -eq 2 ]]
21
22 ; Test that specifying a valid preexisting stats file works.
23 RUN: printf "peak_rss_mb : 0\nslowest_unit_time_sec: 0\n" > %t
24 RUN: AFL_DRIVER_EXTRA_STATS_FILENAME=%t %t-AFLDriverTest
25 ; Check that both lines were printed.
26 RUN: [[ $(grep "peak_rss_mb\|slowest_unit_time_sec" %t | wc -l) -eq 2 ]]
27
28 ; Test that peak_rss_mb and slowest_unit_time_in_secs are only updated when necessary.
29 ; Check that both lines have 9999 since there's no way we have exceeded that
30 ; amount of time or virtual memory.
31 RUN: printf "peak_rss_mb : 9999\nslowest_unit_time_sec: 9999\n" > %t
32 RUN: AFL_DRIVER_EXTRA_STATS_FILENAME=%t %t-AFLDriverTest
33 RUN: [[ $(grep "9999" %t | wc -l) -eq 2 ]]