* [PATCH] test-skeleton.c: Add write_message function
@ 2016-06-22 10:37 Florian Weimer
2016-06-22 10:48 ` Mike Frysinger
0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2016-06-22 10:37 UTC (permalink / raw)
To: libc-alpha
2016-06-22 Florian Weimer <fweimer@redhat.com>
* test-skeleton.c (write_message): New function.
* malloc/tst-mallocfork2.c (write_message): Remove.
* debug/tst-longjmp_chk2.c (write_indented): New function.
(write_message): Remove.
(stackoverflow_handler): Call write_indented.
diff --git a/debug/tst-longjmp_chk2.c b/debug/tst-longjmp_chk2.c
index 243568c..23d3436 100644
--- a/debug/tst-longjmp_chk2.c
+++ b/debug/tst-longjmp_chk2.c
@@ -12,18 +12,20 @@
#include <sys/resource.h>
#include <unistd.h>
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
static jmp_buf mainloop;
static sigset_t mainsigset;
static volatile sig_atomic_t pass;
static void
-write_message (const char *message)
+write_indented (const char *str)
{
- ssize_t unused __attribute__ ((unused));
for (int i = 0; i < pass; ++i)
- unused = write (STDOUT_FILENO, " ", 1);
- unused = write (STDOUT_FILENO, message, strlen (message));
+ write_message (" ");
+ write_message (str);
}
static void
@@ -33,11 +35,10 @@ stackoverflow_handler (int sig)
/* Sanity check to keep test from looping forever (in case the longjmp
chk code is slightly broken). */
pass++;
- assert (pass < 5);
sigaltstack (NULL, &altstack);
- write_message ("in signal handler\n");
+ write_indented ("in signal handler\n");
if (altstack.ss_flags & SS_ONSTACK)
- write_message ("on alternate stack\n");
+ write_indented ("on alternate stack\n");
siglongjmp (mainloop, pass);
}
@@ -127,6 +128,3 @@ do_test (void)
return 0;
}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
diff --git a/malloc/tst-mallocfork2.c b/malloc/tst-mallocfork2.c
index 4939938..109c1b9 100644
--- a/malloc/tst-mallocfork2.c
+++ b/malloc/tst-mallocfork2.c
@@ -44,6 +44,9 @@ enum { malloc_maximum_size = 70000 };
/* How many signals need to be delivered before the test exits. */
enum { signal_count = 1000 };
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
/* Process ID of the subprocess which sends SIGUSR1 signals. */
static pid_t sigusr1_sender_pid;
@@ -56,14 +59,6 @@ static volatile sig_atomic_t sigusr1_received;
progress. Checked by liveness_signal_handler. */
static volatile sig_atomic_t progress_indicator = 1;
-/* Write the message to standard output. Usable from signal
- handlers. */
-static void
-write_message (const char *str)
-{
- write (STDOUT_FILENO, str, strlen (str));
-}
-
static void
sigusr1_handler (int signo)
{
@@ -213,6 +208,3 @@ do_test (void)
return 0;
}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
diff --git a/test-skeleton.c b/test-skeleton.c
index a9ad4ab..49808b3 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -115,6 +115,16 @@ xrealloc (void *p, size_t n)
return p;
}
+/* Write a message to standard output. Can be used in signal
+ handlers. */
+static void
+__attribute__ ((unused))
+write_message (const char *message)
+{
+ ssize_t unused __attribute__ ((unused));
+ unused = write (STDOUT_FILENO, message, strlen (message));
+}
+
/* List of temporary files. */
struct temp_name_list
{
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] test-skeleton.c: Add write_message function
2016-06-22 10:37 [PATCH] test-skeleton.c: Add write_message function Florian Weimer
@ 2016-06-22 10:48 ` Mike Frysinger
0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2016-06-22 10:48 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
[-- Attachment #1: Type: text/plain, Size: 9 bytes --]
OK
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-22 10:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-22 10:37 [PATCH] test-skeleton.c: Add write_message function Florian Weimer
2016-06-22 10:48 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).