summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-09-15 18:09:07 +0200
committerDavid Robillard <d@drobilla.net>2018-09-15 18:09:07 +0200
commite78eb603691b7546848e8b0fb36444292fd1550d (patch)
tree56f188d890867db23cd3fcaad1efde3c4b8c870d
parent38b19c37bfbba19bde0dda6c93b2232f1706632e (diff)
downloadlilv-e78eb603691b7546848e8b0fb36444292fd1550d.tar.gz
lilv-e78eb603691b7546848e8b0fb36444292fd1550d.tar.bz2
lilv-e78eb603691b7546848e8b0fb36444292fd1550d.zip
Improve test suite error reporting
-rw-r--r--test/lilv_test.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/test/lilv_test.c b/test/lilv_test.c
index 117c428..b55f3e9 100644
--- a/test/lilv_test.c
+++ b/test/lilv_test.c
@@ -94,12 +94,13 @@ init_tests(void)
}
static void
-fatal_error(const char* err, const char* arg)
+fatal_error(const char* fmt, ...)
{
- /* TODO: possibly change to vfprintf later */
- fprintf(stderr, err, arg);
- /* IMHO, the bundle should be left in place after an error, for possible investigation */
- /* delete_bundle(); */
+ va_list args;
+ va_start(args, fmt);
+ fprintf(stderr, "error: ");
+ vfprintf(stderr, fmt, args);
+ va_end(args);
exit(1);
}
@@ -109,7 +110,8 @@ write_file(const char* name, const char* content)
FILE* f = fopen(name, "w");
size_t len = strlen(content);
if (fwrite(content, 1, len, f) != len) {
- fatal_error("Cannot write file %s\n", name);
+ fatal_error("Failed to write to file '%s' (%s)\n",
+ name, strerror(errno));
}
fclose(f);
}
@@ -135,7 +137,8 @@ static void
create_bundle(const char* manifest, const char* content)
{
if (mkdir(bundle_dir_name, 0700) && errno != EEXIST) {
- fatal_error("Cannot create directory %s\n", bundle_dir_name);
+ fatal_error("Failed to create directory '%s' (%s)\n",
+ bundle_dir_name, strerror(errno));
}
write_file(manifest_name, manifest);
write_file(content_name, content);