@@ -33,13 +33,11 @@
#include "posixtest.h"
#include "tempfile.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static void sigbus_handler(int signum)
{
if (signum == SIGBUS) {
- WRITE("SIGBUS triggered\n");
- WRITE("Test PASSED\n");
+ PTS_WRITE_MSG("SIGBUS triggered\n");
+ PTS_WRITE_MSG("Test PASSED\n");
_exit(PTS_PASS);
}
}
@@ -31,13 +31,11 @@
#include <unistd.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static void sigbus_handler(int signum)
{
if (signum == SIGBUS) {
- WRITE("SIGBUS triggered\n");
- WRITE("Test PASSED\n");
+ PTS_WRITE_MSG("SIGBUS triggered\n");
+ PTS_WRITE_MSG("Test PASSED\n");
_exit(PTS_PASS);
}
}
@@ -10,8 +10,8 @@
*
* Steps:
* 1. Create a new thread that will go into a never-ending while loop.
- * 2. If the thread is truly asynchronise, then the main function will
- * continue instead of waiting for the thread to return (which in never
+ * 2. If the thread is truly asynchronous, then the main function will
+ * continue instead of waiting for the thread to return (which it never
* does in this test case).
* 3. An alarm is set to go off (i.e. send the SIGARLM signal) after 3
* seconds. This is done for 'timeing-out' reasons, in case main DOES
@@ -72,11 +72,9 @@ static void *a_thread_function()
return NULL;
}
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
/* If this handler is called, that means that the test has failed. */
static void alarm_handler()
{
- WRITE("Test FAILED: Alarm fired while waiting for cancelation\n");
+ PTS_WRITE_MSG("Test FAILED: Alarm fired while waiting for cancelation\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGABRT) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGPIPE) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGQUIT) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGSEGV) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGTERM) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGTSTP) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGTTIN) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGTTOU) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGUSR1) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGUSR2) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGPOLL) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,13 +48,14 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGALRM) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
called = 1;
}
+
int main(void)
{
int ret;
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGPROF) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGSYS) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGTRAP) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGURG) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGVTALRM) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGXCPU) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGXFSZ) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGBUS) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGCHLD) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGCONT) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGFPE) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGHUP) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGILL) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -40,8 +40,6 @@
#include <errno.h>
#include "posixtest.h"
-#define WRITE(str) write(STDOUT_FILENO, str, sizeof(str) - 1)
-
static volatile sig_atomic_t called = 0;
static void handler(int sig, siginfo_t *info, void *context)
@@ -50,7 +48,7 @@ static void handler(int sig, siginfo_t *info, void *context)
(void) context;
if (info->si_signo != SIGINT) {
- WRITE("Wrong signal generated?\n");
+ PTS_WRITE_MSG("Wrong signal generated?\n");
_exit(PTS_FAIL);
}
@@ -23,3 +23,9 @@
#define PTS_ATTRIBUTE_NORETURN __attribute__((noreturn))
#define PTS_ATTRIBUTE_UNUSED __attribute__((unused))
#define PTS_ATTRIBUTE_UNUSED_RESULT __attribute__((warn_unused_result))
+
+#define PTS_WRITE_MSG(msg) do { \
+ if (write(STDOUT_FILENO, msg, sizeof(msg) - 1)) { \
+ /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 */ \
+ } \
+} while (0)