Line data Source code
1 : #include "sute.h"
2 :
3 : /**
4 : *
5 : * Testing symlink operations
6 : *
7 : * Test Scenario:
8 : * 1. Add symlinks, create database
9 : * 2. Remove symlinks, update database
10 : * 3. Add symlinks, update database
11 : *
12 : */
13 2 : Return test0019(void)
14 : {
15 2 : INITTEST;
16 :
17 2 : create(char,pattern);
18 :
19 : // Create memory for the result
20 2 : create(char,result);
21 :
22 : // Preparation for the test
23 2 : ASSERT(SUCCESS == external_call("cd ${TMPDIR} && "
24 : "cp -a tests/examples/ tests/examples_backup;",COMPLETED,ALLOW_BOTH));
25 :
26 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
27 :
28 2 : const char *command = "cd ${TMPDIR} && "
29 : "ln -s ../../../../1/AAA/BCB/CCC/a.txt tests/examples/diffs/diff1/path1/AAA/BCB/CCC/symlink_to_the_file_a.txt && "
30 : "ln -s ../../../../AAA/ZAW/D/e/f tests/examples/diffs/diff1/path1/AAA/ZAW/A/b/symlink_to_dir_f && "
31 : "ln -s /to/nowhere tests/examples/diffs/diff1/path1/AAA/ZAW/A/b/broken_symlink";
32 :
33 2 : ASSERT(SUCCESS == external_call(command,COMPLETED,ALLOW_BOTH));
34 :
35 2 : const char *arguments = "--database=database1.db tests/examples/diffs/diff1";
36 :
37 2 : const char *filename = "templates/0019_001.txt";
38 :
39 2 : ASSERT(SUCCESS == runit(arguments,result,COMPLETED,ALLOW_BOTH));
40 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
41 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
42 :
43 : // Clean to use it iteratively
44 2 : del(pattern);
45 2 : del(result);
46 :
47 2 : command = "cd ${TMPDIR} && "
48 : "rm tests/examples/diffs/diff1/path1/AAA/BCB/CCC/symlink_to_the_file_a.txt && "
49 : "rm tests/examples/diffs/diff1/path1/AAA/ZAW/A/b/symlink_to_dir_f && "
50 : "rm tests/examples/diffs/diff1/path1/AAA/ZAW/A/b/broken_symlink";
51 :
52 2 : ASSERT(SUCCESS == external_call(command,COMPLETED,ALLOW_BOTH));
53 :
54 2 : arguments = "--update --database=database1.db tests/examples/diffs/diff1";
55 :
56 2 : filename = "templates/0019_002.txt";
57 :
58 2 : ASSERT(SUCCESS == runit(arguments,result,COMPLETED,ALLOW_BOTH));
59 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
60 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
61 :
62 : // Clean to use it iteratively
63 2 : del(pattern);
64 2 : del(result);
65 :
66 2 : command = "cd ${TMPDIR} && "
67 : "ln -s ../../../../1/AAA/BCB/CCC/a.txt tests/examples/diffs/diff1/path1/AAA/BCB/CCC/symlink_to_the_file_a.txt && "
68 : "ln -s ../../../../AAA/ZAW/D/e/f tests/examples/diffs/diff1/path1/AAA/ZAW/A/b/symlink_to_dir_f && "
69 : "ln -s /to/nowhere tests/examples/diffs/diff1/path1/AAA/ZAW/A/b/broken_symlink";
70 :
71 2 : ASSERT(SUCCESS == external_call(command,COMPLETED,ALLOW_BOTH));
72 :
73 2 : arguments = "--update --database=database1.db tests/examples/diffs/diff1";
74 :
75 2 : filename = "templates/0019_003.txt";
76 :
77 2 : ASSERT(SUCCESS == runit(arguments,result,COMPLETED,ALLOW_BOTH));
78 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
79 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
80 :
81 : // Clean to use it iteratively
82 2 : del(pattern);
83 2 : del(result);
84 :
85 : // Clean up test results
86 2 : ASSERT(SUCCESS == external_call("cd ${TMPDIR} && "
87 : "rm database1.db && "
88 : "rm -rf tests/examples/ && "
89 : "mv tests/examples_backup/ tests/examples/",COMPLETED,ALLOW_BOTH));
90 :
91 2 : RETURN_STATUS;
92 : }
|