1RUN: %cpp_compiler %S/FullCoverageSetTest.cpp -o %t-FullCoverageSetTest
2
3RUN: rm -rf %t/T0 %t/T1 %t/T2
4RUN: mkdir -p %t/T0 %t/T1 %t/T2
5RUN: echo F..... > %t/T0/1
6RUN: echo .U.... > %t/T0/2
7RUN: echo ..Z... > %t/T0/3
8
9# T1 has 3 elements, T2 is empty.
10RUN: cp %t/T0/* %t/T1/
11RUN: %run %t-FullCoverageSetTest         -merge=1 %t/T1 %t/T2 2>&1 | FileCheck %s --check-prefix=CHECK1
12CHECK1: MERGE-OUTER: 3 files, 3 in the initial corpus
13CHECK1: MERGE-OUTER: 0 new files with 0 new features added
14
15RUN: echo ...Z.. > %t/T2/1
16RUN: echo ....E. > %t/T2/2
17RUN: echo .....R > %t/T2/3
18RUN: echo F..... > %t/T2/a
19RUN: echo .U.... > %t/T2/b
20RUN: echo ..Z... > %t/T2/c
21
22# T1 has 3 elements, T2 has 6 elements, only 3 are new.
23RUN: %run %t-FullCoverageSetTest         -merge=1 %t/T1 %t/T2 2>&1 | FileCheck %s --check-prefix=CHECK2
24CHECK2: MERGE-OUTER: 9 files, 3 in the initial corpus
25CHECK2: MERGE-OUTER: 3 new files with 3 new features added
26
27# Now, T1 has 6 units and T2 has no new interesting units.
28RUN: %run %t-FullCoverageSetTest         -merge=1 %t/T1 %t/T2 2>&1 | FileCheck %s --check-prefix=CHECK3
29CHECK3: MERGE-OUTER: 12 files, 6 in the initial corpus
30CHECK3: MERGE-OUTER: 0 new files with 0 new features added
31
32# Check that we respect max_len during the merge and don't crash.
33RUN: rm %t/T1/*
34RUN: cp %t/T0/* %t/T1/
35RUN: echo looooooooong > %t/T2/looooooooong
36RUN: %run %t-FullCoverageSetTest         -merge=1 %t/T1 %t/T2 -max_len=6 2>&1 | FileCheck %s --check-prefix=MAX_LEN
37MAX_LEN: MERGE-OUTER: 3 new files
38
39# Check that we respect -merge_control_file=FILE
40RUN: rm %t/T1/*
41RUN: cp %t/T0/* %t/T1/
42RUN: rm -f %t/MCF
43RUN: %run %t-FullCoverageSetTest -merge=1 -merge_control_file=%t/MCF %t/T1 %t/T2 2>&1 | FileCheck %s --check-prefix=MCF
44RUN: grep STARTED %t/MCF
45RUN: grep FT %t/MCF
46MCF: MERGE-INNER: using the control file {{.*}}MCF
47MCF: MERGE-OUTER: 3 new files
48
49
50# Check that merge tolerates failures.
51RUN: rm %t/T1/*
52RUN: cp %t/T0/* %t/T1/
53RUN: echo 'FUZZER' > %t/T2/FUZZER
54RUN: %run %t-FullCoverageSetTest -merge=1 %t/T1 %t/T2 2>&1 | FileCheck %s --check-prefix=MERGE_WITH_CRASH
55MERGE_WITH_CRASH: MERGE-OUTER: succesfull in 2 attempt(s)
56MERGE_WITH_CRASH: MERGE-OUTER: 3 new files
57
58# Check that we actually limit the size with max_len
59RUN: rm %t/T1/* %t/T2/*
60RUN: echo 'FUZZER' > %t/T2/FUZZER
61RUN: %run %t-FullCoverageSetTest -merge=1 %t/T1 %t/T2  -max_len=5 2>&1 | FileCheck %s --check-prefix=MERGE_LEN5
62RUN: not grep FUZZER %t/T1/*
63RUN: grep FUZZE %t/T1/*
64MERGE_LEN5: MERGE-OUTER: succesfull in 1 attempt(s)
65
66