Skip to content

Commit

Permalink
Update..
Browse files Browse the repository at this point in the history
2003-06-17  Ulrich Drepper  <drepper@redhat.com>

	* tst-cancel4.c: Test open, close, pread, pwrite, fsync, and msync.
  • Loading branch information
Ulrich Drepper committed Jun 17, 2003
1 parent bbde852 commit 047aec8
Show file tree
Hide file tree
Showing 2 changed files with 266 additions and 4 deletions.
4 changes: 4 additions & 0 deletions nptl/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2003-06-17 Ulrich Drepper <drepper@redhat.com>

* tst-cancel4.c: Test open, close, pread, pwrite, fsync, and msync.

2003-06-16 Jakub Jelinek <jakub@redhat.com>

* sysdeps/pthread/createthread.c (create_thread): Set
Expand Down
266 changes: 262 additions & 4 deletions nptl/tst-cancel4.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
exit to be called more than once. */

#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <pthread.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/poll.h>
#include <sys/select.h>
#include <sys/socket.h>
Expand All @@ -41,10 +43,9 @@
/* The following interfaces are defined to be cancellation points but
tests are not yet implemented:
aio_suspend() clock_nanosleep() close()
connect() creat() fsync()
msgrcv() msgsnd() msync()
open() pread() pwrite()
aio_suspend() clock_nanosleep()
connect() creat()
msgrcv() msgsnd()
sendmsg() sendto()
tcdrain()
Expand Down Expand Up @@ -1296,6 +1297,257 @@ tf_recvmsg (void *arg)
}


static void *
tf_open (void *arg)
{
if (arg == NULL)
// XXX If somebody can provide a portable test case in which open()
// blocks we can enable this test to run in both rounds.
abort ();

int r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: barrier_wait failed\n", __FUNCTION__);
exit (1);
}

r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
exit (1);
}

pthread_cleanup_push (cl, NULL);

open ("Makefile", O_RDONLY);

pthread_cleanup_pop (0);

printf ("%s: open returned\n", __FUNCTION__);

exit (1);
}


static void *
tf_close (void *arg)
{
if (arg == NULL)
// XXX If somebody can provide a portable test case in which close()
// blocks we can enable this test to run in both rounds.
abort ();

char fname[] = "/tmp/tst-cancel-fd-XXXXXX";
tempfd = mkstemp (fname);
if (tempfd == -1)
{
printf ("%s: mkstemp failed\n", __FUNCTION__);
exit (1);
}
unlink (fname);

int r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: barrier_wait failed\n", __FUNCTION__);
exit (1);
}

r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
exit (1);
}

pthread_cleanup_push (cl, NULL);

close (tempfd);

pthread_cleanup_pop (0);

printf ("%s: close returned\n", __FUNCTION__);

exit (1);
}


static void *
tf_pread (void *arg)
{
if (arg == NULL)
// XXX If somebody can provide a portable test case in which pread()
// blocks we can enable this test to run in both rounds.
abort ();

tempfd = open ("Makefile", O_RDONLY);
if (tempfd == -1)
{
printf ("%s: cannot open Makefile\n", __FUNCTION__);
exit (1);
}

int r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: barrier_wait failed\n", __FUNCTION__);
exit (1);
}

r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
exit (1);
}

pthread_cleanup_push (cl, NULL);

char mem[10];
pread (tempfd, mem, sizeof (mem), 0);

pthread_cleanup_pop (0);

printf ("%s: pread returned\n", __FUNCTION__);

exit (1);
}


static void *
tf_pwrite (void *arg)
{
if (arg == NULL)
// XXX If somebody can provide a portable test case in which pwrite()
// blocks we can enable this test to run in both rounds.
abort ();

char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
tempfd = mkstemp (fname);
if (tempfd == -1)
{
printf ("%s: mkstemp failed\n", __FUNCTION__);
exit (1);
}
unlink (fname);

int r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: barrier_wait failed\n", __FUNCTION__);
exit (1);
}

r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
exit (1);
}

pthread_cleanup_push (cl, NULL);

char mem[10];
pwrite (tempfd, mem, sizeof (mem), 0);

pthread_cleanup_pop (0);

printf ("%s: pwrite returned\n", __FUNCTION__);

exit (1);
}


static void *
tf_fsync (void *arg)
{
if (arg == NULL)
// XXX If somebody can provide a portable test case in which fsync()
// blocks we can enable this test to run in both rounds.
abort ();

tempfd = open ("Makefile", O_RDONLY);
if (tempfd == -1)
{
printf ("%s: cannot open Makefile\n", __FUNCTION__);
exit (1);
}

int r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: barrier_wait failed\n", __FUNCTION__);
exit (1);
}

r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
exit (1);
}

pthread_cleanup_push (cl, NULL);

fsync (tempfd);

pthread_cleanup_pop (0);

printf ("%s: fsync returned\n", __FUNCTION__);

exit (1);
}


static void *
tf_msync (void *arg)
{
if (arg == NULL)
// XXX If somebody can provide a portable test case in which msync()
// blocks we can enable this test to run in both rounds.
abort ();

tempfd = open ("Makefile", O_RDONLY);
if (tempfd == -1)
{
printf ("%s: cannot open Makefile\n", __FUNCTION__);
exit (1);
}
void *p = mmap (NULL, 10, PROT_READ, MAP_SHARED, tempfd, 0);
if (p == MAP_FAILED)
{
printf ("%s: mmap failed\n", __FUNCTION__);
exit (1);
}

int r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: barrier_wait failed\n", __FUNCTION__);
exit (1);
}

r = pthread_barrier_wait (&b2);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
exit (1);
}

pthread_cleanup_push (cl, NULL);

msync (p, 10, 0);

pthread_cleanup_pop (0);

printf ("%s: msync returned\n", __FUNCTION__);

exit (1);
}


static struct
{
const char *name;
Expand Down Expand Up @@ -1329,6 +1581,12 @@ static struct
ADD_TEST (recv, 2, 0),
ADD_TEST (recvfrom, 2, 0),
ADD_TEST (recvmsg, 2, 0),
ADD_TEST (open, 2, 1),
ADD_TEST (close, 2, 1),
ADD_TEST (pread, 2, 1),
ADD_TEST (pwrite, 2, 1),
ADD_TEST (fsync, 2, 1),
ADD_TEST (msync, 2, 1),
};
#define ntest_tf (sizeof (tests) / sizeof (tests[0]))

Expand Down

0 comments on commit 047aec8

Please sign in to comment.