Branch data 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 : const char *diff1_fixture_path = "tests/fixtures/diffs/diff1";
20 : 2 : const char *diff1_backup_path = "tests/fixtures/diff1_backup";
21 : 2 : ASSERT(SUCCESS == move_path(diff1_fixture_path,diff1_backup_path));
22 : 2 : ASSERT(SUCCESS == copy_path(diff1_backup_path,diff1_fixture_path));
23 : :
24 : 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
25 : :
26 : 2 : ASSERT(SUCCESS == runit("--start-device-only --database=database1.db tests/fixtures/diffs/diff1",chunk,NULL,COMPLETED,ALLOW_BOTH));
27 : 2 : ASSERT(SUCCESS == copy(result,chunk));
28 : :
29 : 2 : ASSERT(SUCCESS == copy_path("database1.db","database2.db"));
30 : :
31 : 2 : ASSERT(SUCCESS == add_string_to("PWOEUNVSODNLKUHGE","tests/fixtures/diffs/diff1/1/AAA/BCB/CCC/a.txt"));
32 : :
33 : 2 : ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1/path2/AAA/ZAW/D/e/f/b_file.txt"));
34 : :
35 : : // Bump file mtime by a nanosecond delta without changing file content
36 : 2 : ASSERT(SUCCESS == touch_file_mtime_with_reference_delta_ns(NULL,"tests/fixtures/diffs/diff1/2/AAA/BBB/CZC/a.txt",999));
37 : :
38 : 2 : ASSERT(SUCCESS == runit("--update --check-level=QUICK --database=database1.db tests/fixtures/diffs/diff1",chunk,NULL,COMPLETED,ALLOW_BOTH));
39 : 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
40 : :
41 : 2 : const char *compare_arguments = "--compare database1.db database2.db";
42 : 2 : ASSERT(SUCCESS == runit(compare_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
43 : 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
44 : :
45 : 2 : ASSERT(SUCCESS == copy_path("database2.db","database1.db"));
46 : :
47 : 2 : const char *watch_update_arguments = "--watch-timestamps --update --database=database1.db tests/fixtures/diffs/diff1";
48 : 2 : ASSERT(SUCCESS == runit(watch_update_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
49 : 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
50 : :
51 : 2 : ASSERT(SUCCESS == runit(compare_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
52 : 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
53 : :
54 : 2 : const char *filename = "templates/0016_001_1.txt";
55 : 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
56 : 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
57 : :
58 : : // Clean to use it iteratively
59 : 2 : del(pattern);
60 : 2 : del(result);
61 : 2 : del(chunk);
62 : :
63 : 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
64 : :
65 : 2 : ASSERT(SUCCESS == copy_path("database2.db","database1.db"));
66 : :
67 : 2 : ASSERT(SUCCESS == runit("--update --database=database1.db tests/fixtures/diffs/diff1",chunk,NULL,COMPLETED,ALLOW_BOTH));
68 : 2 : ASSERT(SUCCESS == copy(result,chunk));
69 : :
70 : 2 : ASSERT(SUCCESS == runit(compare_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
71 : 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
72 : :
73 : 2 : ASSERT(SUCCESS == copy_path("database2.db","database1.db"));
74 : :
75 : 2 : ASSERT(SUCCESS == runit(watch_update_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
76 : 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
77 : :
78 : 2 : ASSERT(SUCCESS == runit(compare_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
79 : 2 : ASSERT(SUCCESS == concat_strings(result,chunk));
80 : :
81 : 2 : filename = "templates/0016_001_2.txt";
82 : 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
83 : 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
84 : :
85 : : // Clean to use it iteratively
86 : 2 : del(pattern);
87 : 2 : del(result);
88 : 2 : del(chunk);
89 : :
90 : : // Clean up test results
91 : 2 : ASSERT(SUCCESS == delete_path("database1.db"));
92 : 2 : ASSERT(SUCCESS == delete_path("database2.db"));
93 : 2 : ASSERT(SUCCESS == delete_path(diff1_fixture_path));
94 : :
95 : 2 : ASSERT(SUCCESS == move_path(diff1_backup_path,diff1_fixture_path));
96 : :
97 : 2 : RETURN_STATUS;
98 : : }
|