From: Daniel P. Berrange Date: Fri, 10 Jun 2016 12:41:22 +0000 (+0100) Subject: tests: test trailing comma in system priorities X-Git-Tag: gnutls_3_5_1~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f7ddfe6db98930783850171e4dccaf672e6366a;p=thirdparty%2Fgnutls.git tests: test trailing comma in system priorities Add tests which verify behaviour when the list of system priorities has a trailing ','. Avoid crash in test suite if the test unexpectedly succeeds when expected_str is NULL. Signed-off-by: Daniel P. Berrange --- diff --git a/tests/system-prio-file.c b/tests/system-prio-file.c index 59c960de11..e0dfa9460c 100644 --- a/tests/system-prio-file.c +++ b/tests/system-prio-file.c @@ -51,7 +51,7 @@ try_prio(const char *prio, const char *expected_str) if (p == NULL && expected_str == NULL) goto ok; - if (p == NULL || strcmp(p, expected_str) != 0) { + if (p == NULL || expected_str == NULL || strcmp(p, expected_str) != 0) { fail("test: %s: error; got: %s, expected: %s\n", prio, p, expected_str); exit(1); } @@ -72,6 +72,7 @@ void doit(void) try_prio("@HELLO1,HELLO2", "NORMAL"); try_prio("@HELLO1,HELLO2:+AES-128-CBC", "NORMAL:+AES-128-CBC"); try_prio("@HELLO1,HELLO1", "NORMAL"); + try_prio("@HELLO1,", "NORMAL"); try_prio("@HELLO2,HELLO1", "NORMAL:+AES-128-CBC"); try_prio("@HELLO2,HELLO1,@HELLONO", "NORMAL:+AES-128-CBC"); try_prio("@HELLO2,HELLO1,@HELLO3", "NORMAL:+AES-128-CBC"); @@ -79,5 +80,8 @@ void doit(void) try_prio("@HELLONO,HELLONO2,HELLO1", "NORMAL"); try_prio("@HELLONO,HELLONO2,HELLO1:+AES-128-CBC", "NORMAL:+AES-128-CBC"); try_prio("@HELLONO", NULL); + try_prio("@HELLONO,", NULL); + try_prio("@HELLONO:+AES-128-CBC", NULL); + try_prio("@HELLONO,:+AES-128-CBC", NULL); }