summaryrefslogtreecommitdiff
path: root/tests/utils.h
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-08-08 11:49:04 +0200
committerGitLab <gitlab@gitlab.com>2016-08-09 06:01:35 +0000
commit2124f87dcd1acee4e2e04702469e16bc8da03edb (patch)
tree7d4c2910ca9a20d216d97c32328ece060f8340a8 /tests/utils.h
parentbcbf2dd69715c5fba7c760406f644a27d5dbcc64 (diff)
downloadgnutls-2124f87dcd1acee4e2e04702469e16bc8da03edb.tar.gz
tests: moved child status error checking code in utils.h
Diffstat (limited to 'tests/utils.h')
-rw-r--r--tests/utils.h36
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 */