Branch data Line data Source code
1 : : #include "sute.h"
2 : :
3 : : /**
4 : : * "inaccessible" message of file_show() function
5 : : */
6 : 2 : static Return test0029_1(void)
7 : : {
8 : 2 : INITTEST;
9 : :
10 : : // Create memory for the result
11 : 2 : create(char,result);
12 : 2 : create(char,pattern);
13 : :
14 : 2 : const char *command = "cd ${TMPDIR};"
15 : : "mv tests/fixtures/diffs/diff1 tests/fixtures/diff1_backup;"
16 : : "cp -a tests/fixtures/diff1_backup tests/fixtures/diffs/diff1;";
17 : :
18 : : // Preparation for tests
19 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
20 : :
21 [ + - + - ]: 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
22 : :
23 : 2 : const char *arguments = "--silent --database=database1.db tests/fixtures/diffs/diff1";
24 : :
25 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
26 : :
27 [ - + ]: 2 : if(result->length > 0)
28 : : {
29 : 0 : echo(STDERR,"STDOUT buffer is not empty. It contains characters: %zu\n",result->length);
30 : 0 : status = FAILURE;
31 : : #if 0
32 : : echo(STDOUT,"%s\n",getcstring(result));
33 : : #endif
34 : : }
35 : :
36 : 2 : command = "cd ${TMPDIR};"
37 : : "chmod 000 tests/fixtures/diffs/diff1/1/AAA/ZAW/D/e/f/b_file.txt;"
38 : : "chmod 000 tests/fixtures/diffs/diff1/2/AAA/BBB/CZC;"; // Change directory permitions
39 : :
40 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
41 : :
42 [ + - + - ]: 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
43 : :
44 : 2 : arguments = "--update --database=database1.db tests/fixtures/diffs/diff1";
45 : :
46 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
47 : :
48 : 2 : const char *filename = "templates/0029_001.txt";
49 : :
50 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
51 [ + - + - ]: 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
52 : :
53 : 2 : del(pattern);
54 : 2 : del(result);
55 : :
56 : : // Clean up test results
57 : 2 : command = "cd ${TMPDIR} && "
58 : : "rm database1.db && "
59 : : "chmod -R a+rwX tests/fixtures/diffs/diff1 && "
60 : : "rm -rf tests/fixtures/diffs/diff1 && "
61 : : "mv tests/fixtures/diff1_backup tests/fixtures/diffs/diff1";
62 : :
63 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
64 : :
65 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
66 : : }
67 : :
68 : : /**
69 : : * --db-drop-inaccessible option. Dropping DB records for inaccessible paths
70 : : */
71 : 2 : static Return test0029_2(void)
72 : : {
73 : 2 : INITTEST;
74 : :
75 : : // Create memory for the result
76 : 2 : create(char,result);
77 : 2 : create(char,pattern);
78 : :
79 : 2 : const char *command = "cd ${TMPDIR};"
80 : : "mv tests/fixtures/diffs/diff1 tests/fixtures/diff1_backup;"
81 : : "cp -a tests/fixtures/diff1_backup tests/fixtures/diffs/diff1;";
82 : :
83 : : // Preparation for tests
84 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
85 : :
86 [ + - + - ]: 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
87 : :
88 : 2 : const char *arguments = "--silent --database=database2.db tests/fixtures/diffs/diff1";
89 : :
90 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
91 : :
92 [ - + ]: 2 : if(result->length > 0)
93 : : {
94 : 0 : echo(STDERR,"STDOUT buffer is not empty. It contains characters: %zu\n",result->length);
95 : 0 : status = FAILURE;
96 : : #if 0
97 : : echo(STDOUT,"%s\n",getcstring(result));
98 : : #endif
99 : : }
100 : :
101 : 2 : command = "cd ${TMPDIR};"
102 : : "chmod 000 tests/fixtures/diffs/diff1/1/AAA/ZAW/D/e/f/b_file.txt;"
103 : : "chmod 000 tests/fixtures/diffs/diff1/2/AAA/BBB/CZC;"; // Change directory permitions
104 : :
105 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
106 : :
107 [ + - + - ]: 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
108 : :
109 : 2 : arguments = "--update --db-drop-inaccessible --database=database2.db "
110 : : "tests/fixtures/diffs/diff1";
111 : :
112 [ + - + - ]: 2 : ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
113 : :
114 : 2 : const char *filename = "templates/0029_002.txt";
115 : :
116 [ + - + - ]: 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
117 [ + - + - ]: 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
118 : :
119 : 2 : del(pattern);
120 : 2 : del(result);
121 : :
122 : : // Clean up test results
123 : 2 : command = "cd ${TMPDIR} && "
124 : : "rm database2.db && "
125 : : "chmod -R a+rwX tests/fixtures/diffs/diff1 && "
126 : : "rm -rf tests/fixtures/diffs/diff1 && "
127 : : "mv tests/fixtures/diff1_backup tests/fixtures/diffs/diff1";
128 : :
129 [ + - + - ]: 2 : ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
130 : :
131 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
132 : : }
133 : :
134 : : /**
135 : : *
136 : : * Testing how the application behaves with inaccessible files
137 : : *
138 : : */
139 : 2 : Return test0029(void)
140 : : {
141 : 2 : INITTEST;
142 : :
143 [ + - ]: 2 : TEST(test0029_1,"\"inaccessible\" message of file_show() function…");
144 [ + - ]: 2 : TEST(test0029_2,"--db-drop-inaccessible option. Dropping DB records for inaccessible paths…");
145 : :
146 [ + - - + : 2 : RETURN_STATUS;
- - - + +
- ]
147 : : }
|