1 /*
2 * Copyright (C) 2017 Cyril Hrubis <chrubis@suse.cz>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 /*
20 * Test Description:
21 * clock_nanosleep() should return with value 0 and the process should be
22 * suspended for time specified by timespec structure.
23 */
24
25 #include <errno.h>
26 #include "tst_timer_test.h"
27
sample_fn(int clk_id,long long usec)28 int sample_fn(int clk_id, long long usec)
29 {
30 struct timespec t = tst_us_to_timespec(usec);
31
32 tst_timer_start(clk_id);
33 TEST(clock_nanosleep(clk_id, 0, &t, NULL));
34 tst_timer_stop();
35 tst_timer_sample();
36
37 if (TST_RET != 0) {
38 tst_res(TFAIL | TERRNO,
39 "nanosleep() returned %li", TST_RET);
40 return 1;
41 }
42
43 return 0;
44 }
45
46 static struct tst_test test = {
47 .scall = "clock_nanosleep()",
48 .sample = sample_fn,
49 };
50