diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-08-08 11:49:04 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-08-08 12:16:58 +0200 |
commit | 5a86a16bdd14b6a4091671c4bfebc2e593cf1573 (patch) | |
tree | 3107c17ca7628a02e9d2b81964fc38fa9ae28469 /tests/utils.h | |
parent | a30a5359f9dd55e31d97925dfcf45f12ecaae37c (diff) | |
download | gnutls-tests-error-checking.tar.gz |
tests: moved child status error checking code in utils.htests-error-checking
Diffstat (limited to 'tests/utils.h')
-rw-r--r-- | tests/utils.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/tests/utils.h b/tests/utils.h index fbd6b7a160..7606a6dbb8 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -72,11 +72,10 @@ void sec_sleep(int sec); typedef void callback_func(gnutls_session_t, void *priv); void test_cli_serv(gnutls_certificate_credentials_t server_cred, - gnutls_certificate_credentials_t client_cred, - const char *prio, const char *host, - void *priv, - callback_func *client_cb, - callback_func *server_cb); + gnutls_certificate_credentials_t client_cred, + const char *prio, const char *host, + void *priv, + callback_func * client_cb, callback_func * server_cb); #define TMPNAME_SIZE 128 char *get_tmpname(char s[TMPNAME_SIZE]); @@ -84,4 +83,31 @@ char *get_tmpname(char s[TMPNAME_SIZE]); /* This must be implemented elsewhere. */ extern void doit(void); +/* calls fail() if status indicates an error */ +inline static void _check_wait_status(int status, unsigned sigonly) +{ +#if defined WEXITSTATUS && defined WIFSIGNALED + if (WEXITSTATUS(status) != 0 || + (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) { + if (WIFSIGNALED(status)) { + fail("Child died with signal %d\n", WTERMSIG(status)); + } else { + if (!sigonly) + fail("Child died with status %d\n", + WEXITSTATUS(status)); + } + } +#endif +} + +inline static void check_wait_status(int status) +{ + _check_wait_status(status, 0); +} + +inline static void check_wait_status_for_sig(int status) +{ + _check_wait_status(status, 1); +} + #endif /* UTILS_H */ |