summaryrefslogtreecommitdiffstats
path: root/jq_test.c
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2013-05-08 00:52:24 +0100
committerStephen Dolan <mu@netsoc.tcd.ie>2013-05-08 00:52:24 +0100
commit2363246eeaa700924279ba288a18b518d570b9ca (patch)
treee823504a8991a1cfce4326c0c6b906d7f87058ef /jq_test.c
parent65deaaacf507c9e1d01773887d8c56be847ff1bd (diff)
parentdc4d3d8cbee6659ac444cb4696edd9bd8157f6eb (diff)
Merge remote-tracking branch 'stagrlee/master' into autotools
Conflicts: Makefile jq_test.c
Diffstat (limited to 'jq_test.c')
-rw-r--r--jq_test.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/jq_test.c b/jq_test.c
index 64b88fb6..39f2664f 100644
--- a/jq_test.c
+++ b/jq_test.c
@@ -8,12 +8,23 @@
static void jv_test();
static void run_jq_tests();
-FILE* testdata;
int jq_testsuite(int argc, char* argv[]) {
+ FILE* testdata;
jv_test();
if (argc == 1) {
testdata = fopen("testdata", "r");
+ if ( NULL == testdata )
+ {
+ /* in an autoconf distcheck, the binary file will be in a _build subdirectory */
+ testdata = fopen("../testdata", "r");
+ if ( NULL == testdata )
+ {
+ fprintf(stderr, "Could not find testdata file\n");
+ exit(1);
+ }
+ }
+
} else if (argc == 2) {
if (!strcmp(argv[1], "-")) {
testdata = stdin;
@@ -24,7 +35,7 @@ int jq_testsuite(int argc, char* argv[]) {
printf("usage: %s OR cat testdata | %s - OR %s testdata\n", argv[0], argv[0], argv[0]);
return 127;
}
- run_jq_tests();
+ run_jq_tests(testdata);
if (testdata != stdin) fclose(testdata);
return 0;
}
@@ -39,7 +50,7 @@ static int skipline(const char* buf) {
return 0;
}
-static void run_jq_tests() {
+static void run_jq_tests(FILE *testdata) {
char buf[4096];
int tests = 0, passed = 0, invalid = 0;
jq_state *jq = NULL;