1 /* Test unsupported/bad clocks passed to pthread_mutex_clocklock.
3 Copyright (C) 2019-2024 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>
27 static pthread_mutex_t mut
= PTHREAD_MUTEX_INITIALIZER
;
29 static void test_bad_clockid (clockid_t clockid
)
31 const struct timespec ts
= {0,0};
32 TEST_COMPARE (pthread_mutex_clocklock (&mut
, clockid
, &ts
), EINVAL
);
35 #define NOT_A_VALID_CLOCK 123456
40 /* These clocks are meaningless to pthread_mutex_clocklock. */
41 #if defined(CLOCK_PROCESS_CPUTIME_ID)
42 test_bad_clockid (CLOCK_PROCESS_CPUTIME_ID
);
44 #if defined(CLOCK_THREAD_CPUTIME_ID)
45 test_bad_clockid (CLOCK_PROCESS_CPUTIME_ID
);
48 /* These clocks might be meaningful, but are currently unsupported by
49 pthread_mutex_clocklock. */
50 #if defined(CLOCK_REALTIME_COARSE)
51 test_bad_clockid (CLOCK_REALTIME_COARSE
);
53 #if defined(CLOCK_MONOTONIC_RAW)
54 test_bad_clockid (CLOCK_MONOTONIC_RAW
);
56 #if defined(CLOCK_MONOTONIC_COARSE)
57 test_bad_clockid (CLOCK_MONOTONIC_COARSE
);
59 #if defined(CLOCK_BOOTTIME)
60 test_bad_clockid (CLOCK_BOOTTIME
);
63 /* This is a completely invalid clock. */
64 test_bad_clockid (NOT_A_VALID_CLOCK
);
69 #include <support/test-driver.c>