Branch data 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 : const char *create_symlinks_command = "cd ${TMPDIR} && ln -s ../../../../1/AAA/BCB/CCC/a.txt tests/fixtures/diffs/diff1/path1/AAA/BCB/CCC/symlink_to_the_file_a.txt && "
18 : : "ln -s ../../../../AAA/ZAW/D/e/f tests/fixtures/diffs/diff1/path1/AAA/ZAW/A/b/symlink_to_dir_f && "
19 : : "ln -s /to/nowhere tests/fixtures/diffs/diff1/path1/AAA/ZAW/A/b/broken_symlink";
20 : 2 : const char *update_arguments = "--update --database=database1.db tests/fixtures/diffs/diff1";
21 : :
22 : 2 : create(char,pattern);
23 : :
24 : : // Create memory for the result
25 : 2 : create(char,result);
26 : :
27 : : // Preparation for the test
28 : 2 : ASSERT(SUCCESS == move_path("tests/fixtures/diffs/diff1","tests/fixtures/diff1_backup"));
29 : 2 : ASSERT(SUCCESS == copy_path("tests/fixtures/diff1_backup","tests/fixtures/diffs/diff1"));
30 : :
31 : 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
32 : :
33 : 2 : ASSERT(SUCCESS == external_call(create_symlinks_command,NULL,NULL,COMPLETED,ALLOW_BOTH));
34 : :
35 : 2 : const char *arguments = "--database=database1.db tests/fixtures/diffs/diff1";
36 : :
37 : 2 : const char *filename = "templates/0019_001.txt";
38 : :
39 : 2 : ASSERT(SUCCESS == runit(arguments,result,NULL,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 : ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1/path1/AAA/BCB/CCC/symlink_to_the_file_a.txt"));
48 : 2 : ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1/path1/AAA/ZAW/A/b/symlink_to_dir_f"));
49 : 2 : ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1/path1/AAA/ZAW/A/b/broken_symlink"));
50 : :
51 : 2 : filename = "templates/0019_002.txt";
52 : :
53 : 2 : ASSERT(SUCCESS == runit(update_arguments,result,NULL,COMPLETED,ALLOW_BOTH));
54 : 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
55 : 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
56 : :
57 : : // Clean to use it iteratively
58 : 2 : del(pattern);
59 : 2 : del(result);
60 : :
61 : 2 : ASSERT(SUCCESS == external_call(create_symlinks_command,NULL,NULL,COMPLETED,ALLOW_BOTH));
62 : :
63 : 2 : filename = "templates/0019_003.txt";
64 : :
65 : 2 : ASSERT(SUCCESS == runit(update_arguments,result,NULL,COMPLETED,ALLOW_BOTH));
66 : 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
67 : 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
68 : :
69 : : // Clean to use it iteratively
70 : 2 : del(pattern);
71 : 2 : del(result);
72 : :
73 : : // Clean up test results
74 : 2 : ASSERT(SUCCESS == delete_path("database1.db"));
75 : 2 : ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1"));
76 : :
77 : 2 : ASSERT(SUCCESS == move_path("tests/fixtures/diff1_backup","tests/fixtures/diffs/diff1"));
78 : :
79 : 2 : RETURN_STATUS;
80 : : }
|