Line data Source code
1 : #include "sute.h"
2 :
3 : /**
4 : *
5 : * --watch-timestamps argument testing
6 : *
7 : */
8 2 : Return test0016(void)
9 : {
10 2 : INITTEST;
11 :
12 2 : create(char,pattern);
13 :
14 : // Create memory for the result
15 2 : create(char,result);
16 2 : create(char,chunk);
17 :
18 : // Preparation for the test
19 2 : ASSERT(SUCCESS == external_call("cd ${TMPDIR} && "
20 : "cp -a tests/examples/ tests/examples_backup;",COMPLETED,ALLOW_BOTH));
21 :
22 2 : const char *filename = "templates/0016_001_1.txt";
23 :
24 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
25 :
26 2 : ASSERT(SUCCESS == runit("--start-device-only --database=database1.db tests/examples/diffs/diff1",chunk,COMPLETED,ALLOW_BOTH));
27 2 : ASSERT(SUCCESS == copy(result,chunk));
28 :
29 2 : ASSERT(SUCCESS == external_call("cd ${TMPDIR} && cp -a database1.db database2.db",COMPLETED,ALLOW_BOTH));
30 2 : ASSERT(SUCCESS == external_call("cd ${TMPDIR} && "
31 : "echo -n 'PWOEUNVSODNLKUHGE' >> tests/examples/diffs/diff1/1/AAA/BCB/CCC/a.txt && "
32 : "touch tests/examples/diffs/diff1/2/AAA/BBB/CZC/a.txt && "
33 : "rm tests/examples/diffs/diff1/path2/AAA/ZAW/D/e/f/b_file.txt",COMPLETED,ALLOW_BOTH));
34 :
35 2 : ASSERT(SUCCESS == runit("--update --check-level=QUICK --database=database1.db tests/examples/diffs/diff1",chunk,COMPLETED,ALLOW_BOTH));
36 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
37 :
38 2 : ASSERT(SUCCESS == runit("--compare database1.db database2.db",chunk,COMPLETED,ALLOW_BOTH));
39 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
40 :
41 2 : ASSERT(SUCCESS == external_call("cd ${TMPDIR} && cp -a database2.db database1.db",COMPLETED,ALLOW_BOTH));
42 :
43 2 : ASSERT(SUCCESS == runit("--watch-timestamps --update --database=database1.db tests/examples/diffs/diff1",chunk,COMPLETED,ALLOW_BOTH));
44 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
45 :
46 2 : ASSERT(SUCCESS == runit("--compare database1.db database2.db",chunk,COMPLETED,ALLOW_BOTH));
47 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
48 :
49 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
50 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
51 :
52 : // Clean to use it iteratively
53 2 : del(pattern);
54 2 : del(result);
55 2 : del(chunk);
56 :
57 2 : filename = "templates/0016_001_2.txt";
58 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
59 :
60 2 : ASSERT(SUCCESS == external_call("cd ${TMPDIR} && cp -a database2.db database1.db",COMPLETED,ALLOW_BOTH));
61 :
62 2 : ASSERT(SUCCESS == runit("--update --database=database1.db tests/examples/diffs/diff1",chunk,COMPLETED,ALLOW_BOTH));
63 2 : ASSERT(SUCCESS == copy(result,chunk));
64 :
65 2 : ASSERT(SUCCESS == runit("--compare database1.db database2.db",chunk,COMPLETED,ALLOW_BOTH));
66 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
67 :
68 2 : ASSERT(SUCCESS == external_call("cd ${TMPDIR} && cp -a database2.db database1.db",COMPLETED,ALLOW_BOTH));
69 :
70 2 : ASSERT(SUCCESS == runit("--watch-timestamps --update --database=database1.db tests/examples/diffs/diff1",chunk,COMPLETED,ALLOW_BOTH));
71 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
72 :
73 2 : ASSERT(SUCCESS == runit("--compare database1.db database2.db",chunk,COMPLETED,ALLOW_BOTH));
74 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
75 :
76 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
77 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
78 :
79 : // Clean to use it iteratively
80 2 : del(pattern);
81 2 : del(result);
82 2 : del(chunk);
83 :
84 : // Clean up test results
85 2 : ASSERT(SUCCESS == external_call("cd ${TMPDIR} && "
86 : "rm database1.db && "
87 : "rm database2.db && "
88 : "rm -rf tests/examples/ && "
89 : "mv tests/examples_backup/ tests/examples/",COMPLETED,ALLOW_BOTH));
90 :
91 2 : RETURN_STATUS;
92 : }
|