server(fd[0], p1, p2, expected);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1], cp1, "unknown/1.4", cp2);
server(fd);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
fd = socket(AF_INET, SOCK_STREAM, 0);
{
int status;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
{
int status;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
server(fd[0], server_initiated);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1], server_initiated);
server(fd[0], server_initiated);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1], server_initiated);
server_fd = fd[0];
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
server(fd[0], server_initiated);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1], server_initiated);
client(fd[1]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[1]);
server(fd[0]);
close(fd[1]);
server(fd[0], server_prio, expect_fail);
waitpid(child, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- }
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1], cli_prio, expect_fail);
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
{
int status, ret = 0;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status)) {
- fprintf(stderr, "Child died with sigsegv\n");
- ret = 1;
- } else {
- fprintf(stderr, "Child died with status %d\n",
- WEXITSTATUS(status));
- }
- terminate(ret);
- }
+ check_wait_status(status);
return;
}
server(fd[0], p1, p2);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1], "unknown/1.4", p2, p1);
int status = 0;
waitpid(-1, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- }
+ check_wait_status_for_sig(status);
return;
}
int status = 0;
waitpid(-1, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- }
+ check_wait_status(status);
return;
}
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
close(fd[1]);
client(fd[0], do_fork);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
server(fd[1], 1-do_fork);
server(fd[0], server_initiated);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1], server_initiated);
client(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Server died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
server(fd[1]);
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
{
int status;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
close(fd[0]);
server(fd[1]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[1]);
client(fd[0]);
close(fd[1]);
client(fd[0], do_thread);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
server(fd[1], 1-do_thread);
close(fd[1]);
client(fd[0], cache);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
server(fd[1], cache);
close(fd[1]);
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
server(fd[0], profile);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1], profile);
close(fd[1]);
server(fd[0], proto, cipher, mac);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
close(fd[0]);
} else {
close(fd[0]);
{
int status;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
{
int status = 0;
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n", WEXITSTATUS(status));
+ check_wait_status(status);
return;
}
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
{
int status = 0;
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n", WEXITSTATUS(status));
+ check_wait_status(status);
return;
}
int status = 0;
waitpid(-1, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
{
int status;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
{
int status;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
{
int status;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
{
int status = 0;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
{
int status;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
{
int status;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
int status = 0;
waitpid(-1, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
int status = 0;
waitpid(-1, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
{
int status = 0;
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n", WEXITSTATUS(status));
+ check_wait_status(status);
return;
}
if (done != child)
fail("who's that?! %d\n", done);
- if (WIFEXITED(status)) {
- if (WEXITSTATUS(status) != 0)
- fail("child exited with status %d\n", WEXITSTATUS(status));
- } else if (WIFSIGNALED(status))
- fail("child stopped by signal %d\n",
- WTERMSIG(status));
- else
- fail("child failed: %d\n", status);
+ check_wait_status(status);
}
}
if (done != child)
fail("who's that?! %d\n", done);
- if (WIFEXITED(status)) {
- if (WEXITSTATUS(status) != 0)
- fail("child exited with status %d\n",
- WEXITSTATUS(status));
- } else if (WIFSIGNALED(status))
- fail("child stopped by signal %d\n",
- WTERMSIG(status));
- else
- fail("child failed: %d\n", status);
+ check_wait_status(status);
}
gnutls_global_deinit();
/* parent */
client(sockets[0]);
wait(&status);
-
-#if defined WIFEXITED && defined WEXITSTATUS
- if (WIFEXITED(status) && WEXITSTATUS(status)) {
- fail("server: client failed with exit status %d\n",
- WEXITSTATUS(status));
- }
-#endif
-
-#if defined WIFSIGNALED && defined WTERMSIG
- if (WIFSIGNALED(status)) {
- fail("server: client failed with fatal signal %d\n", WTERMSIG(status));
- }
-#endif
-
+ check_wait_status(status);
} else
server(sockets[1]);
}
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
close(client_sds[j]);
server(server_sds, &resume_tests[i]);
wait(&status);
- if (WEXITSTATUS(status) != 0 || (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
- exit(1);
+ check_wait_status(status);
} else {
for (j = 0; j < SESSIONS; j++)
close(server_sds[j]);
server(server_sds, &resume_tests[i]);
waitpid(child, &status, 0);
- if (WEXITSTATUS(status) != 0 || (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV))
- exit(1);
+ check_wait_status(status);
global_stop();
} else {
for (j = 0; j < SESSIONS; j++)
{
int status;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
/* parent */
server(fd[0], prio);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
client(fd[1], prio);
exit(0);
close(fd[1]);
client(fd[0]);
waitpid(child, &status, 0);
-
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- }
+ check_wait_status(status);
} else {
close(fd[0]);
server(fd[1]);
close(fd[1]);
client(fd[0]);
waitpid(child, &status, 0);
-
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- }
+ check_wait_status(status);
} else {
close(fd[0]);
server(fd[1]);
close(fd[1]);
client(fd[0]);
waitpid(child, &status, 0);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- }
+ check_wait_status(status);
} else {
close(fd[0]);
server(fd[1]);
server(fd[0]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[0]);
client(fd[1]);
{
int status = 0;
wait(&status);
- if (WEXITSTATUS(status) != 0 ||
- (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)) {
- if (WIFSIGNALED(status))
- fail("Child died with sigsegv\n");
- else
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
- terminate();
- }
+ check_wait_status(status);
return;
}
client(fd[1]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
} else {
close(fd[1]);
server(fd[0]);
server(fd[1]);
wait(&status);
- if (WEXITSTATUS(status) != 0)
- fail("Child died with status %d\n",
- WEXITSTATUS(status));
+ check_wait_status(status);
close(fd[1]);
} else {
close(fd[1]);
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]);
/* 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 */
close(sockets[1]);
server(sockets[0]);
wait(&status);
-
-#if defined WIFEXITED && defined WEXITSTATUS
- if (WIFEXITED(status) && WEXITSTATUS(status)) {
- fail("server: client failed with exit status %d\n",
- WEXITSTATUS(status));
- }
-#endif
-
-#if defined WIFSIGNALED && defined WTERMSIG
- if (WIFSIGNALED(status)) {
- fail("server: client failed with fatal signal %d\n", WTERMSIG(status));
- }
-#endif
-
+ check_wait_status(status);
} else {
close(sockets[0]);
client(sockets[1]);