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 : m_create(char,result,MEMORY_STRING);
12 : 2 : m_create(char,pattern,MEMORY_STRING);
13 : :
14 : 2 : const char *fixture_path = "tests/fixtures/diffs/diff1";
15 : 2 : const char *tracked_file_in_source_fixture = "tests/fixtures/diffs/diff1/path1/AAA/BCB/CCC/a.txt";
16 : :
17 : 2 : off_t sparse_file_size = 0;
18 : 2 : blkcnt_t sparse_blocks = 0;
19 : :
20 : : // First pass runs in TESTING mode without verbose output
21 : 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
22 : :
23 : : // Prepare a mutable working copy while keeping a pristine backup hidden from traversal
24 : 2 : ASSERT(SUCCESS == prepare_mutable_fixture(fixture_path));
25 : :
26 : 2 : ASSERT(SUCCESS == runit("--database=0034_lsize_vs_asize_flags.db tests/fixtures/diffs/diff1",NULL,NULL,COMPLETED,ALLOW_BOTH));
27 : :
28 : : // Case 1: grow logical size as sparse extension and preserve allocated blocks
29 : 2 : ASSERT(SUCCESS == make_sparse_size_change_without_allocated_block_growth(
30 : : tracked_file_in_source_fixture,
31 : : &sparse_file_size,
32 : : &sparse_blocks));
33 : :
34 : : // Second and third passes run in non-TESTING mode
35 : : // Second pass uses --verbose, third pass uses --watch-timestamps
36 : 2 : ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
37 : :
38 : 2 : ASSERT(SUCCESS == runit("--verbose --update --database=0034_lsize_vs_asize_flags.db tests/fixtures/diffs/diff1",result,NULL,COMPLETED,ALLOW_BOTH));
39 : :
40 : 2 : const char *filename = "templates/0034_001_1.txt";
41 : 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
42 : 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
43 : :
44 : 2 : ASSERT(NULL != strstr(m_text(result),"changed: lsize"));
45 : 2 : ASSERT(NULL == strstr(m_text(result),"changed: asize"));
46 : :
47 : : // Case 2: rewrite file densely with same logical size so only allocated blocks differ
48 : 2 : ASSERT(SUCCESS == rewrite_file_dense_with_same_size(
49 : : tracked_file_in_source_fixture,
50 : : sparse_file_size,
51 : : sparse_blocks));
52 : :
53 : 2 : ASSERT(SUCCESS == runit("--update --watch-timestamps --database=0034_lsize_vs_asize_flags.db tests/fixtures/diffs/diff1",result,NULL,COMPLETED,ALLOW_BOTH));
54 : :
55 : 2 : filename = "templates/0034_001_2.txt";
56 : 2 : ASSERT(SUCCESS == get_file_content(filename,pattern));
57 : 2 : ASSERT(SUCCESS == match_pattern(result,pattern,filename));
58 : :
59 : 2 : ASSERT(NULL == strstr(m_text(result),"changed: lsize"));
60 : 2 : ASSERT(NULL != strstr(m_text(result),"changed: asize"));
61 : 2 : ASSERT(NULL != strstr(m_text(result),"update & rehash"));
62 : 2 : ASSERT(NULL != strstr(m_text(result),"path1/AAA/BCB/CCC/a.txt"));
63 : :
64 : 2 : ASSERT(SUCCESS == delete_path("0034_lsize_vs_asize_flags.db"));
65 : 2 : ASSERT(SUCCESS == restore_mutable_fixture(fixture_path));
66 : :
67 : 2 : m_del(pattern);
68 : 2 : m_del(result);
69 : :
70 : 2 : RETURN_STATUS;
71 : : }
72 : :
73 : : /**
74 : : * @brief Run metadata-difference reporting coverage for logical and allocated size changes
75 : : *
76 : : * @return Return status code
77 : : */
78 : 2 : Return test0034(void)
79 : : {
80 : 2 : INITTEST;
81 : :
82 : 2 : TEST(test0034_1,"Metadata diff flags: lsize-only and asize-only cases");
83 : :
84 : 2 : RETURN_STATUS;
85 : : }
|