Skip to content

Commit ff426f1

Browse files
committed
more cleanup and tests
1 parent dff4a4d commit ff426f1

File tree

9 files changed

+26
-10
lines changed

9 files changed

+26
-10
lines changed

contrib/split_trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ int main(int argc, char *argv[]) {
214214

215215
QPTPool_t *pool = QPTPool_init(threads, prefix);
216216
if (QPTPool_start(pool) != 0) {
217-
fprintf(stderr, "Error: Failed to start thread pool\n");
217+
fprintf(stderr, "Error: Failed to start thread pool with %zu threads\n", threads);
218218
QPTPool_destroy(pool);
219219
close(fd);
220220
return 1;

contrib/treediff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ int main(int argc, char *argv[]) {
376376

377377
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
378378
if (!OutputBuffers_init(&pa.obufs, pa.in.maxthreads, pa.in.output_buffer_size, &mutex)) {
379+
fprintf(stderr, "Error: Could not initialize %zu output buffers\n", pa.in.maxthreads);
379380
rc = 1;
380381
goto done;
381382
}

src/parallel_cpr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static int cpr_file(QPTPool_t *ctx, const size_t id, void *data, void *args) {
144144

145145
str_t dst = create_dst_name(in, work);
146146

147-
const int dst_fd = open(dst.data, O_CREAT | O_WRONLY, st.st_mode);
147+
const int dst_fd = open(dst.data, O_CREAT | O_WRONLY | O_TRUNC, st.st_mode);
148148
if (dst_fd < 0) {
149149
print_error_and_goto("Could not open file", dst.data, free_name);
150150
}

src/parallel_rmr.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ static int rm_dir(void *args timestamp_sig) {
8989
sll_loop(&dir->subnondirs, node) {
9090
struct BottomUp * entry = (struct BottomUp *) sll_node_data(node);
9191
if (unlink(entry->name) != 0) {
92-
fprintf(stderr, "Warning: Failed to delete \"%s\": %s\n", entry->name, strerror(errno));
92+
const int err = errno;
93+
fprintf(stderr, "Warning: Failed to delete \"%s\": %s\n", entry->name, strerror(err));
9394
rc = 1;
9495
}
9596
}
9697

9798
if (rmdir(dir->name) != 0) {
98-
fprintf(stderr, "Warning: Failed to remove \"%s\": %s\n", dir->name, strerror(errno));
99+
const int err = errno;
100+
fprintf(stderr, "Warning: Failed to remove \"%s\": %s\n", dir->name, strerror(err));
99101
return 1;
100102
}
101103

test/regression/external_databases.sh.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ do_tests() {
206206
"-Q \"${FACTION1_DB}\" \"${TABLE}\" \"${FACTION1_TEMPLATE_ATTACH}.${TABLE}\" \"${FACTION1_VIEW}\"" \
207207
"-S \"SELECT rpath(evrsummary.sname, evrsummary.sroll), evrsummary.type, ${FACTION1_VIEW}.data FROM evrsummary LEFT JOIN ${FACTION1_VIEW} ON (evrsummary.name == ${FACTION1_VIEW}.name) AND (evrsummary.type == ${FACTION1_VIEW}.type);\"" \
208208
"-E \"SELECT rpath(evrpentries.sname, evrpentries.sroll) || '/' || evrpentries.name, evrpentries.type, ${FACTION1_VIEW}.data FROM evrpentries LEFT JOIN ${FACTION1_VIEW} ON (evrpentries.name == ${FACTION1_VIEW}.name) AND (evrpentries.type == ${FACTION1_VIEW}.type);\"" \
209-
"\"${INDEXROOT}\""
209+
"\"${SEARCH}\""
210210

211211
echo "# again, but with xattrs"
212212
echo "# SELECT rpath(), type, xattr_name, xattr_value, faction1 user data"
@@ -217,7 +217,7 @@ do_tests() {
217217
"-Q \"${FACTION1_DB}\" \"${TABLE}\" \"${FACTION1_TEMPLATE_ATTACH}.${TABLE}\" \"${FACTION1_VIEW}\"" \
218218
"-S \"SELECT rpath(evrxsummary.sname, evrxsummary.sroll), evrxsummary.type, evrxsummary.xattr_name, evrxsummary.xattr_value, ${FACTION1_VIEW}.data FROM evrxsummary LEFT JOIN ${FACTION1_VIEW} ON (evrxsummary.name == ${FACTION1_VIEW}.name) AND (evrxsummary.type == ${FACTION1_VIEW}.type);\"" \
219219
"-E \"SELECT rpath(evrxpentries.sname, evrxpentries.sroll) || '/' || evrxpentries.name, evrxpentries.type, evrxpentries.xattr_name, evrxpentries.xattr_value, ${FACTION1_VIEW}.data FROM evrxpentries LEFT JOIN ${FACTION1_VIEW} ON (evrxpentries.name == ${FACTION1_VIEW}.name) AND (evrxpentries.type == ${FACTION1_VIEW}.type);\"" \
220-
"\"${INDEXROOT}\""
220+
"\"${SEARCH}\""
221221

222222
echo "# get faction2 user data"
223223
echo "# SELECT rpath(), type, faction2 user data"
@@ -227,7 +227,7 @@ do_tests() {
227227
"-Q \"${FACTION2_DB}\" \"${TABLE}\" \"${FACTION2_TEMPLATE_ATTACH}.${TABLE}\" \"${FACTION2_VIEW}\"" \
228228
"-S \"SELECT rpath(evrsummary.sname, evrsummary.sroll), evrsummary.type, ${FACTION2_VIEW}.data FROM evrsummary LEFT JOIN ${FACTION2_VIEW} ON (evrsummary.name == ${FACTION2_VIEW}.name) AND (evrsummary.type == ${FACTION2_VIEW}.type);\"" \
229229
"-E \"SELECT rpath(evrpentries.sname, evrpentries.sroll) || '/' || evrpentries.name, evrpentries.type, ${FACTION2_VIEW}.data FROM evrpentries LEFT JOIN ${FACTION2_VIEW} ON (evrpentries.name == ${FACTION2_VIEW}.name) AND (evrpentries.type == ${FACTION2_VIEW}.type);\"" \
230-
"\"${INDEXROOT}\""
230+
"\"${SEARCH}\""
231231

232232
echo "# again, but with xattrs"
233233
echo "# SELECT rpath(), type, xattr_name, xattr_value, faction2 user data"
@@ -238,7 +238,7 @@ do_tests() {
238238
"-Q \"${FACTION2_DB}\" \"${TABLE}\" \"${FACTION2_TEMPLATE_ATTACH}.${TABLE}\" \"${FACTION2_VIEW}\"" \
239239
"-S \"SELECT rpath(evrxsummary.sname, evrxsummary.sroll), evrxsummary.type, evrxsummary.xattr_name, evrxsummary.xattr_value, ${FACTION2_VIEW}.data FROM evrxsummary LEFT JOIN ${FACTION2_VIEW} ON (evrxsummary.name == ${FACTION2_VIEW}.name) AND (evrxsummary.type == ${FACTION2_VIEW}.type);\"" \
240240
"-E \"SELECT rpath(evrxpentries.sname, evrxpentries.sroll) || '/' || evrxpentries.name, evrxpentries.type, evrxpentries.xattr_name, evrxpentries.xattr_value, ${FACTION2_VIEW}.data FROM evrxpentries LEFT JOIN ${FACTION2_VIEW} ON (evrxpentries.name == ${FACTION2_VIEW}.name) AND (evrxpentries.type == ${FACTION2_VIEW}.type);\"" \
241-
"\"${INDEXROOT}\""
241+
"\"${SEARCH}\""
242242

243243
echo "# get faction1 and faction2 user data at the same time"
244244
echo "# SELECT rpath(), type, faction1 user data, faction2 user data"
@@ -248,7 +248,7 @@ do_tests() {
248248
"-Q \"${FACTION1_DB}\" \"${TABLE}\" \"${FACTION1_TEMPLATE_ATTACH}.${TABLE}\" \"${FACTION1_VIEW}\" -Q \"${FACTION2_DB}\" \"${TABLE}\" \"${FACTION2_TEMPLATE_ATTACH}.${TABLE}\" \"${FACTION2_VIEW}\"" \
249249
"-S \"SELECT rpath(evrsummary.sname, evrsummary.sroll), evrsummary.type, ${FACTION1_VIEW}.data, ${FACTION2_VIEW}.data FROM evrsummary LEFT JOIN ${FACTION1_VIEW} ON (evrsummary.name == ${FACTION1_VIEW}.name) AND (evrsummary.type == ${FACTION1_VIEW}.type) LEFT JOIN ${FACTION2_VIEW} ON (evrsummary.name == ${FACTION2_VIEW}.name) AND (evrsummary.type == ${FACTION2_VIEW}.type);\"" \
250250
"-E \"SELECT rpath(evrpentries.sname, evrpentries.sroll) || '/' || evrpentries.name, evrpentries.type, ${FACTION1_VIEW}.data, ${FACTION2_VIEW}.data FROM evrpentries LEFT JOIN ${FACTION1_VIEW} ON (evrpentries.name == ${FACTION1_VIEW}.name) AND (evrpentries.type == ${FACTION1_VIEW}.type) LEFT JOIN ${FACTION2_VIEW} ON (evrpentries.name == ${FACTION2_VIEW}.name) AND (evrpentries.type == ${FACTION2_VIEW}.type);\"" \
251-
"\"${INDEXROOT}\""
251+
"\"${SEARCH}\""
252252

253253
echo "# again, but with xattrs"
254254
echo "# SELECT rpath(), type, xattr_name, xattr_value, faction1 user data, faction2 user data"
@@ -258,7 +258,7 @@ do_tests() {
258258
"-I \"ATTACH '${FACTION1_TEMPLATE_DB}' AS '${FACTION1_TEMPLATE_ATTACH}'; ATTACH '${FACTION2_TEMPLATE_DB}' AS '${FACTION2_TEMPLATE_ATTACH}';\" -Q \"${FACTION1_DB}\" \"${TABLE}\" \"${FACTION1_TEMPLATE_ATTACH}.${TABLE}\" \"${FACTION1_VIEW}\" -Q \"${FACTION2_DB}\" \"${TABLE}\" \"${FACTION2_TEMPLATE_ATTACH}.${TABLE}\" \"${FACTION2_VIEW}\"" \
259259
"-S \"SELECT rpath(evrxsummary.sname, evrxsummary.sroll), evrxsummary.type, evrxsummary.xattr_name, evrxsummary.xattr_value, ${FACTION1_VIEW}.data, ${FACTION2_VIEW}.data FROM evrxsummary LEFT JOIN ${FACTION1_VIEW} ON (evrxsummary.name == ${FACTION1_VIEW}.name) AND (evrxsummary.type == ${FACTION1_VIEW}.type) LEFT JOIN ${FACTION2_VIEW} ON (evrxsummary.name == ${FACTION2_VIEW}.name) AND (evrxsummary.type == ${FACTION2_VIEW}.type);\"" \
260260
"-E \"SELECT rpath(evrxpentries.sname, evrxpentries.sroll) || '/' || evrxpentries.name, evrxpentries.type, evrxpentries.xattr_name, evrxpentries.xattr_value, ${FACTION1_VIEW}.data, ${FACTION2_VIEW}.data FROM evrxpentries LEFT JOIN ${FACTION1_VIEW} ON (evrxpentries.name == ${FACTION1_VIEW}.name) AND (evrxpentries.type == ${FACTION1_VIEW}.type) LEFT JOIN ${FACTION2_VIEW} ON (evrxpentries.name == ${FACTION2_VIEW}.name) AND (evrxpentries.type == ${FACTION2_VIEW}.type);\"" \
261-
"\"${INDEXROOT}\""
261+
"\"${SEARCH}\""
262262
}
263263

264264
rollup() {

test/regression/split_trace.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ Error: Invalid thread count: |
3333
$ split_trace "badtrace" "|" "4" "split"
3434
Error: Line at offset 4 does not have a delimiter
3535

36+
# Bad thread count
37+
$ split_trace "badtrace" "|" "4" "split" 18446744073709551615
38+
Error: Failed to start thread pool with 18446744073709551615 threads
39+

test/regression/split_trace.sh.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ echo d
152152
echo "# Missing delimiter"
153153
run_no_sort "${SPLIT_TRACE} \"${BADTRACE}\" \"${DELIM}\" \"${SPLIT_COUNT}\" \"${SPLIT_PREFIX}\"" | replace
154154

155+
echo "# Bad thread count"
156+
run_no_sort "${SPLIT_TRACE} \"${BADTRACE}\" \"${DELIM}\" \"${SPLIT_COUNT}\" \"${SPLIT_PREFIX}\" 18446744073709551615" | replace
155157
) | remove_indexing_time | tee "${OUTPUT}"
156158

157159
@DIFF@ @CMAKE_CURRENT_BINARY_DIR@/split_trace.expected "${OUTPUT}"

test/regression/treediff.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ Error: Could not stat right directory "": No such file or directory (2)
4848
$ treediff -k "" "prefix" "prefix"
4949
Error: Cannot open skip file ""
5050

51+
# Bad thread count
52+
$ treediff -n 18446744073709551615 "prefix" "prefix"
53+
Error: Could not initialize 18446744073709551615 output buffers
54+

test/regression/treediff.sh.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ run_no_sort "${TREEDIFF} \"${SEARCH}\" \"\""
9595

9696
echo "# Bad skip"
9797
run_sort "${TREEDIFF} -k \"\" \"${SRCDIR}\" \"${INDEXROOT}\""
98+
99+
echo "# Bad thread count"
100+
run_sort "${TREEDIFF} -n 18446744073709551615 \"${SRCDIR}\" \"${INDEXROOT}\""
98101
) | remove_root | tee "${OUTPUT}"
99102

100103
@DIFF@ @CMAKE_CURRENT_BINARY_DIR@/treediff.expected "${OUTPUT}"

0 commit comments

Comments
 (0)