make repository_test pass again on OpenBSD 6.5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
diff --git a/regress/repository/repository_test.c b/regress/repository/repository_test.c
index e520aaf..b6001e3 100644
--- a/regress/repository/repository_test.c
+++ b/regress/repository/repository_test.c
@@ -17,6 +17,7 @@
#include <sys/stat.h>
#include <sys/queue.h>
+#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <util.h>
@@ -447,7 +448,7 @@ int
main(int argc, char *argv[])
{
int test_ok = 0, failure = 0;
- const char *repo_path;
+ char *repo_path;
int ch;
const struct got_error *error;
@@ -470,18 +471,26 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (argc == 0)
- repo_path = GOT_REPO_PATH;
- else if (argc == 1)
- repo_path = argv[0];
- else {
+ switch (argc) {
+ case 0:
+ repo_path = realpath(GOT_REPO_PATH, NULL);
+ break;
+ case 1:
+ repo_path = realpath(argv[0], NULL);
+ break;
+ default:
usage();
return 1;
}
+ if (repo_path == NULL) {
+ fprintf(stderr, "realpath: %s\n", strerror(errno));
+ return 1;
+ }
error = apply_unveil(repo_path);
if (error) {
- fprintf(stderr, "unveil: %s", error->msg);
+ fprintf(stderr, "unveil: %s\n", error->msg);
+ free(repo_path);
return 1;
}
@@ -491,5 +500,6 @@ main(int argc, char *argv[])
RUN_TEST(repo_diff_blob(repo_path), "diff_blob");
RUN_TEST(repo_diff_tree(repo_path), "diff_tree");
+ free(repo_path);
return failure ? 1 : 0;
}