diff options
Diffstat (limited to 'test/nptl')
-rw-r--r-- | test/nptl/tst-cancel4.c | 28 | ||||
-rw-r--r-- | test/nptl/tst-sem3.c | 33 | ||||
-rw-r--r-- | test/nptl/tst-sem4.c | 7 |
3 files changed, 49 insertions, 19 deletions
diff --git a/test/nptl/tst-cancel4.c b/test/nptl/tst-cancel4.c index e7119589f..4ba40450e 100644 --- a/test/nptl/tst-cancel4.c +++ b/test/nptl/tst-cancel4.c @@ -83,7 +83,30 @@ static pthread_barrier_t b2; # define IPC_ADDVAL 0 #endif -#define WRITE_BUFFER_SIZE 4096 +/* The WRITE_BUFFER_SIZE value needs to be chosen such that if we set + the socket send buffer size to '1', a write of this size on that + socket will block. + + The Linux kernel imposes a minimum send socket buffer size which + has changed over the years. As of Linux 3.10 the value is: + + 2 * (2048 + SKB_DATA_ALIGN(sizeof(struct sk_buff))) + + which is attempting to make sure that with standard MTUs, + TCP can always queue up at least 2 full sized packets. + + Furthermore, there is logic in the socket send paths that + will allow one more packet (of any size) to be queued up as + long as some socket buffer space remains. Blocking only + occurs when we try to queue up a new packet and the send + buffer space has already been fully consumed. + + Therefore we must set this value to the largest possible value of + the formula above (and since it depends upon the size of "struct + sk_buff", it is dependent upon machine word size etc.) plus some + slack space. */ + +#define WRITE_BUFFER_SIZE 16384 /* Cleanup handling test. */ static int cl_called; @@ -758,7 +781,6 @@ tf_sigpause (void *arg) pthread_cleanup_push (cl, NULL); - /* Just for fun block the cancellation signal. */ sigpause (SIGCANCEL); pthread_cleanup_pop (0); @@ -993,6 +1015,8 @@ tf_accept (void *arg) if (++tries > 10) { printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); + /* prevent endless loop, when bind fails forever */ + exit (1); } strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-1-XXXXXX"); diff --git a/test/nptl/tst-sem3.c b/test/nptl/tst-sem3.c index d14f6f633..7b75e29e2 100644 --- a/test/nptl/tst-sem3.c +++ b/test/nptl/tst-sem3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2002-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -28,7 +28,7 @@ int -main (void) +do_test (void) { size_t ps = sysconf (_SC_PAGESIZE); char tmpfname[] = "/tmp/tst-sem3.XXXXXX"; @@ -43,7 +43,7 @@ main (void) if (fd == -1) { printf ("cannot open temporary file: %m\n"); - exit (1); + return 1; } /* Make sure it is always removed. */ @@ -56,14 +56,14 @@ main (void) if (write (fd, data, ps) != (ssize_t) ps) { puts ("short write"); - exit (1); + return 1; } mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (mem == MAP_FAILED) { printf ("mmap failed: %m\n"); - exit (1); + return 1; } s = (sem_t *) (((uintptr_t) mem + __alignof (sem_t)) @@ -73,25 +73,25 @@ main (void) if (sem_init (s, 1, 1) == -1) { puts ("init failed"); - exit (1); + return 1; } if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1) { puts ("1st wait failed"); - exit (1); + return 1; } errno = 0; if (TEMP_FAILURE_RETRY (sem_trywait (s)) != -1) { puts ("trywait succeeded"); - exit (1); + return 1; } else if (errno != EAGAIN) { puts ("trywait didn't return EAGAIN"); - exit (1); + return 1; } *p = 0; @@ -101,7 +101,7 @@ main (void) if (pid == -1) { puts ("fork failed"); - exit (1); + return 1; } else if (pid == 0) { @@ -109,13 +109,13 @@ main (void) if ((*p)++ != 0) { puts ("child: *p != 0"); - exit (1); + return 1; } if (sem_post (s) == -1) { puts ("child: 1st post failed"); - exit (1); + return 1; } puts ("child done"); @@ -125,17 +125,20 @@ main (void) if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1) { printf ("parent: 2nd wait failed: %m\n"); - exit (1); + return 1; } if (*p != 1) { puts ("*p != 1"); - exit (1); + return 1; } puts ("parent done"); } - exit (0); + return 0; } + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/nptl/tst-sem4.c b/test/nptl/tst-sem4.c index 125759bab..72ed97d37 100644 --- a/test/nptl/tst-sem4.c +++ b/test/nptl/tst-sem4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -32,7 +32,7 @@ remove_sem (int status, void *arg) int -main (void) +do_test (void) { sem_t *s; sem_t *s2; @@ -144,3 +144,6 @@ main (void) return 0; } + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |