summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martin@piware.de>2017-02-14 08:58:19 +0100
committerMartin Pitt <martin@piware.de>2017-02-16 21:36:30 +0100
commit31f8b331c77160019bb282c8b722ace5c9c290d4 (patch)
tree08ec8bcb16b089b3b2a9618461f7159020b2754c
parent916b5002861473879088dfa3bb6dfaac9cfdcc68 (diff)
test: clarify error message if test data directory does not exist
When trying to directly run a test executable in the build tree without setting $TEST_DIR, some tests fail with a non-obvious error message. Print an useful one instead.
-rw-r--r--src/shared/tests.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/shared/tests.c b/src/shared/tests.c
index 7034687725..189aa36bc6 100644
--- a/src/shared/tests.c
+++ b/src/shared/tests.c
@@ -42,5 +42,9 @@ const char* get_exe_relative_testdata_dir(void) {
assert_se(readlink_and_make_absolute("/proc/self/exe", &exedir) >= 0);
assert_se(snprintf(testdir, sizeof(testdir), "%s/testdata", dirname(exedir)) > 0);
+ if (access(testdir, F_OK) < 0) {
+ fprintf(stderr, "Test data directory '%s' does not exist, set $TEST_DIR\n", testdir);
+ exit(1);
+ }
return testdir;
}