summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2018-09-26 18:00:57 -0700
committerGary E. Miller <gem@rellim.com>2018-09-26 18:00:57 -0700
commit7148916f777dc62db5d685666e7159fa115faa06 (patch)
tree04c89a359ba1667ee8bc73c6d3f4ba5f2f8b7981
parentf48d44dac4ef03956f899fa56980d80dd1d44deb (diff)
downloadgpsd-7148916f777dc62db5d685666e7159fa115faa06.tar.gz
test_json: add -V option.
-rw-r--r--test_json.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/test_json.c b/test_json.c
index 8aeda308..1eb645c8 100644
--- a/test_json.c
+++ b/test_json.c
@@ -13,6 +13,7 @@
#include "gpsd.h"
#include "gps_json.h"
+#include "revision.h"
/* GPSD is built with JSON_MINIMAL. Any !JSON_MINIMAL tests,
* like 18, 19 and 20 will thus fail.
@@ -559,7 +560,7 @@ int main(int argc UNUSED, char *argv[]UNUSED)
int option;
int individual = 0;
- while ((option = getopt(argc, argv, "hn:D:?")) != -1) {
+ while ((option = getopt(argc, argv, "D:hn:V?")) != -1) {
switch (option) {
#ifdef CLIENTDEBUG_ENABLE
case 'D':
@@ -573,11 +574,17 @@ int main(int argc UNUSED, char *argv[]UNUSED)
case '?':
case 'h':
default:
- (void)fputs("usage: test_json [-D lvl] [-n tst]\n"
+ (void)fprintf(stderr,
+ "usage: %s [-D lvl] [-n tst] [-V]\n"
" -D lvl set debug level\n"
- " -n tst run only test tst\n",
- stderr);
+ " -n tst run only test tst\n"
+ " -V Print version and exit\n",
+ argv[0]);
exit(EXIT_FAILURE);
+ case 'V':
+ (void)fprintf(stderr, "%s: %s (revision %s)\n",
+ argv[0], VERSION, REVISION);
+ exit(EXIT_SUCCESS);
}
}