From 75accc3bc3c164ac6063c384c98f0dfa7d489dcc Mon Sep 17 00:00:00 2001 From: Austin Foxley Date: Sat, 17 Oct 2009 12:39:06 -0700 Subject: test/nptl/: tests for NPTL Signed-off-by: Austin Foxley --- test/nptl/Makefile | 149 ++++++ test/nptl/tst-align.c | 71 +++ test/nptl/tst-align2.c | 87 ++++ test/nptl/tst-atfork1.c | 121 +++++ test/nptl/tst-attr1.c | 306 ++++++++++++ test/nptl/tst-attr2.c | 317 ++++++++++++ test/nptl/tst-attr3.c | 420 ++++++++++++++++ test/nptl/tst-barrier1.c | 71 +++ test/nptl/tst-barrier2.c | 185 +++++++ test/nptl/tst-barrier3.c | 154 ++++++ test/nptl/tst-barrier4.c | 122 +++++ test/nptl/tst-basic1.c | 82 ++++ test/nptl/tst-basic2.c | 121 +++++ test/nptl/tst-basic3.c | 87 ++++ test/nptl/tst-basic4.c | 101 ++++ test/nptl/tst-basic5.c | 74 +++ test/nptl/tst-basic6.c | 132 +++++ test/nptl/tst-cancel1.c | 163 +++++++ test/nptl/tst-cancel10.c | 126 +++++ test/nptl/tst-cancel11.c | 123 +++++ test/nptl/tst-cancel12.c | 127 +++++ test/nptl/tst-cancel13.c | 129 +++++ test/nptl/tst-cancel14.c | 137 ++++++ test/nptl/tst-cancel15.c | 142 ++++++ test/nptl/tst-cancel16.c | 231 +++++++++ test/nptl/tst-cancel19.c | 287 +++++++++++ test/nptl/tst-cancel2.c | 100 ++++ test/nptl/tst-cancel20.c | 264 ++++++++++ test/nptl/tst-cancel21.c | 294 ++++++++++++ test/nptl/tst-cancel22.c | 121 +++++ test/nptl/tst-cancel3.c | 98 ++++ test/nptl/tst-cancel6.c | 79 +++ test/nptl/tst-cancel7.c | 213 ++++++++ test/nptl/tst-cancel8.c | 143 ++++++ test/nptl/tst-cancel9.c | 126 +++++ test/nptl/tst-cleanup0.c | 76 +++ test/nptl/tst-cleanup1.c | 100 ++++ test/nptl/tst-cleanup2.c | 63 +++ test/nptl/tst-cleanup3.c | 98 ++++ test/nptl/tst-cleanup4.c | 198 ++++++++ test/nptl/tst-cleanup4aux.c | 121 +++++ test/nptl/tst-clock.c | 124 +++++ test/nptl/tst-clock1.c | 51 ++ test/nptl/tst-clock2.c | 202 ++++++++ test/nptl/tst-clock_nanosleep.c | 58 +++ test/nptl/tst-cond1.c | 94 ++++ test/nptl/tst-cond10.c | 173 +++++++ test/nptl/tst-cond11.c | 191 ++++++++ test/nptl/tst-cond12.c | 196 ++++++++ test/nptl/tst-cond13.c | 2 + test/nptl/tst-cond14.c | 118 +++++ test/nptl/tst-cond15.c | 160 ++++++ test/nptl/tst-cond16.c | 105 ++++ test/nptl/tst-cond17.c | 2 + test/nptl/tst-cond18.c | 117 +++++ test/nptl/tst-cond19.c | 76 +++ test/nptl/tst-cond2.c | 163 +++++++ test/nptl/tst-cond20.c | 170 +++++++ test/nptl/tst-cond21.c | 3 + test/nptl/tst-cond3.c | 113 +++++ test/nptl/tst-cond4.c | 264 ++++++++++ test/nptl/tst-cond5.c | 106 ++++ test/nptl/tst-cond6.c | 234 +++++++++ test/nptl/tst-cond7.c | 168 +++++++ test/nptl/tst-cond8.c | 277 +++++++++++ test/nptl/tst-cond9.c | 150 ++++++ test/nptl/tst-cpuclock1.c | 307 ++++++++++++ test/nptl/tst-cpuclock2.c | 332 +++++++++++++ test/nptl/tst-cputimer1.c | 68 +++ test/nptl/tst-cputimer2.c | 83 ++++ test/nptl/tst-cputimer3.c | 130 +++++ test/nptl/tst-detach1.c | 56 +++ test/nptl/tst-eintr1.c | 105 ++++ test/nptl/tst-eintr2.c | 118 +++++ test/nptl/tst-eintr3.c | 72 +++ test/nptl/tst-eintr4.c | 56 +++ test/nptl/tst-eintr5.c | 81 ++++ test/nptl/tst-exec2.c | 154 ++++++ test/nptl/tst-exec3.c | 152 ++++++ test/nptl/tst-exec4.c | 116 +++++ test/nptl/tst-exit1.c | 79 +++ test/nptl/tst-exit2.c | 40 ++ test/nptl/tst-exit3.c | 81 ++++ test/nptl/tst-flock1.c | 93 ++++ test/nptl/tst-flock2.c | 260 ++++++++++ test/nptl/tst-fork1.c | 120 +++++ test/nptl/tst-fork2.c | 90 ++++ test/nptl/tst-fork3.c | 107 +++++ test/nptl/tst-fork4.c | 65 +++ test/nptl/tst-initializers1.c | 48 ++ test/nptl/tst-join1.c | 83 ++++ test/nptl/tst-join2.c | 104 ++++ test/nptl/tst-join3.c | 123 +++++ test/nptl/tst-join4.c | 125 +++++ test/nptl/tst-join5.c | 143 ++++++ test/nptl/tst-key1.c | 89 ++++ test/nptl/tst-key2.c | 115 +++++ test/nptl/tst-key3.c | 156 ++++++ test/nptl/tst-key4.c | 137 ++++++ test/nptl/tst-kill1.c | 100 ++++ test/nptl/tst-kill2.c | 139 ++++++ test/nptl/tst-kill3.c | 159 ++++++ test/nptl/tst-kill4.c | 74 +++ test/nptl/tst-kill5.c | 49 ++ test/nptl/tst-kill6.c | 162 +++++++ test/nptl/tst-mqueue.h | 84 ++++ test/nptl/tst-mqueue1.c | 417 ++++++++++++++++ test/nptl/tst-mqueue2.c | 477 ++++++++++++++++++ test/nptl/tst-mqueue3.c | 244 ++++++++++ test/nptl/tst-mqueue4.c | 288 +++++++++++ test/nptl/tst-mqueue5.c | 1014 +++++++++++++++++++++++++++++++++++++++ test/nptl/tst-mqueue6.c | 305 ++++++++++++ test/nptl/tst-mqueue7.c | 109 +++++ test/nptl/tst-mqueue8.c | 266 ++++++++++ test/nptl/tst-mqueue9.c | 92 ++++ test/nptl/tst-mutex1.c | 57 +++ test/nptl/tst-mutex2.c | 223 +++++++++ test/nptl/tst-mutex3.c | 225 +++++++++ test/nptl/tst-mutex4.c | 191 ++++++++ test/nptl/tst-mutex5.c | 186 +++++++ test/nptl/tst-mutex5a.c | 2 + test/nptl/tst-mutex6.c | 55 +++ test/nptl/tst-mutex7.c | 121 +++++ test/nptl/tst-mutex7a.c | 2 + test/nptl/tst-mutex8.c | 367 ++++++++++++++ test/nptl/tst-mutex9.c | 191 ++++++++ test/nptl/tst-once1.c | 51 ++ test/nptl/tst-once2.c | 104 ++++ test/nptl/tst-once3.c | 162 +++++++ test/nptl/tst-once4.c | 202 ++++++++ test/nptl/tst-popen1.c | 60 +++ test/nptl/tst-raise1.c | 62 +++ test/nptl/tst-rwlock1.c | 117 +++++ test/nptl/tst-rwlock10.c | 21 + test/nptl/tst-rwlock11.c | 21 + test/nptl/tst-rwlock12.c | 208 ++++++++ test/nptl/tst-rwlock13.c | 71 +++ test/nptl/tst-rwlock14.c | 169 +++++++ test/nptl/tst-rwlock2.c | 143 ++++++ test/nptl/tst-rwlock3.c | 93 ++++ test/nptl/tst-rwlock4.c | 190 ++++++++ test/nptl/tst-rwlock5.c | 87 ++++ test/nptl/tst-rwlock6.c | 226 +++++++++ test/nptl/tst-rwlock7.c | 179 +++++++ test/nptl/tst-rwlock8.c | 164 +++++++ test/nptl/tst-rwlock9.c | 203 ++++++++ test/nptl/tst-sched1.c | 98 ++++ test/nptl/tst-sem1.c | 89 ++++ test/nptl/tst-sem2.c | 54 +++ test/nptl/tst-sem3.c | 142 ++++++ test/nptl/tst-sem4.c | 147 ++++++ test/nptl/tst-sem5.c | 80 +++ test/nptl/tst-sem6.c | 81 ++++ test/nptl/tst-sem7.c | 109 +++++ test/nptl/tst-sem8.c | 74 +++ test/nptl/tst-sem9.c | 81 ++++ test/nptl/tst-signal1.c | 189 ++++++++ test/nptl/tst-signal2.c | 198 ++++++++ test/nptl/tst-signal3.c | 261 ++++++++++ test/nptl/tst-signal4.c | 60 +++ test/nptl/tst-signal5.c | 111 +++++ test/nptl/tst-signal6.c | 192 ++++++++ test/nptl/tst-spin1.c | 57 +++ test/nptl/tst-spin2.c | 159 ++++++ test/nptl/tst-spin3.c | 55 +++ test/nptl/tst-stack-align.h | 35 ++ test/nptl/tst-stack1.c | 146 ++++++ test/nptl/tst-stack2.c | 80 +++ test/nptl/tst-stdio1.c | 57 +++ test/nptl/tst-stdio2.c | 82 ++++ test/nptl/tst-sysconf.c | 48 ++ test/nptl/tst-timer2.c | 65 +++ test/nptl/tst-timer3.c | 86 ++++ test/nptl/tst-timer4.c | 648 +++++++++++++++++++++++++ test/nptl/tst-timer5.c | 38 ++ test/nptl/tst-tls1.c | 122 +++++ test/nptl/tst-tls2.c | 216 +++++++++ test/nptl/tst-tls3.c | 216 +++++++++ test/nptl/tst-tls3mod.c | 94 ++++ test/nptl/tst-tls4.c | 191 ++++++++ test/nptl/tst-tls4moda.c | 56 +++ test/nptl/tst-tls4modb.c | 65 +++ test/nptl/tst-tls5.c | 119 +++++ test/nptl/tst-tls5.h | 28 ++ test/nptl/tst-tls5mod.c | 6 + test/nptl/tst-tls5moda.c | 6 + test/nptl/tst-tls5modb.c | 6 + test/nptl/tst-tls5modc.c | 6 + test/nptl/tst-tls5modd.c | 6 + test/nptl/tst-tls5mode.c | 8 + test/nptl/tst-tls5modf.c | 9 + test/nptl/tst-tsd1.c | 118 +++++ test/nptl/tst-tsd2.c | 97 ++++ test/nptl/tst-tsd3.c | 129 +++++ test/nptl/tst-tsd4.c | 103 ++++ test/nptl/tst-tsd5.c | 81 ++++ test/nptl/tst-umask1.c | 137 ++++++ 197 files changed, 26837 insertions(+) create mode 100644 test/nptl/Makefile create mode 100644 test/nptl/tst-align.c create mode 100644 test/nptl/tst-align2.c create mode 100644 test/nptl/tst-atfork1.c create mode 100644 test/nptl/tst-attr1.c create mode 100644 test/nptl/tst-attr2.c create mode 100644 test/nptl/tst-attr3.c create mode 100644 test/nptl/tst-barrier1.c create mode 100644 test/nptl/tst-barrier2.c create mode 100644 test/nptl/tst-barrier3.c create mode 100644 test/nptl/tst-barrier4.c create mode 100644 test/nptl/tst-basic1.c create mode 100644 test/nptl/tst-basic2.c create mode 100644 test/nptl/tst-basic3.c create mode 100644 test/nptl/tst-basic4.c create mode 100644 test/nptl/tst-basic5.c create mode 100644 test/nptl/tst-basic6.c create mode 100644 test/nptl/tst-cancel1.c create mode 100644 test/nptl/tst-cancel10.c create mode 100644 test/nptl/tst-cancel11.c create mode 100644 test/nptl/tst-cancel12.c create mode 100644 test/nptl/tst-cancel13.c create mode 100644 test/nptl/tst-cancel14.c create mode 100644 test/nptl/tst-cancel15.c create mode 100644 test/nptl/tst-cancel16.c create mode 100644 test/nptl/tst-cancel19.c create mode 100644 test/nptl/tst-cancel2.c create mode 100644 test/nptl/tst-cancel20.c create mode 100644 test/nptl/tst-cancel21.c create mode 100644 test/nptl/tst-cancel22.c create mode 100644 test/nptl/tst-cancel3.c create mode 100644 test/nptl/tst-cancel6.c create mode 100644 test/nptl/tst-cancel7.c create mode 100644 test/nptl/tst-cancel8.c create mode 100644 test/nptl/tst-cancel9.c create mode 100644 test/nptl/tst-cleanup0.c create mode 100644 test/nptl/tst-cleanup1.c create mode 100644 test/nptl/tst-cleanup2.c create mode 100644 test/nptl/tst-cleanup3.c create mode 100644 test/nptl/tst-cleanup4.c create mode 100644 test/nptl/tst-cleanup4aux.c create mode 100644 test/nptl/tst-clock.c create mode 100644 test/nptl/tst-clock1.c create mode 100644 test/nptl/tst-clock2.c create mode 100644 test/nptl/tst-clock_nanosleep.c create mode 100644 test/nptl/tst-cond1.c create mode 100644 test/nptl/tst-cond10.c create mode 100644 test/nptl/tst-cond11.c create mode 100644 test/nptl/tst-cond12.c create mode 100644 test/nptl/tst-cond13.c create mode 100644 test/nptl/tst-cond14.c create mode 100644 test/nptl/tst-cond15.c create mode 100644 test/nptl/tst-cond16.c create mode 100644 test/nptl/tst-cond17.c create mode 100644 test/nptl/tst-cond18.c create mode 100644 test/nptl/tst-cond19.c create mode 100644 test/nptl/tst-cond2.c create mode 100644 test/nptl/tst-cond20.c create mode 100644 test/nptl/tst-cond21.c create mode 100644 test/nptl/tst-cond3.c create mode 100644 test/nptl/tst-cond4.c create mode 100644 test/nptl/tst-cond5.c create mode 100644 test/nptl/tst-cond6.c create mode 100644 test/nptl/tst-cond7.c create mode 100644 test/nptl/tst-cond8.c create mode 100644 test/nptl/tst-cond9.c create mode 100644 test/nptl/tst-cpuclock1.c create mode 100644 test/nptl/tst-cpuclock2.c create mode 100644 test/nptl/tst-cputimer1.c create mode 100644 test/nptl/tst-cputimer2.c create mode 100644 test/nptl/tst-cputimer3.c create mode 100644 test/nptl/tst-detach1.c create mode 100644 test/nptl/tst-eintr1.c create mode 100644 test/nptl/tst-eintr2.c create mode 100644 test/nptl/tst-eintr3.c create mode 100644 test/nptl/tst-eintr4.c create mode 100644 test/nptl/tst-eintr5.c create mode 100644 test/nptl/tst-exec2.c create mode 100644 test/nptl/tst-exec3.c create mode 100644 test/nptl/tst-exec4.c create mode 100644 test/nptl/tst-exit1.c create mode 100644 test/nptl/tst-exit2.c create mode 100644 test/nptl/tst-exit3.c create mode 100644 test/nptl/tst-flock1.c create mode 100644 test/nptl/tst-flock2.c create mode 100644 test/nptl/tst-fork1.c create mode 100644 test/nptl/tst-fork2.c create mode 100644 test/nptl/tst-fork3.c create mode 100644 test/nptl/tst-fork4.c create mode 100644 test/nptl/tst-initializers1.c create mode 100644 test/nptl/tst-join1.c create mode 100644 test/nptl/tst-join2.c create mode 100644 test/nptl/tst-join3.c create mode 100644 test/nptl/tst-join4.c create mode 100644 test/nptl/tst-join5.c create mode 100644 test/nptl/tst-key1.c create mode 100644 test/nptl/tst-key2.c create mode 100644 test/nptl/tst-key3.c create mode 100644 test/nptl/tst-key4.c create mode 100644 test/nptl/tst-kill1.c create mode 100644 test/nptl/tst-kill2.c create mode 100644 test/nptl/tst-kill3.c create mode 100644 test/nptl/tst-kill4.c create mode 100644 test/nptl/tst-kill5.c create mode 100644 test/nptl/tst-kill6.c create mode 100644 test/nptl/tst-mqueue.h create mode 100644 test/nptl/tst-mqueue1.c create mode 100644 test/nptl/tst-mqueue2.c create mode 100644 test/nptl/tst-mqueue3.c create mode 100644 test/nptl/tst-mqueue4.c create mode 100644 test/nptl/tst-mqueue5.c create mode 100644 test/nptl/tst-mqueue6.c create mode 100644 test/nptl/tst-mqueue7.c create mode 100644 test/nptl/tst-mqueue8.c create mode 100644 test/nptl/tst-mqueue9.c create mode 100644 test/nptl/tst-mutex1.c create mode 100644 test/nptl/tst-mutex2.c create mode 100644 test/nptl/tst-mutex3.c create mode 100644 test/nptl/tst-mutex4.c create mode 100644 test/nptl/tst-mutex5.c create mode 100644 test/nptl/tst-mutex5a.c create mode 100644 test/nptl/tst-mutex6.c create mode 100644 test/nptl/tst-mutex7.c create mode 100644 test/nptl/tst-mutex7a.c create mode 100644 test/nptl/tst-mutex8.c create mode 100644 test/nptl/tst-mutex9.c create mode 100644 test/nptl/tst-once1.c create mode 100644 test/nptl/tst-once2.c create mode 100644 test/nptl/tst-once3.c create mode 100644 test/nptl/tst-once4.c create mode 100644 test/nptl/tst-popen1.c create mode 100644 test/nptl/tst-raise1.c create mode 100644 test/nptl/tst-rwlock1.c create mode 100644 test/nptl/tst-rwlock10.c create mode 100644 test/nptl/tst-rwlock11.c create mode 100644 test/nptl/tst-rwlock12.c create mode 100644 test/nptl/tst-rwlock13.c create mode 100644 test/nptl/tst-rwlock14.c create mode 100644 test/nptl/tst-rwlock2.c create mode 100644 test/nptl/tst-rwlock3.c create mode 100644 test/nptl/tst-rwlock4.c create mode 100644 test/nptl/tst-rwlock5.c create mode 100644 test/nptl/tst-rwlock6.c create mode 100644 test/nptl/tst-rwlock7.c create mode 100644 test/nptl/tst-rwlock8.c create mode 100644 test/nptl/tst-rwlock9.c create mode 100644 test/nptl/tst-sched1.c create mode 100644 test/nptl/tst-sem1.c create mode 100644 test/nptl/tst-sem2.c create mode 100644 test/nptl/tst-sem3.c create mode 100644 test/nptl/tst-sem4.c create mode 100644 test/nptl/tst-sem5.c create mode 100644 test/nptl/tst-sem6.c create mode 100644 test/nptl/tst-sem7.c create mode 100644 test/nptl/tst-sem8.c create mode 100644 test/nptl/tst-sem9.c create mode 100644 test/nptl/tst-signal1.c create mode 100644 test/nptl/tst-signal2.c create mode 100644 test/nptl/tst-signal3.c create mode 100644 test/nptl/tst-signal4.c create mode 100644 test/nptl/tst-signal5.c create mode 100644 test/nptl/tst-signal6.c create mode 100644 test/nptl/tst-spin1.c create mode 100644 test/nptl/tst-spin2.c create mode 100644 test/nptl/tst-spin3.c create mode 100644 test/nptl/tst-stack-align.h create mode 100644 test/nptl/tst-stack1.c create mode 100644 test/nptl/tst-stack2.c create mode 100644 test/nptl/tst-stdio1.c create mode 100644 test/nptl/tst-stdio2.c create mode 100644 test/nptl/tst-sysconf.c create mode 100644 test/nptl/tst-timer2.c create mode 100644 test/nptl/tst-timer3.c create mode 100644 test/nptl/tst-timer4.c create mode 100644 test/nptl/tst-timer5.c create mode 100644 test/nptl/tst-tls1.c create mode 100644 test/nptl/tst-tls2.c create mode 100644 test/nptl/tst-tls3.c create mode 100644 test/nptl/tst-tls3mod.c create mode 100644 test/nptl/tst-tls4.c create mode 100644 test/nptl/tst-tls4moda.c create mode 100644 test/nptl/tst-tls4modb.c create mode 100644 test/nptl/tst-tls5.c create mode 100644 test/nptl/tst-tls5.h create mode 100644 test/nptl/tst-tls5mod.c create mode 100644 test/nptl/tst-tls5moda.c create mode 100644 test/nptl/tst-tls5modb.c create mode 100644 test/nptl/tst-tls5modc.c create mode 100644 test/nptl/tst-tls5modd.c create mode 100644 test/nptl/tst-tls5mode.c create mode 100644 test/nptl/tst-tls5modf.c create mode 100644 test/nptl/tst-tsd1.c create mode 100644 test/nptl/tst-tsd2.c create mode 100644 test/nptl/tst-tsd3.c create mode 100644 test/nptl/tst-tsd4.c create mode 100644 test/nptl/tst-tsd5.c create mode 100644 test/nptl/tst-umask1.c diff --git a/test/nptl/Makefile b/test/nptl/Makefile new file mode 100644 index 000000000..65378dd87 --- /dev/null +++ b/test/nptl/Makefile @@ -0,0 +1,149 @@ +# uClibc NPTL tests +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + +TESTS := tst-align tst-align2 tst-atfork1 tst-attr1 tst-attr2 tst-attr3 \ + tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 tst-basic1 \ + tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \ + tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel6 tst-cancel7 \ + tst-cancel8 tst-cancel9 tst-cancel10 tst-cancel11 tst-cancel12 \ + tst-cancel13 tst-cancel14 tst-cancel15 tst-cancel16 \ + tst-cancel19 tst-cancel20 tst-cancel21 tst-cancel22 \ + tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 \ + tst-cleanup4 tst-clock1 tst-clock2 tst-cond1 tst-cond2 \ + tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 tst-cond8 \ + tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \ + tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 \ + tst-cond19 tst-cond20 tst-cond21 tst-detach1 tst-eintr1 \ + tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 tst-exec2 tst-exec3 \ + tst-exec4 tst-exit1 tst-exit2 tst-exit3 tst-flock1 tst-flock2 \ + tst-fork1 tst-fork2 tst-fork3 tst-fork4 tst-initializers1 \ + tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 tst-key1 \ + tst-key2 tst-key3 tst-key4 tst-kill1 tst-kill2 tst-kill3 \ + tst-kill4 tst-kill5 tst-kill6 tst-mutex1 tst-mutex2 tst-mutex3 \ + tst-mutex4 tst-mutex5 tst-mutex6 tst-mutex7 tst-mutex8 \ + tst-mutex9 tst-mutex5a tst-mutex7a tst-once1 tst-once2 \ + tst-once3 tst-once4 tst-popen1 tst-raise1 tst-rwlock1 \ + tst-rwlock2 tst-rwlock3 tst-rwlock4 tst-rwlock5 tst-rwlock6 \ + tst-rwlock7 tst-rwlock8 tst-rwlock9 tst-rwlock10 tst-rwlock11 \ + tst-rwlock12 tst-rwlock13 tst-rwlock14 tst-sched1 tst-sem1 \ + tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 tst-sem8 \ + tst-sem9 tst-signal1 tst-signal2 tst-signal3 tst-signal4 \ + tst-signal5 tst-signal6 tst-spin1 tst-spin2 tst-spin3 \ + tst-stack1 tst-stack2 tst-stdio1 tst-stdio2 tst-sysconf \ + tst-tls1 tst-tls2 tst-tls3 tst-tls4 tst-tls5 tst-tsd1 tst-tsd2 \ + tst-tsd3 tst-tsd4 tst-tsd5 tst-umask1 + +# +# These are for the RT library and POSIX timers. +# +TESTS += tst-clock tst-clock_nanosleep tst-cpuclock1 tst-cpuclock2 \ + tst-cputimer1 tst-cputimer2 tst-cputimer3 tst-mqueue1 \ + tst-mqueue2 tst-mqueue3 tst-mqueue4 tst-mqueue5 tst-mqueue6 \ + tst-mqueue7 tst-mqueue8 tst-mqueue9 tst-timer2 tst-timer3 \ + tst-timer4 tst-timer5 + +ifeq ($(UCLIBC_HAS_OBSOLETE_BSD_SIGNAL),) +TESTS_DISABLED := tst-exec2 tst-exec3 tst-exec4 +endif + +include ../Test.mak + +TARGET_ARCH := $(strip $(subst ",, $(strip $(TARGET_ARCH)))) +PTDIR := $(top_builddir)libpthread/nptl + +EXTRA_CFLAGS := -DNOT_IN_libc=1 -D_LIBC -D__USE_GNU -std=gnu99 \ + -I$(PTDIR) -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \ + -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \ + -I$(PTDIR)/sysdeps/unix/sysv/linux \ + -I$(PTDIR)/sysdeps/pthread \ + -I$(PTDIR)/sysdeps/pthread/bits \ + -I$(PTDIR)/sysdeps/generic \ + -I$(top_builddir)ldso/include \ + -I$(top_builddir)ldso/ldso/$(TARGET_ARCH) \ + -include $(top_builddir)include/libc-symbols.h + +ifeq ($(TARGET_ARCH),i386) +CFLAGS_tst-align.o := -malign-double -mpreferred-stack-boundary=4 +endif +ifeq ($(TARGET_ARCH),i686) +CFLAGS_tst-align.o := -malign-double -mpreferred-stack-boundary=4 -msse +endif +CFLAGS_tst-cleanup4aux.o := -W -Wall -sjh +CFLAGS_tst-initializers1.o := -W -Wall -Werror +CFLAGS_tst-tls3.o := tst-tls3mod.so +CFLAGS_tst-tls4.o := tst-tls4moda.so tst-tls4modb.so +CFLAGS_tst-tls5.o := tst-tls5mod.so +CFLAGS_tst-tls3mod.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc +CFLAGS_tst-tls4moda.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc +CFLAGS_tst-tls4modb.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc +CFLAGS_tst-tls5mod.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc +CFLAGS_tst-tls5moda.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc +CFLAGS_tst-tls5modb.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc +CFLAGS_tst-tls5modc.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc +CFLAGS_tst-tls5modd.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc +CFLAGS_tst-tls5mode.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc +CFLAGS_tst-tls5modf.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc + +EXTRA_LDFLAGS := -lpthread + +LDFLAGS_tst-cleanup4 := tst-cleanup4aux.o +LDFLAGS_tst-clock2 := -lrt +LDFLAGS_tst-cond11 := -lrt +LDFLAGS_tst-cond19 := -lrt +LDFLAGS_tst-rwlock14 := -lrt +LDFLAGS_tst-tls3 := -ldl -rdynamic +LDFLAGS_tst-tls4 := -ldl +LDFLAGS_tst-tls5 := tst-tls5mod.so +LDFLAGS_tst-clock := -lrt +LDFLAGS_tst-clock_nanosleep := -lrt +LDFLAGS_tst-cpuclock1 := -lrt +LDFLAGS_tst-cpuclock2 := -lrt +LDFLAGS_tst-cputimer1 := -lrt +LDFLAGS_tst-cputimer2 := -lrt +LDFLAGS_tst-cputimer3 := -lrt +LDFLAGS_tst-mqueue1 := -lrt +LDFLAGS_tst-mqueue2 := -lrt +LDFLAGS_tst-mqueue3 := -lrt +LDFLAGS_tst-mqueue4 := -lrt +LDFLAGS_tst-mqueue5 := -lrt +LDFLAGS_tst-mqueue6 := -lrt +LDFLAGS_tst-mqueue7 := -lrt +LDFLAGS_tst-mqueue8 := -lrt +LDFLAGS_tst-mqueue9 := -lrt +LDFLAGS_tst-timer2 := -lrt +LDFLAGS_tst-timer3 := -lrt +LDFLAGS_tst-timer4 := -lrt +LDFLAGS_tst-timer5 := -lrt +LDFLAGS_tst-tls3mod.so := -shared -static-libgcc +LDFLAGS_tst-tls4moda.so := -shared -static-libgcc +LDFLAGS_tst-tls4modb.so := -shared -static-libgcc +LDFLAGS_tst-tls5mod.so := -shared -static-libgcc -Wl,-soname,tst-tls5mod.so +LDFLAGS_tst-tls5moda.so := -shared -static-libgcc +LDFLAGS_tst-tls5modb.so := -shared -static-libgcc +LDFLAGS_tst-tls5modc.so := -shared -static-libgcc +LDFLAGS_tst-tls5modd.so := -shared -static-libgcc +LDFLAGS_tst-tls5mode.so := -shared -static-libgcc +LDFLAGS_tst-tls5modf.so := -shared -static-libgcc + +# +# Special case +# +tst-cleanup4aux.o: + $(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c tst-cleanup4aux.c -o $@ + +tst-cleanup4: tst-cleanup4aux.o +tst-tls3: tst-tls3mod.so +tst-tls4: tst-tls4moda.so tst-tls4modb.so +tst-tls5: tst-tls5mod.so tst-tls5moda.so tst-tls5modb.so \ + tst-tls5modc.so tst-tls5modd.so tst-tls5mode.so tst-tls5modf.so + +OPTS_tst-cancel7 = --command ./tst-cancel7 +OPTS_tst-mqueue7 = -- ./tst-mqueue7 +OPTS_tst-exec4 = ./tst-exec4 + +RET_tst-clock2 := 1 +RET_tst-cputimer1 := 1 +RET_tst-cputimer2 := 1 +RET_tst-cputimer3 := 1 + +WRAPPER := env LD_LIBRARY_PATH="$$PWD:.:$(LD_LIBRARY_PATH)" TIMEOUTFACTOR=100 diff --git a/test/nptl/tst-align.c b/test/nptl/tst-align.c new file mode 100644 index 000000000..381db8f4e --- /dev/null +++ b/test/nptl/tst-align.c @@ -0,0 +1,71 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include "tst-stack-align.h" + +static void * +tf (void *arg) +{ + bool ok = true; + + puts ("in thread"); + + if (TEST_STACK_ALIGN ()) + ok = false; + + return ok ? NULL : (void *) -1l; +} + +static int +do_test (void) +{ + bool ok = true; + + puts ("in main"); + + if (TEST_STACK_ALIGN ()) + ok = false; + + pthread_t th; + if (pthread_create (&th, NULL, tf, NULL) != 0) + { + puts ("create failed"); + return 1; + } + + void *res; + if (pthread_join (th, &res) != 0) + { + puts ("join failed"); + return 1; + } + + if (res != NULL) + ok = false; + + return ok ? 0 : 1; +} + + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/nptl/tst-align2.c b/test/nptl/tst-align2.c new file mode 100644 index 000000000..7d8be53da --- /dev/null +++ b/test/nptl/tst-align2.c @@ -0,0 +1,87 @@ +/* Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include "tst-stack-align.h" + +static int +f (void *arg) +{ + bool ok = true; + + if (TEST_STACK_ALIGN ()) + ok = false; + + return ok ? 0 : 1; +} + +static int +do_test (void) +{ + bool ok = true; + + puts ("in main"); + + if (TEST_STACK_ALIGN ()) + ok = false; + +#ifdef __ia64__ + extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base, + size_t __child_stack_size, int __flags, + void *__arg, ...); + char st[256 * 1024]; + pid_t p = __clone2 (f, st, sizeof (st), 0, 0); +#else + char st[128 * 1024]; + pid_t p = clone (f, st + sizeof (st), 0, 0); +#endif + if (p == -1) + { + printf("clone failed: %m\n"); + return 1; + } + + int e; + if (waitpid (p, &e, __WCLONE) != p) + { + puts ("waitpid failed"); + kill (p, SIGKILL); + return 1; + } + if (!WIFEXITED (e)) + { + if (WIFSIGNALED (e)) + printf ("died from signal %s\n", strsignal (WTERMSIG (e))); + else + puts ("did not terminate correctly"); + return 1; + } + if (WEXITSTATUS (e) != 0) + ok = false; + + return ok ? 0 : 1; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/nptl/tst-atfork1.c b/test/nptl/tst-atfork1.c new file mode 100644 index 000000000..b42ab4246 --- /dev/null +++ b/test/nptl/tst-atfork1.c @@ -0,0 +1,121 @@ +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include + + +static int val; + + +static void +prepare1 (void) +{ + val *= 2; +} + +static void +prepare2 (void) +{ + ++val; +} + +static void +parent1 (void) +{ + val += 4; +} + +static void +parent2 (void) +{ + val *= 4; +} + +static void +child1 (void) +{ + val += 8; +} + +static void +child2 (void) +{ + val *= 8; +} + + +static int +do_test (void) +{ + pid_t pid; + int status = 0; + + if (pthread_atfork (prepare1, parent1, child1) != 0) + { + puts ("1st atfork failed"); + exit (1); + } + if (pthread_atfork (prepare2, parent2, child2) != 0) + { + puts ("2nd atfork failed"); + exit (1); + } + + pid = fork (); + if (pid == -1) + { + puts ("fork failed"); + exit (1); + } + + if (pid != 0) + { + /* Parent. */ + if (val != 24) + { + printf ("expected val=%d, got %d\n", 24, val); + exit (1); + } + + if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid) + { + puts ("waitpid failed"); + exit (1); + } + } + else + { + /* Child. */ + if (val != 80) + { + printf ("expected val=%d, got %d\n", 80, val); + exit (2); + } + } + + return status; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/nptl/tst-attr1.c b/test/nptl/tst-attr1.c new file mode 100644 index 000000000..13b62a69d --- /dev/null +++ b/test/nptl/tst-attr1.c @@ -0,0 +1,306 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include + + +int +do_test (void) +{ + int i; + pthread_attr_t a; + + if (pthread_attr_init (&a) != 0) + { + puts ("attr_init failed"); + exit (1); + } + + pthread_mutexattr_t ma; + + if (pthread_mutexattr_init (&ma) != 0) + { + puts ("mutexattr_init failed"); + exit (1); + } + + pthread_rwlockattr_t rwa; + + if (pthread_rwlockattr_init (&rwa) != 0) + { + puts ("rwlockattr_init failed"); + exit (1); + } + + /* XXX Remove if default value is clear. */ + pthread_attr_setinheritsched (&a, PTHREAD_INHERIT_SCHED); + pthread_attr_setschedpolicy (&a, SCHED_OTHER); + pthread_attr_setscope (&a, PTHREAD_SCOPE_SYSTEM); + + for (i = 0; i < 10000; ++i) + { + long int r = random (); + + if (r != PTHREAD_CREATE_DETACHED && r != PTHREAD_CREATE_JOINABLE) + { + int e = pthread_attr_setdetachstate (&a, r); + + if (e == 0) + { + printf ("attr_setdetachstate with value %ld succeeded\n", r); + exit (1); + } + if (e != EINVAL) + { + puts ("attr_setdetachstate didn't return EINVAL"); + exit (1); + } + + int s; + if (pthread_attr_getdetachstate (&a, &s) != 0) + { + puts ("attr_getdetachstate failed"); + exit (1); + } + + if (s != PTHREAD_CREATE_JOINABLE) + { + printf ("\ +detach state changed to %d by invalid setdetachstate call\n", s); + exit (1); + } + } + + if (r != PTHREAD_INHERIT_SCHED && r != PTHREAD_EXPLICIT_SCHED) + { + int e = pthread_attr_setinheritsched (&a, r); + + if (e == 0) + { + printf ("attr_setinheritsched with value %ld succeeded\n", r); + exit (1); + } + if (e != EINVAL) + { + puts ("attr_setinheritsched didn't return EINVAL"); + exit (1); + } + + int s; + if (pthread_attr_getinheritsched (&a, &s) != 0) + { + puts ("attr_getinheritsched failed"); + exit (1); + } + + if (s != PTHREAD_INHERIT_SCHED) + { + printf ("\ +inheritsched changed to %d by invalid setinheritsched call\n", s); + exit (1); + } + } + + if (r != SCHED_OTHER && r != SCHED_RR && r != SCHED_FIFO) + { + int e = pthread_attr_setschedpolicy (&a, r); + + if (e == 0) + { + printf ("attr_setschedpolicy with value %ld succeeded\n", r); + exit (1); + } + if (e != EINVAL) + { + puts ("attr_setschedpolicy didn't return EINVAL"); + exit (1); + } + + int s; + if (pthread_attr_getschedpolicy (&a, &s) != 0) + { + puts ("attr_getschedpolicy failed"); + exit (1); + } + + if (s != SCHED_OTHER) + { + printf ("\ +schedpolicy changed to %d by invalid setschedpolicy call\n", s); + exit (1); + } + } + + if (r != PTHREAD_SCOPE_SYSTEM && r != PTHREAD_SCOPE_PROCESS) + { + int e = pthread_attr_setscope (&a, r); + + if (e == 0) + { + printf ("attr_setscope with value %ld succeeded\n", r); + exit (1); + } + if (e != EINVAL) + { + puts ("attr_setscope didn't return EINVAL"); + exit (1); + } + + int s; + if (pthread_attr_getscope (&a, &s) != 0) + { + puts ("attr_getscope failed"); + exit (1); + } + + if (s != PTHREAD_SCOPE_SYSTEM) + { + printf ("\ +contentionscope changed to %d by invalid setscope call\n", s); + exit (1); + } + } + + if (r != PTHREAD_PROCESS_PRIVATE && r != PTHREAD_PROCESS_SHARED) + { + int e = pthread_mutexattr_setpshared (&ma, r); + + if (e == 0) + { + printf ("mutexattr_setpshared with value %ld succeeded\n", r); + exit (1); + } + if (e != EINVAL) + { + puts ("mutexattr_setpshared didn't return EINVAL"); + exit (1); + } + + int s; + if (pthread_mutexattr_getpshared (&ma, &s) != 0) + { + puts ("mutexattr_getpshared failed"); + exit (1); + } + + if (s != PTHREAD_PROCESS_PRIVATE) + { + printf ("\ +pshared changed to %d by invalid mutexattr_setpshared call\n", s); + exit (1); + } + + e = pthread_rwlockattr_setpshared (&rwa, r); + + if (e == 0) + { + printf ("rwlockattr_setpshared with value %ld succeeded\n", r); + exit (1); + } + if (e != EINVAL) + { + puts ("rwlockattr_setpshared didn't return EINVAL"); + exit (1); + } + + if (pthread_rwlockattr_getpshared (&rwa, &s) != 0) + { + puts ("rwlockattr_getpshared failed"); + exit (1); + } + + if (s != PTHREAD_PROCESS_PRIVATE) + { + printf ("\ +pshared changed to %d by invalid rwlockattr_setpshared call\n", s); + exit (1); + } + } + + if (r != PTHREAD_CANCEL_ENABLE && r != PTHREAD_CANCEL_DISABLE) + { + int e = pthread_setcancelstate (r, NULL); + + if (e == 0) + { + printf ("setcancelstate with value %ld succeeded\n", r); + exit (1); + } + + if (e != EINVAL) + { + puts ("setcancelstate didn't return EINVAL"); + exit (1); + } + + int s; + if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, &s) != 0) + { + puts ("setcancelstate failed for PTHREAD_CANCEL_ENABLE"); + exit (1); + } + + if (s != PTHREAD_CANCEL_ENABLE) + { + puts ("invalid setcancelstate changed state"); + exit (1); + } + } + + if (r != PTHREAD_CANCEL_DEFERRED && r != PTHREAD_CANCEL_ASYNCHRONOUS) + { + int e = pthread_setcanceltype (r, NULL); + + if (e == 0) + { + printf ("setcanceltype with value %ld succeeded\n", r); + exit (1); + } + + if (e != EINVAL) + { + puts ("setcanceltype didn't return EINVAL"); + exit (1); + } + + int s; + if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &s) != 0) + { + puts ("setcanceltype failed for PTHREAD_CANCEL_DEFERRED"); + exit (1); + } + + if (s != PTHREAD_CANCEL_DEFERRED) + { + puts ("invalid setcanceltype changed state"); + exit (1); + } + } + } + + return 0; +} + + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/nptl/tst-attr2.c b/test/nptl/tst-attr2.c new file mode 100644 index 000000000..a60598dd7 --- /dev/null +++ b/test/nptl/tst-attr2.c @@ -0,0 +1,317 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include + + +int +do_test (void) +{ + pthread_attr_t a; + + if (pthread_attr_init (&a) != 0) + { + puts ("attr_init failed"); + exit (1); + } + + /* Check default value of detach state. */ + int s; + if (pthread_attr_getdetachstate (&a, &s) != 0) + { + puts ("1st attr_getdestachstate failed"); + exit (1); + } + if (s != PTHREAD_CREATE_JOINABLE) + { + printf ("\ +default detach state wrong: %d, expected %d (PTHREAD_CREATE_JOINABLE)\n", + s, PTHREAD_CREATE_JOINABLE); + exit (1); + } + + int e = pthread_attr_setdetachstate (&a, PTHREAD_CREATE_DETACHED); + if (e != 0) + { + puts ("1st attr_setdetachstate failed"); + exit (1); + } + if (pthread_attr_getdetachstate (&a, &s) != 0) + { + puts ("2nd attr_getdestachstate failed"); + exit (1); + } + if (s != PTHREAD_CREATE_DETACHED) + { + puts ("PTHREAD_CREATE_DETACHED set, but not given back"); + exit (1); + } + + e = pthread_attr_setdetachstate (&a, PTHREAD_CREATE_JOINABLE); + if (e != 0) + { + puts ("2nd attr_setdetachstate failed"); + exit (1); + } + if (pthread_attr_getdetachstate (&a, &s) != 0) + { + puts ("3rd attr_getdestachstate failed"); + exit (1); + } + if (s != PTHREAD_CREATE_JOINABLE) + { + puts ("PTHREAD_CREATE_JOINABLE set, but not given back"); + exit (1); + } + + + size_t g; + if (pthread_attr_getguardsize (&a, &g) != 0) + { + puts ("1st attr_getguardsize failed"); + exit (1); + } + if (g != (size_t) sysconf (_SC_PAGESIZE)) + { + printf ("default guardsize %zu, expected %ld (PAGESIZE)\n", + g, sysconf (_SC_PAGESIZE)); + exit (1); + } + + e = pthread_attr_setguardsize (&a, 0); + if (e != 0) + { + puts ("1st attr_setguardsize failed"); + exit (1); + } + if (pthread_attr_getguardsize (&a, &g) != 0) + { + puts ("2nd attr_getguardsize failed"); + exit (1); + } + if (g != 0) + { + printf ("guardsize set to zero but %zu returned\n", g); + exit (1); + } + + e = pthread_attr_setguardsize (&a, 1); + if (e != 0) + { + puts ("2nd attr_setguardsize failed"); + exit (1); + } + if (pthread_attr_getguardsize (&a, &g) != 0) + { + puts ("3rd attr_getguardsize failed"); + exit (1); + } + if (g != 1) + { + printf ("guardsize set to 1 but %zu returned\n", g); + exit (1); + } + + + if (pthread_attr_getinheritsched (&a, &s) != 0) + { + puts ("1st attr_getinheritsched failed"); + exit (1); + } + /* XXX What is the correct default value. */ + if (s != PTHREAD_INHERIT_SCHED && s != PTHREAD_EXPLICIT_SCHED) + { + puts ("incorrect default value for inheritsched"); + exit (1); + } + + e = pthread_attr_setinheritsched (&a, PTHREAD_EXPLICIT_SCHED); + if (e != 0) + { + puts ("1st attr_setinheritsched failed"); + exit (1); + } + if (pthread_attr_getinheritsched (&a, &s) != 0) + { + puts ("2nd attr_getinheritsched failed"); + exit (1); + } + if (s != PTHREAD_EXPLICIT_SCHED) + { + printf ("inheritsched set to PTHREAD_EXPLICIT_SCHED, but got %d\n", s); + exit (1); + } + + e = pthread_attr_setinheritsched (&a, PTHREAD_INHERIT_SCHED); + if (e != 0) + { + puts ("2nd attr_setinheritsched failed"); + exit (1); + } + if (pthread_attr_getinheritsched (&a, &s) != 0) + { + puts ("3rd attr_getinheritsched failed"); + exit (1); + } + if (s != PTHREAD_INHERIT_SCHED) + { + printf ("inheritsched set to PTHREAD_INHERIT_SCHED, but got %d\n", s); + exit (1); + } + + + if (pthread_attr_getschedpolicy (&a, &s) != 0) + { + puts ("1st attr_getschedpolicy failed"); + exit (1); + } + /* XXX What is the correct default value. */ + if (s != SCHED_OTHER && s != SCHED_FIFO && s != SCHED_RR) + { + puts ("incorrect default value for schedpolicy"); + exit (1); + } + + e = pthread_attr_setschedpolicy (&a, SCHED_RR); + if (e != 0) + { + puts ("1st attr_setschedpolicy failed"); + exit (1); + } + if (pthread_attr_getschedpolicy (&a, &s) != 0) + { + puts ("2nd attr_getschedpolicy failed"); + exit (1); + } + if (s != SCHED_RR) + { + printf ("schedpolicy set to SCHED_RR, but got %d\n", s); + exit (1); + } + + e = pthread_attr_setschedpolicy (&a, SCHED_FIFO); + if (e != 0) + { + puts ("2nd attr_setschedpolicy failed"); + exit (1); + } + if (pthread_attr_getschedpolicy (&a, &s) != 0) + { + puts ("3rd attr_getschedpolicy failed"); + exit (1); + } + if (s != SCHED_FIFO) + { + printf ("schedpolicy set to SCHED_FIFO, but got %d\n", s); + exit (1); + } + + e = pthread_attr_setschedpolicy (&a, SCHED_OTHER); + if (e != 0) + { + puts ("3rd attr_setschedpolicy failed"); + exit (1); + } + if (pthread_attr_getschedpolicy (&a, &s) != 0) + { + puts ("4th attr_getschedpolicy failed"); + exit (1); + } + if (s != SCHED_OTHER) + { + printf ("schedpolicy set to SCHED_OTHER, but got %d\n", s); + exit (1); + } + + + if (pthread_attr_getscope (&a, &s) != 0) + { + puts ("1st attr_getscope failed"); + exit (1); + } + /* XXX What is the correct default value. */ + if (s != PTHREAD_SCOPE_SYSTEM && s != PTHREAD_SCOPE_PROCESS) + { + puts ("incorrect default value for contentionscope"); + exit (1); + } + + e = pthread_attr_setscope (&a, PTHREAD_SCOPE_PROCESS); + if (e != ENOTSUP) + { + if (e != 0) + { + puts ("1st attr_setscope failed"); + exit (1); + } + if (pthread_attr_getscope (&a, &s) != 0) + { + puts ("2nd attr_getscope failed"); + exit (1); + } + if (s != PTHREAD_SCOPE_PROCESS) + { + printf ("\ +contentionscope set to PTHREAD_SCOPE_PROCESS, but got %d\n", s); + exit (1); + } + } + + e = pthread_attr_setscope (&a, PTHREAD_SCOPE_SYSTEM); + if (e != 0) + { + puts ("2nd attr_setscope failed"); + exit (1); + } + if (pthread_attr_getscope (&a, &s) != 0) + { + puts ("3rd attr_getscope failed"); + exit (1); + } + if (s != PTHREAD_SCOPE_SYSTEM) + { + printf ("contentionscope set to PTHREAD_SCOPE_SYSTEM, but got %d\n", s); + exit (1); + } + + char buf[1]; + e = pthread_attr_setstack (&a, buf, 1); + if (e != EINVAL) + { + puts ("setstack with size 1 did not produce EINVAL"); + exit (1); + } + + e = pthread_attr_setstacksize (&a, 1); + if (e != EINVAL) + { + puts ("setstacksize with size 1 did not produce EINVAL"); + exit (1); + } + + return 0; +} + + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/nptl/tst-attr3.c b/test/nptl/tst-attr3.c new file mode 100644 index 000000000..29b4bbe37 --- /dev/null +++ b/test/nptl/tst-attr3.c @@ -0,0 +1,420 @@ +/* pthread_getattr_np test. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include +#include + +static void * +tf (void *arg) +{ + pthread_attr_t a, *ap, a2; + int err; + void *result = NULL; + + if (arg == NULL) + { + ap = &a2; + err = pthread_attr_init (ap); + if (err) + { + error (0, err, "pthread_attr_init failed"); + return tf; + } + } + else + ap = (pthread_attr_t *) arg; + + err = pthread_getattr_np (pthread_self (), &a); + if (err) + { + error (0, err, "pthread_getattr_np failed"); + result = tf; + } + + int detachstate1, detachstate2; + err = pthread_attr_getdetachstate (&a, &detachstate1); + if (err) + { + error (0, err, "pthread_attr_getdetachstate failed"); + result = tf; + } + else + { + err = pthread_attr_getdetachstate (ap, &detachstate2); + if (err) + { + error (0, err, "pthread_attr_getdetachstate failed"); + result = tf; + } + else if (detachstate1 != detachstate2) + { + error (0, 0, "detachstate differs %d != %d", + detachstate1, detachstate2); + result = tf; + } + } + + void *stackaddr; + size_t stacksize; + err = pthread_attr_getstack (&a, &stackaddr, &stacksize); + if (err) + { + error (0, err, "pthread_attr_getstack failed"); + result = tf; + } + else if ((void *) &a < stackaddr + || (void *) &a >= stackaddr + stacksize) + { + error (0, 0, "pthread_attr_getstack returned range does not cover thread's stack"); + result = tf; + } + else + printf ("thread stack %p-%p (0x%zx)\n", stackaddr, stackaddr + stacksize, + stacksize); + + size_t guardsize1, guardsize2; + err = pthread_attr_getguardsize (&a, &guardsize1); + if (err) + { + error (0, err, "pthread_attr_getguardsize failed"); + result = tf; + } + else + { + err = pthread_attr_getguardsize (ap, &guardsize2); + if (err) + { + error (0, err, "pthread_attr_getguardsize failed"); + result = tf; + } + else if (guardsize1 != guardsize2) + { + error (0, 0, "guardsize differs %zd != %zd", + guardsize1, guardsize2); + result = tf; + } + else + printf ("thread guardsize %zd\n", guardsize1); + } + + int scope1, scope2; + err = pthread_attr_getscope (&a, &scope1); + if (err) + { + error (0, err, "pthread_attr_getscope failed"); + result = tf; + } + else + { + err = pthread_attr_getscope (ap, &scope2); + if (err) + { + error (0, err, "pthread_attr_getscope failed"); + result = tf; + } + else if (scope1 != scope2) + { + error (0, 0, "scope differs %d != %d", + scope1, scope2); + result = tf; + } + } + + int inheritsched1, inheritsched2; + err = pthread_attr_getinheritsched (&a, &inheritsched1); + if (err) + { + error (0, err, "pthread_attr_getinheritsched failed"); + result = tf; + } + else + { + err = pthread_attr_getinheritsched (ap, &inheritsched2); + if (err) + { + error (0, err, "pthread_attr_getinheritsched failed"); + result = tf; + } + else if (inheritsched1 != inheritsched2) + { + error (0, 0, "inheritsched differs %d != %d", + inheritsched1, inheritsched2); + result = tf; + } + } + + cpu_set_t c1, c2; + err = pthread_getaffinity_np (pthread_self (), sizeof (c1), &c1); + if (err == 0) + { + err = pthread_attr_getaffinity_np (&a, sizeof (c2), &c2); + if (err) + { + error (0, err, "pthread_attr_getaffinity_np failed"); + result = tf; + } + else if (memcmp (&c1, &c2, sizeof (c1))) + { + error (0, 0, "pthread_attr_getaffinity_np returned different CPU mask than pthread_getattr_np"); + result = tf; + } + } + + err = pthread_attr_destroy (&a); + if (err) + { + error (0, err, "pthread_attr_destroy failed"); + result = tf; + } + + if (ap == &a2) + { + err = pthread_attr_destroy (ap); + if (err) + { + error (0, err, "pthread_attr_destroy failed"); + result = tf; + } + } + + return result; +} + + +static int +do_test (void) +{ + int result = 0; + pthread_attr_t a; + cpu_set_t c1, c2; + + int err = pthread_attr_init (&a); + if (err) + { + error (0, err, "pthread_attr_init failed"); + result = 1; + } + + err = pthread_attr_getaffinity_np (&a, sizeof (c1), &c1); + if (err && err != ENOSYS) + { + error (0, err, "pthread_attr_getaffinity_np failed"); + result = 1; + } + + err = pthread_attr_destroy (&a); + if (err) + { + error (0, err, "pthread_attr_destroy failed"); + result = 1; + } + + err = pthread_getattr_np (pthread_self (), &a); + if (err) + { + error (0, err, "pthread_getattr_np failed"); + result = 1; + } + + int detachstate; + err = pthread_attr_getdetachstate (&a, &detachstate); + if (err) + { + error (0, err, "pthread_attr_getdetachstate failed"); + result = 1; + } + else if (detachstate != PTHREAD_CREATE_JOINABLE) + { + error (0, 0, "initial thread not joinable"); + result = 1; + } + + void *stackaddr; + size_t stacksize; + err = pthread_attr_getstack (&a, &stackaddr, &stacksize); + if (err) + { + error (0, err, "pthread_attr_getstack failed"); + result = 1; + } + else if ((void *) &a < stackaddr + || (void *) &a >= stackaddr + stacksize) + { + error (0, 0, "pthread_attr_getstack returned range does not cover main's stack"); + result = 1; + } + else + printf ("initial thread stack %p-%p (0x%zx)\n", stackaddr, + stackaddr + stacksize, stacksize); + + size_t guardsize; + err = pthread_attr_getguardsize (&a, &guardsize); + if (err) + { + error (0, err, "pthread_attr_getguardsize failed"); + result = 1; + } + else if (guardsize != 0) + { + error (0, 0, "pthread_attr_getguardsize returned %zd != 0", + guardsize); + result = 1; + } + + int scope; + err = pthread_attr_getscope (&a, &scope); + if (err) + { + error (0, err, "pthread_attr_getscope failed"); + result = 1; + } + else if (scope != PTHREAD_SCOPE_SYSTEM) + { + error (0, 0, "pthread_attr_getscope returned %d != PTHREAD_SCOPE_SYSTEM", + scope); + result = 1; + } + + int inheritsched; + err = pthread_attr_getinheritsched (&a, &inheritsched); + if (err) + { + error (0, err, "pthread_attr_getinheritsched failed"); + result = 1; + } + else if (inheritsched != PTHREAD_INHERIT_SCHED) + { + error (0, 0, "pthread_attr_getinheritsched returned %d != PTHREAD_INHERIT_SCHED", + inheritsched); + result = 1; + } + + err = pthread_getaffinity_np (pthread_self (), sizeof (c1), &c1); + if (err == 0) + { + err = pthread_attr_getaffinity_np (&a, sizeof (c2), &c2); + if (err) + { + error (0, err, "pthread_attr_getaffinity_np failed"); + result = 1; + } + else if (memcmp (&c1, &c2, sizeof (c1))) + { + error (0, 0, "pthread_attr_getaffinity_np returned different CPU mask than pthread_getattr_np"); + result = 1; + } + } + + err = pthread_attr_destroy (&a); + if (err) + { + error (0, err, "pthread_attr_destroy failed"); + result = 1; + } + + pthread_t th; + err = pthread_create (&th, NULL, tf, NULL); + if (err) + { + error (0, err, "pthread_create #1 failed"); + result = 1; + } + else + { + void *ret; + err = pthread_join (th, &ret); + if (err) + { + error (0, err, "pthread_join #1 failed"); + result = 1; + } + else if (ret != NULL) + result = 1; + } + + err = pthread_attr_init (&a); + if (err) + { + error (0, err, "pthread_attr_init failed"); + result = 1; + } + + err = pthread_create (&th, &a, tf, &a); + if (err) + { + error (0, err, "pthread_create #2 failed"); + result = 1; + } + else + { + void *ret; + err = pthread_join (th, &ret); + if (err) + { + error (0, err, "pthread_join #2 failed"); + result = 1; + } + else if (ret != NULL) + result = 1; + } + + err = pthread_attr_setguardsize (&a, 16 * sysconf (_SC_PAGESIZE)); + if (err) + { + error (0, err, "pthread_attr_setguardsize failed"); + result = 1; + } + + err = pthread_create (&th, &a, tf, &a); + if (err) + { + error (0, err, "pthread_create #3 failed"); + result = 1; + } + else + { + void *ret; + err = pthread_join (th, &ret); + if (err) + { + error (0, err, "pthread_join #3 failed"); + result = 1; + } + else if (ret != NULL) + result = 1; + } + + err = pthread_attr_destroy (&a); + if (err) + { + error (0, err, "pthread_attr_destroy failed"); + result = 1; + } + + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/nptl/tst-barrier1.c b/test/nptl/tst-barrier1.c new file mode 100644 index 000000000..2859fb4ca --- /dev/null +++ b/test/nptl/tst-barrier1.c @@ -0,0 +1,71 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + + +static int +do_test (void) +{ + pthread_barrier_t b; + int e; + int cnt; + + e = pthread_barrier_init (&b, NULL, 0); + if (e == 0) + { + puts ("barrier_init with count 0 succeeded"); + return 1; + } + if (e != EINVAL) + { + puts ("barrier_init with count 0 didn't return EINVAL"); + return 1; + } + + if (pthread_barrier_init (&b, NULL, 1) != 0) + { + puts ("real barrier_init failed"); + return 1; + } + + for (cnt = 0; cnt < 10; ++cnt) + { + e = pthread_barrier_wait (&b); + + if (e != PTHREAD_BARRIER_SERIAL_THREAD) + { + puts ("barrier_wait didn't return PTHREAD_BARRIER_SERIAL_THREAD"); + return 1; + } + } + + if (pthread_barrier_destroy (&b) != 0) + { + puts ("barrier_destroy failed"); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/nptl/tst-barrier2.c b/test/nptl/tst-barrier2.c new file mode 100644 index 000000000..7f588694d --- /dev/null +++ b/test/nptl/tst-barrier2.c @@ -0,0 +1,185 @@ +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static int +do_test (void) +{ + size_t ps = sysconf (_SC_PAGESIZE); + char tmpfname[] = "/tmp/tst-barrier2.XXXXXX"; + char data[ps]; + void *mem; + int fd; + pthread_barrier_t *b; + pthread_barrierattr_t a; + pid_t pid; + int serials = 0; + int cnt; + int status; + int p; + + fd = mkstemp (tmpfname); + if (fd == -1) + { + printf ("cannot open temporary file: %m\n"); + return 1; + } + + /* Make sure it is always removed. */ + unlink (tmpfname); + + /* Create one page of data. */ + memset (data, '\0', ps); + + /* Write the data to the file. */ + if (write (fd, data, ps) != (ssize_t) ps) + { + puts ("short write"); + return 1; + } + + mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (mem == MAP_FAILED) + { + printf ("mmap failed: %m\n"); + return 1; + } + + b = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t)) + & ~(__alignof (pthread_barrier_t) - 1)); + + if (pthread_barrierattr_init (&a) != 0) + { + puts ("barrierattr_init failed"); + return 1; + } + + if (pthread_barrierattr_getpshared (&a, &p) != 0) + { + puts ("1st barrierattr_getpshared failed"); + return 1; + } + + if (p != PTHREAD_PROCESS_PRIVATE) + { + puts ("default pshared value wrong"); + return 1; + } + + if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0) + { + puts ("barrierattr_setpshared failed"); + return 1; + } + + if (pthread_barrierattr_getpshared (&a, &p) != 0) + { + puts ("2nd barrierattr_getpshared failed"); + return 1; + } + + if (p != PTHREAD_PROCESS_SHARED) + { + puts ("pshared value after setpshared call wrong"); + return 1; + } + + if (pthread_barrier_init (b, &a, 2) != 0) + { + puts ("barrier_init failed"); + return 1; + } + + if (pthread_barrierattr_destroy (&a) != 0) + { + puts ("barrierattr_destroy failed"); + return 1; + } + + puts ("going to fork now"); + pid = fork (); + if (pid == -1) + { + puts ("fork failed"); + return 1; + } + + /* Just to be sure we don't hang forever. */ + alarm (4); + +#define N 30 + for (cnt = 0; cnt < N; ++cnt) + { + int e; + + e = pthread_barrier_wait (b); + if (e == PTHREAD_BARRIER_SERIAL_THREAD) + ++serials; + else if (e != 0) + { + printf ("%s: barrier_wait returned value %d != 0 and PTHREAD_BARRIER_SERIAL_THREAD\n", + pid == 0 ? "child" : "parent", e); + return 1; + } + } + + alarm (0); + + printf ("%s: was %d times the serial thread\n", + pid == 0 ? "child" : "parent", serials); + + if (pid == 0) + /* The child. Pass the number of times we had the serializing + thread back to the parent. */ + exit (serials); + + if (waitpid (pid, &status, 0) != pid) + { + puts ("waitpid failed"); + return 1; + } + + if (!WIFEXITED (status)) + { + puts ("child exited abnormally"); + return 1; + } + + if (WEXITSTATUS (status) + serials != N) + { + printf ("total number of serials is %d, expected %d\n", + WEXITSTATUS (status) + serials, N); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/nptl/tst-barrier3.c b/test/nptl/tst-barrier3.c new file mode 100644 index 000000000..b5478f827 --- /dev/null +++ b/test/nptl/tst-barrier3.c @@ -0,0 +1,154 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Test of POSIX barriers. */ + +#include +#include +#include +#include + +#define NTHREADS 20 + +#define ROUNDS 20 + +static pthread_barrier_t barriers[NTHREADS]; + +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; +static int counters[NTHREADS]; +static int serial[NTHREADS]; + +static void * +worker (void *arg) +{ + void *result = NULL; + int nr = (long int) arg; + int i; + + for (i = 0; i < ROUNDS; ++i) + { + int j; + int retval; + + if (nr == 0) + { + memset (counters, '\0', sizeof (counters)); + memset (serial, '\0', sizeof (serial)); + } + + retval = pthread_barrier_wait (&barriers[NTHREADS - 1]); + if (retval != 0 && retval != PTHREAD_BARRIER_SERIAL_THREAD) + { + printf ("thread %d failed to wait for all the others\n", nr); + result = (void *) 1; + } + + for (j = nr; j < NTHREADS; ++j) + { + /* Increment the counter for this round. */ + pthread_mutex_lock (&lock); + ++counters[j]; + pthread_mutex_unlock (&lock); + + /* Wait for the rest. */ + retval = pthread_barrier_wait (&barriers[j]); + + /* Te