diff options
author | José Bollo <jose.bollo@iot.bzh> | 2019-11-07 11:00:55 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2019-11-07 11:00:55 +0100 |
commit | 6c88efcb7b1361ba6389753e520e26fc556b7d79 (patch) | |
tree | f1b206345fb43c5b92ec25640d41f64c8530c9a0 | |
parent | 195d93caaec446b2cbca2059b41803498a0b30c9 (diff) |
Improve exit status of cynagora-adminicefish_8.99.2icefish_8.99.1icefish/8.99.2icefish/8.99.18.99.28.99.1
When used command line, the tool cynagora-admin
was terminating with status 0 even when the server
wasn't up and running.
This changes corrctly fix the issue by recording
the status of the last cynagora command and by
treating with it in command line mode.
This change is required to implement a basic ptest
and to submit cynagora for Itchy Icefish.
Bug-AGL: 2844
Also fix a naming in the cache stressing test.
Change-Id: I39ee784bbe8ce7b792e96ef14578baa6f80ef6ac
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r-- | src/main-cynagora-admin.c | 29 | ||||
-rwxr-xr-x | tests/stress-cache.sh | 2 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/main-cynagora-admin.c b/src/main-cynagora-admin.c index aea022a..c6a9535 100644 --- a/src/main-cynagora-admin.c +++ b/src/main-cynagora-admin.c @@ -308,6 +308,7 @@ static char *str[40]; static int nstr; static int pending; static int echo; +static int last_status; cynagora_key_t key; cynagora_value_t value; @@ -457,7 +458,7 @@ int do_list(int ac, char **av) rc = get_csup(ac, av, &uc, "#"); if (rc == 0) { memset(&lr, 0, sizeof lr); - rc = cynagora_get(cynagora, &key, listcb, &lr); + last_status = rc = cynagora_get(cynagora, &key, listcb, &lr); if (rc < 0) fprintf(stderr, "error %s\n", strerror(-rc)); else { @@ -492,9 +493,9 @@ int do_set(int ac, char **av) rc = get_csupve(ac, av, &uc, "*"); if (rc == 0) - rc = cynagora_enter(cynagora); + last_status = rc = cynagora_enter(cynagora); if (rc == 0) { - rc = cynagora_set(cynagora, &key, &value); + last_status = rc = cynagora_set(cynagora, &key, &value); cynagora_leave(cynagora, !rc); } if (rc < 0) @@ -508,9 +509,9 @@ int do_drop(int ac, char **av) rc = get_csup(ac, av, &uc, "#"); if (rc == 0) - rc = cynagora_enter(cynagora); + last_status = rc = cynagora_enter(cynagora); if (rc == 0) { - rc = cynagora_drop(cynagora, &key); + last_status = rc = cynagora_drop(cynagora, &key); cynagora_leave(cynagora, !rc); } if (rc < 0) @@ -524,7 +525,7 @@ int do_scheck(int ac, char **av, int (*f)(cynagora_t*,const cynagora_key_t*,int) rc = get_csup(ac, av, &uc, NULL); if (rc == 0) { - rc = f(cynagora, &key, 0); + last_status = rc = f(cynagora, &key, 0); if (rc > 0) fprintf(stdout, "allowed\n"); else if (rc == 0) @@ -543,7 +544,7 @@ int do_cache_check(int ac, char **av) rc = get_csup(ac, av, &uc, NULL); if (rc == 0) { - rc = cynagora_cache_check(cynagora, &key); + last_status = rc = cynagora_cache_check(cynagora, &key); if (rc > 0) fprintf(stdout, "allowed\n"); else if (rc == 0) @@ -574,7 +575,7 @@ int do_check(int ac, char **av, bool simple) rc = get_csup(ac, av, &uc, NULL); if (rc == 0) { pending++; - rc = cynagora_async_check(cynagora, &key, 0, simple, check_cb, NULL); + last_status = rc = cynagora_async_check(cynagora, &key, 0, simple, check_cb, NULL); if (rc < 0) { fprintf(stderr, "error %s\n", strerror(-rc)); pending--; @@ -597,7 +598,7 @@ int do_log(int ac, char **av) return uc; } } - rc = cynagora_log(cynagora, on, off); + last_status = rc = cynagora_log(cynagora, on, off); if (rc < 0) fprintf(stderr, "error %s\n", strerror(-rc)); else @@ -687,7 +688,7 @@ int do_any(int ac, char **av) return 0; } -void do_all(int ac, char **av) +void do_all(int ac, char **av, int quit) { int rc; @@ -697,12 +698,14 @@ void do_all(int ac, char **av) fprintf(stdout, "\n"); } while(ac) { + last_status = 0; rc = do_any(ac, av); - if (rc <= 0) + if (quit && (rc <= 0 || last_status < 0)) exit(1); ac -= rc; av += rc; } + } int async_ctl(void *closure, int op, int fd, uint32_t events) @@ -798,7 +801,7 @@ int main(int ac, char **av) } if (optind < ac) { - do_all(ac - optind, av + optind); + do_all(ac - optind, av + optind, 1); return 0; } @@ -820,7 +823,7 @@ int main(int ac, char **av) str[nstr = 0] = strtok(buffer, " \t"); while(str[nstr]) str[++nstr] = strtok(NULL, " \t"); - do_all(nstr, str); + do_all(nstr, str, 0); bufill -= (size_t)(p - buffer); if (!bufill) break; diff --git a/tests/stress-cache.sh b/tests/stress-cache.sh index c2b022c..9933606 100755 --- a/tests/stress-cache.sh +++ b/tests/stress-cache.sh @@ -23,7 +23,7 @@ for((y = 0 ; y < 10 ; y++)); do sleep .05 done done | -valgrind cynagoradm -c 2000 -e -s $d/cynagora.check +valgrind cynagora-admin -c 2000 -e -s $d/cynagora.check echo ----------- STOP ------------------ # terminate |