From: Bruno Haible Date: Mon, 15 Jul 2019 00:36:16 +0000 (+0200) Subject: pthread-h: Add tests. X-Git-Tag: v1.0~4756 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=30e64672a7ac497ad0e4c0b8c25890844bbe46e1;p=gnulib.git pthread-h: Add tests. * tests/test-pthread.c: New file. * modules/pthread-h-tests: New file. --- diff --git a/ChangeLog b/ChangeLog index bab6808e18..3932992e55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-07-14 Bruno Haible + + pthread-h: Add tests. + * tests/test-pthread.c: New file. + * modules/pthread-h-tests: New file. + 2019-07-14 Bruno Haible pthread-h: New module. diff --git a/modules/pthread-h-tests b/modules/pthread-h-tests new file mode 100644 index 0000000000..13fd05b3a0 --- /dev/null +++ b/modules/pthread-h-tests @@ -0,0 +1,12 @@ +Files: +tests/test-pthread.c + +Depends-on: +verify +pthread-h-c++-tests + +configure.ac: + +Makefile.am: +TESTS += test-pthread +check_PROGRAMS += test-pthread diff --git a/tests/test-pthread.c b/tests/test-pthread.c new file mode 100644 index 0000000000..48ec65c977 --- /dev/null +++ b/tests/test-pthread.c @@ -0,0 +1,90 @@ +/* Test of substitute. + Copyright (C) 2019 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +#include + +#include "verify.h" + +/* Check that the types are all defined. */ + +pthread_t t1; +pthread_attr_t t2; + +pthread_once_t t3 = PTHREAD_ONCE_INIT; + +pthread_mutex_t t4 = PTHREAD_MUTEX_INITIALIZER; +pthread_mutexattr_t t5; + +pthread_rwlock_t t6 = PTHREAD_RWLOCK_INITIALIZER; +pthread_rwlockattr_t t7; + +pthread_cond_t t8 = PTHREAD_COND_INITIALIZER; +pthread_condattr_t t9; + +pthread_key_t t10; + +pthread_spinlock_t t11; + +#ifdef TODO /* Not implemented in gnulib yet */ +pthread_barrier_t t12; +pthread_barrierattr_t t13; +#endif + +/* Check that the various macros are defined. */ + +/* Constants for pthread_attr_setdetachstate(). */ +int ds[] = { PTHREAD_CREATE_JOINABLE, PTHREAD_CREATE_DETACHED }; + +/* Constants for pthread_exit(). */ +void *canceled = PTHREAD_CANCELED; + +/* Constants for pthread_mutexattr_settype(). */ +int mt[] = { + PTHREAD_MUTEX_DEFAULT, + PTHREAD_MUTEX_NORMAL, + PTHREAD_MUTEX_RECURSIVE, + PTHREAD_MUTEX_ERRORCHECK +}; + +#ifdef TODO /* Not implemented in gnulib yet */ + +/* Constants for pthread_mutexattr_setrobust(). */ +int mr[] = { PTHREAD_MUTEX_ROBUST, PTHREAD_MUTEX_STALLED }; + +/* Constants for pthread_barrierattr_setpshared(). */ +int bp[] = { PTHREAD_PROCESS_SHARED, PTHREAD_PROCESS_PRIVATE }; + +/* Constants for pthread_barrier_wait(). */ +int bw[] = { PTHREAD_BARRIER_SERIAL_THREAD }; + +/* Constants for pthread_setcancelstate(). */ +int cs[] = { PTHREAD_CANCEL_ENABLE, PTHREAD_CANCEL_DISABLE }; + +/* Constants for pthread_setcanceltype(). */ +int ct[] = { PTHREAD_CANCEL_DEFERRED, PTHREAD_CANCEL_ASYNCHRONOUS }; + +#endif + + +int +main (void) +{ + return 0; +}