Branch data Line data Source code
1 : : #include "sute.h"
2 : :
3 : : /**
4 : : * @brief Verify that lsize and asize flags are reported independently from on-disk file changes
5 : : *
6 : : */
7 : 2 : static Return test0034_1(void)
8 : : {
9 : 2 : INITTEST;
10 : :
11 : 2 : create(char,result);
12 : 2 : create(char,pattern);
13 : :
14 : 2 : const char *fixture_path = "tests/fixtures/diffs/diff1";
15 : 2 : const char *fixture_backup_path = "tests/fixtures/diff1_backup";
16 : 2 : const char *tracked_file_in_source_fixture = "tests/fixtures/diffs/diff1/path1/AAA/BCB/CCC/a.txt";
17 : :
18 : 2 : off_t sparse_file_size = 0;
19 : 2 : blkcnt_t sparse_blocks = 0;
20 : :
21 : : // First pass runs in TESTING mode without verbose output
22 : 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
23 : :
24 : : // Prepare fixture copy using native move and copy helpers
25 : 2 : ASSERT(SUCCESS == move_path(fixture_path,fixture_backup_path));
26 : 2 : ASSERT(SUCCESS == copy_path(fixture_backup_path,fixture_path));
27 : :
28 : 2 : ASSERT(SUCCESS == runit("--database=0034_lsize_vs_asize_flags.db tests/fixtures/diffs/diff1",NULL,NULL,COMPLETED,ALLOW_BOTH));
29 : :
30 : : // Case 1: grow logical size as sparse extension and preserve allocated blocks
31 : 2 : ASSERT(SUCCESS == make_sparse_size_change_without_allocated_block_growth(
32 : : tracked_file_in_source_fixture,
33 : : &sparse_file_size,
34 : : &sparse_blocks));
35 : :
36 : : // Second and third passes run in non-TESTING mode
37 : : // Second pass uses --verbose, third pass uses --watch-timestamps
38 : 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
39 : :
40 : 2 : ASSERT(SUCCESS == runit("--verbose --update --database=0034_lsize_vs_asize_flags.db tests/fixtures/diffs/diff1",result,NULL,COMPLETED,ALLOW_BOTH));
41 : :
42 : 2 : const char *filename = "templates/0034_001_1.txt";
43 : 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
44 : 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
45 : :
46 : 2 : ASSERT(NULL != strstr(getcstring(result),"changed: lsize"));
47 : 2 : ASSERT(NULL == strstr(getcstring(result),"changed: asize"));
48 : :
49 : : // Case 2: rewrite file densely with same logical size so only allocated blocks differ
50 : 2 : ASSERT(SUCCESS == rewrite_file_dense_with_same_size(
51 : : tracked_file_in_source_fixture,
52 : : sparse_file_size,
53 : : sparse_blocks));
54 : :
55 : 2 : ASSERT(SUCCESS == runit("--update --watch-timestamps --database=0034_lsize_vs_asize_flags.db tests/fixtures/diffs/diff1",result,NULL,COMPLETED,ALLOW_BOTH));
56 : :
57 : 2 : filename = "templates/0034_001_2.txt";
58 : 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
59 : 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
60 : :
61 : 2 : ASSERT(NULL == strstr(getcstring(result),"changed: lsize"));
62 : 2 : ASSERT(NULL != strstr(getcstring(result),"changed: asize"));
63 : 2 : ASSERT(NULL != strstr(getcstring(result),"update & rehash"));
64 : 2 : ASSERT(NULL != strstr(getcstring(result),"path1/AAA/BCB/CCC/a.txt"));
65 : :
66 : 2 : ASSERT(SUCCESS == delete_path("0034_lsize_vs_asize_flags.db"));
67 : 2 : ASSERT(SUCCESS == delete_path(fixture_path));
68 : 2 : ASSERT(SUCCESS == move_path(fixture_backup_path,fixture_path));
69 : :
70 : 2 : del(pattern);
71 : 2 : del(result);
72 : :
73 : 2 : RETURN_STATUS;
74 : : }
75 : :
76 : 2 : Return test0034(void)
77 : : {
78 : 2 : INITTEST;
79 : :
80 : 2 : TEST(test0034_1,"Metadata diff flags: lsize-only and asize-only cases…");
81 : :
82 : 2 : RETURN_STATUS;
83 : : }
|