1 /* Test unsupported/bad clocks passed to pthread_cond_clockwait.
3 Copyright (C) 2019-2023 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
25 #include <support/check.h>
26 #include <support/timespec.h>
27 #include <support/xthread.h>
29 static pthread_cond_t cond
= PTHREAD_COND_INITIALIZER
;
30 static pthread_mutex_t mut
= PTHREAD_MUTEX_INITIALIZER
;
32 #define NOT_A_VALID_CLOCK 123456
37 xpthread_mutex_lock (&mut
);
39 const struct timespec ts
= make_timespec (0, 0);
41 /* These clocks are meaningless to sem_clockwait. */
42 #if defined(CLOCK_PROCESS_CPUTIME_ID)
43 TEST_COMPARE (pthread_cond_clockwait (&cond
, &mut
,
44 CLOCK_PROCESS_CPUTIME_ID
, &ts
), EINVAL
);
46 #if defined(CLOCK_THREAD_CPUTIME_ID)
47 TEST_COMPARE (pthread_cond_clockwait (&cond
, &mut
,
48 CLOCK_THREAD_CPUTIME_ID
, &ts
), EINVAL
);
51 /* These clocks might be meaningful, but are currently unsupported
52 by pthread_cond_clockwait. */
53 #if defined(CLOCK_REALTIME_COARSE)
54 TEST_COMPARE (pthread_cond_clockwait (&cond
, &mut
,
55 CLOCK_REALTIME_COARSE
, &ts
), EINVAL
);
57 #if defined(CLOCK_MONOTONIC_RAW)
58 TEST_COMPARE (pthread_cond_clockwait (&cond
, &mut
,
59 CLOCK_MONOTONIC_RAW
, &ts
), EINVAL
);
61 #if defined(CLOCK_MONOTONIC_COARSE)
62 TEST_COMPARE (pthread_cond_clockwait (&cond
, &mut
,
63 CLOCK_MONOTONIC_COARSE
, &ts
), EINVAL
);
65 #if defined(CLOCK_BOOTTIME)
66 TEST_COMPARE (pthread_cond_clockwait (&cond
, &mut
,
67 CLOCK_BOOTTIME
, &ts
), EINVAL
);
70 /* This is a completely invalid clock. */
71 TEST_COMPARE (pthread_cond_clockwait (&cond
, &mut
,
72 NOT_A_VALID_CLOCK
, &ts
), EINVAL
);
77 #include <support/test-driver.c>