Skip to content

Commit e011963

Browse files
committed
gufi_rollup --dry-run fix
added dry_run test
1 parent def6510 commit e011963

File tree

3 files changed

+76
-3
lines changed

3 files changed

+76
-3
lines changed

src/gufi_rollup.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ static int do_rollup(struct RollUp *rollup,
875875
* were integrated into above loop, but that would add a lot
876876
* of complexity
877877
*/
878-
if (!rc) {
878+
if (!rc && !pa->in.dry_run) {
879879
bottomup_collect_treesummary(dst, rollup->data.name, &rollup->data.subdirs, ROLLUPSCORE_KNOWN_YES);
880880
}
881881

@@ -979,7 +979,9 @@ static int rollup_ascend(void *args) {
979979
}
980980
}
981981

982-
bottomup_collect_treesummary(dst, dir->data.name, &dir->data.subdirs, ROLLUPSCORE_KNOWN_NO);
982+
if (!pa->in.dry_run) {
983+
bottomup_collect_treesummary(dst, dir->data.name, &dir->data.subdirs, ROLLUPSCORE_KNOWN_NO);
984+
}
983985
}
984986
}
985987

test/regression/gufi_rollup.expected

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ GUFI_tree GUFI tree to roll up
1919
Creating GUFI tree search with 1 threads
2020
Total Dirs: 69
2121
Total Non-Dirs: 96
22+
$ gufi_rollup --dry-run "search"
2223
Roots:
2324
search
2425

@@ -72,6 +73,62 @@ Files/Links: 96
7273
Directories: 70 (22 empty)
7374
Total: 166
7475
Remaining Dirs: 18 (25.71%)
76+
77+
$ gufi_rollup "search"
78+
Roots:
79+
search
80+
81+
Thread Pool Size: 1
82+
Files/Links Limit: 0
83+
84+
Not Processed: 0
85+
Cannot Roll Up: 5
86+
Subdirectories:
87+
min: 1
88+
max: 4
89+
median: 4.00
90+
sum: 17
91+
average: 3.40
92+
Files/Links:
93+
min: 0
94+
max: 0
95+
median: 0.00
96+
sum: 0
97+
average: 0.00
98+
Level:
99+
min: 0
100+
max: 2
101+
median: 2.00
102+
sum: 7
103+
average: 1.40
104+
Too Many Before: 0
105+
Too Many After: 0
106+
Can Roll Up: 65
107+
Subdirectories:
108+
min: 0
109+
max: 4
110+
median: 0.00
111+
sum: 52
112+
average: 0.80
113+
Files/Links:
114+
min: 0
115+
max: 3
116+
median: 1.00
117+
sum: 96
118+
average: 1.48
119+
Level:
120+
min: 2
121+
max: 4
122+
median: 4.00
123+
sum: 242
124+
average: 3.72
125+
Successful: 65
126+
Failed: 0
127+
Files/Links: 96
128+
Directories: 70 (22 empty)
129+
Total: 166
130+
Remaining Dirs: 18 (25.71%)
131+
75132
$ gufi_query -d " " -S "SELECT rpath(sname, sroll) FROM vrsummary;" "search" | wc -l
76133
69
77134

@@ -723,6 +780,7 @@ $ gufi_stats -c total-dircount prefix
723780
Creating GUFI tree search with 1 threads
724781
Total Dirs: 69
725782
Total Non-Dirs: 96
783+
$ gufi_rollup --limit 3 "search"
726784
Roots:
727785
search
728786

@@ -781,6 +839,7 @@ Files/Links: 96
781839
Directories: 70 (22 empty)
782840
Total: 166
783841
Remaining Dirs: 70 (100.00%)
842+
784843
$ gufi_query -d " " -S "SELECT rpath(sname, sroll) FROM vrsummary;" "search" | wc -l
785844
69
786845

@@ -1687,6 +1746,7 @@ Files/Links: 14
16871746
Directories: 7 (2 empty)
16881747
Total: 21
16891748
Remaining Dirs: 2 (28.57%)
1749+
16901750
# test-xattr.db is only left at prefix and prefix/directory/subdirectory
16911751
$ find "prefix" -name "*.db"
16921752
prefix/db.db

test/regression/gufi_rollup.sh.in

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,22 @@ do_tests() {
136136
run_sort "${GUFI_STATS} -c total-dircount ${BASENAME}"
137137
}
138138

139+
# there is a weird bug with printing out stats when
140+
# running gufi_query on alpine linux in run_no_sort
141+
139142
"${GUFI_DIR2INDEX}" "${SRCDIR}" "${SEARCH}" 2>&1
140143
"${GUFI_QUERY}" \
141144
-a 1 \
142145
-w \
143146
-S "UPDATE summary SET uid = 0, gid = 0, minuid = 0, maxuid = 0, mingid = 0, maxgid = 0;" \
144147
-E "UPDATE entries SET uid = 0, gid = 0;" \
145148
"${SEARCH}"
149+
echo "$ ${GUFI_ROLLUP} --dry-run \"${SEARCH}\""
150+
"${GUFI_ROLLUP}" --dry-run "${SEARCH}"
151+
echo
152+
echo "$ ${GUFI_ROLLUP} \"${SEARCH}\""
146153
"${GUFI_ROLLUP}" "${SEARCH}"
154+
echo
147155
do_tests
148156

149157
rm -r "${SEARCH}"
@@ -155,7 +163,9 @@ rm -r "${SEARCH}"
155163
-S "UPDATE summary SET uid = 0, gid = 0, minuid = 0, maxuid = 0, mingid = 0, maxgid = 0;" \
156164
-E "UPDATE entries SET uid = 0, gid = 0;" \
157165
"${SEARCH}"
166+
echo "$ ${GUFI_ROLLUP} --limit 3 \"${SEARCH}\""
158167
"${GUFI_ROLLUP}" --limit 3 "${SEARCH}"
168+
echo
159169
do_tests
160170

161171
rm -rf "${SEARCH}"
@@ -216,7 +226,8 @@ rm -rf "${SEARCH}"
216226

217227
echo "# delete rollups under ${INDEXROOT}"
218228
echo "$ ${GUFI_ROLLUP} --delete-below 1 \"${SEARCH}\""
219-
"${GUFI_ROLLUP}" --delete-below 1 "${SEARCH}" # alpine linux is weird about running this in run_no_sort
229+
"${GUFI_ROLLUP}" --delete-below 1 "${SEARCH}"
230+
echo
220231

221232
echo "# ${EXT_DBNAME} is only left at ${INDEXROOT} and ${INSERT_DIR}"
222233
run_sort "find \"${INDEXROOT}\" -name \"*.db\""

0 commit comments

Comments
 (0)