From 23abbfa633f7e017a7939aa3966e0d7d24df480d Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Thu, 28 Aug 2014 12:31:23 +0200 Subject: test: NPTL: sync WRITE_BUFFER_SIZE with glibc test Test on Linux 3.16.1 in Qemu ARM fails with: TEST_EXEC nptl/ tst-cancel4 ret == 1 ; expected_ret == 0 make[1]: *** [tst-cancel4.exe] Error 1 The output of failed test is: minimum write buffer size too large ../Test.mak:89: recipe for target 'tst-cancel4.exe' failed Signed-off-by: Waldemar Brodkorb Signed-off-by: Bernhard Reutner-Fischer --- test/nptl/tst-cancel4.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'test/nptl') diff --git a/test/nptl/tst-cancel4.c b/test/nptl/tst-cancel4.c index e7119589f..53abf83ee 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); -- cgit v1.2.3 From 697dbb016e4bc63d20a7c871a9580e7dce32d1b0 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Thu, 28 Aug 2014 12:31:29 +0200 Subject: test: get out of the endless while loop, when bind failed When bind() fails in this test, then /tmp get filled up with temp files and upcoming tests will fail, because they need to create temp files, too. Better exit from the loop. Test still needs to be investigated to fix the failing bind(). Signed-off-by: Waldemar Brodkorb Signed-off-by: Bernhard Reutner-Fischer --- test/nptl/tst-cancel4.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/nptl') diff --git a/test/nptl/tst-cancel4.c b/test/nptl/tst-cancel4.c index 53abf83ee..4ba40450e 100644 --- a/test/nptl/tst-cancel4.c +++ b/test/nptl/tst-cancel4.c @@ -1015,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"); -- cgit v1.2.3 From 512fd3804b963a6738ce59d25dd44a7d9143b8b7 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Thu, 28 Aug 2014 12:31:30 +0200 Subject: test: sync with glibc, use do_test This breaks out of a deadlock, which occurs when testing for powerpc. (qemu) Otherwise the test suite does not finish. Signed-off-by: Waldemar Brodkorb Signed-off-by: Bernhard Reutner-Fischer --- test/nptl/tst-sem3.c | 33 ++++++++++++++++++--------------- test/nptl/tst-sem4.c | 7 +++++-- 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'test/nptl') 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 , 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 , 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" -- cgit v1.2.3