1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00
Move inclusion of test-skeleton to front to have prototype for
	add_temp_file.
This commit is contained in:
Andreas Jaeger
2000-08-24 09:30:58 +00:00
parent 991dca9005
commit 3b526f89b5
5 changed files with 30 additions and 17 deletions

View File

@ -4,6 +4,8 @@
(generated): Added memusage and memusagestat for make clean. (generated): Added memusage and memusagestat for make clean.
* libio/tst_putwc.c (do_test): Delete temporary file. * libio/tst_putwc.c (do_test): Delete temporary file.
Move inclusion of test-skeleton to front to have prototype for
add_temp_file.
* posix/Makefile (generated): Add wordexp-tst.out. * posix/Makefile (generated): Add wordexp-tst.out.

View File

@ -26,8 +26,13 @@
static const char outname[] = OBJPFX "tst_putwc.temp"; static const char outname[] = OBJPFX "tst_putwc.temp";
/* Prototype for our test function. */
int do_test (void);
#define TEST_FUNCTION do_test () #define TEST_FUNCTION do_test ()
/* This defines the `main' function and some more. */
#include <test-skeleton.c>
int int
do_test (void) do_test (void)
{ {
@ -37,6 +42,8 @@ do_test (void)
FILE *fp; FILE *fp;
int res = 0; int res = 0;
add_temp_file (outname);
fp = fopen (outname, "w+"); fp = fopen (outname, "w+");
if (fp == NULL) if (fp == NULL)
error (EXIT_FAILURE, errno, "cannot open temporary file"); error (EXIT_FAILURE, errno, "cannot open temporary file");
@ -113,6 +120,3 @@ do_test (void)
return res; return res;
} }
#include "../test-skeleton.c"

View File

@ -18,12 +18,11 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#define _GNU_SOURCE 1
#include <unistd.h>
#include <stdio.h>
#include <errno.h> #include <errno.h>
#include <pthread.h> #include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
struct thr_ctrl struct thr_ctrl
{ {
@ -47,11 +46,14 @@ void
pthr_cond_signal_mutex (pthread_cond_t * cond, pthread_mutex_t * mut) pthr_cond_signal_mutex (pthread_cond_t * cond, pthread_mutex_t * mut)
{ {
int err; int err;
if (err = pthread_mutex_lock (mut)) err = pthread_mutex_lock (mut);
if (err)
printf ("mutex_lock : %s\n", strerror (err)); printf ("mutex_lock : %s\n", strerror (err));
if (err = pthread_cond_signal (cond)) err = pthread_cond_signal (cond);
if (err)
printf ("cond_signal : %s\n", strerror (err)); printf ("cond_signal : %s\n", strerror (err));
if (err = pthread_mutex_unlock (mut)) err = pthread_mutex_unlock (mut);
if (err)
printf ("mutex_unlock: %s\n", strerror (err)); printf ("mutex_unlock: %s\n", strerror (err));
} }
@ -60,7 +62,6 @@ void *
thread_start (void *ptr) thread_start (void *ptr)
{ {
struct thr_ctrl *tc = ptr; struct thr_ctrl *tc = ptr;
int err;
/* Do initialization. */ /* Do initialization. */
/* ... */ /* ... */
/* Signal that we are ready. */ /* Signal that we are ready. */
@ -82,21 +83,23 @@ main (void)
pthread_mutexattr_init (&mutattr); pthread_mutexattr_init (&mutattr);
pthread_mutex_init (&threadctrl.mutex, &mutattr); pthread_mutex_init (&threadctrl.mutex, &mutattr);
pthread_cond_init (&threadctrl.cond, NULL); pthread_cond_init (&threadctrl.cond, NULL);
if (err = pthread_mutex_lock (&threadctrl.mutex)) err = pthread_mutex_lock (&threadctrl.mutex);
if (err)
printf ("mutex_lock : %s\n", strerror (err)); printf ("mutex_lock : %s\n", strerror (err));
dump_mut (&threadctrl.mutex); dump_mut (&threadctrl.mutex);
pthread_create (&thread, NULL, thread_start, &threadctrl); pthread_create (&thread, NULL, thread_start, &threadctrl);
/* Wait until it's ready. */ /* Wait until it's ready. */
if (err = pthread_cond_wait (&threadctrl.cond, &threadctrl.mutex)) err = pthread_cond_wait (&threadctrl.cond, &threadctrl.mutex);
if (err)
printf ("cond_wait : %s\n", strerror (err)); printf ("cond_wait : %s\n", strerror (err));
/* Now, we should have acquired the mutex again! */ /* Now, we should have acquired the mutex again! */
dump_mut (&threadctrl.mutex); dump_mut (&threadctrl.mutex);
sleep (1); sleep (1);
dump_mut (&threadctrl.mutex); dump_mut (&threadctrl.mutex);
if (err = pthread_cond_wait (&threadctrl.cond, &threadctrl.mutex)) err = pthread_cond_wait (&threadctrl.cond, &threadctrl.mutex);
printf ("cond_wait : %s\n", strerror (err));
if (err) if (err)
{ {
printf ("cond_wait : %s\n", strerror (err));
printf ("ERROR\n"); printf ("ERROR\n");
abort (); abort ();
}; };

View File

@ -1,3 +1,7 @@
2000-08-24 Andreas Jaeger <aj@suse.de>
* Makefile (generated): Add some .out files.
2000-08-23 Ulrich Drepper <drepper@redhat.com> 2000-08-23 Ulrich Drepper <drepper@redhat.com>
* locales/i18n: Add transliteration information. * locales/i18n: Add transliteration information.

View File

@ -81,7 +81,7 @@ before-compile := testcases.h ptestcases.h
# So they get cleaned up. # So they get cleaned up.
generated := $(addprefix wordexp-test-result, 1 2 3 4 5 6 7 8 9 10) \ generated := $(addprefix wordexp-test-result, 1 2 3 4 5 6 7 8 9 10) \
annexc annexc.out annexc annexc.out wordexp-tst.out
include ../Rules include ../Rules