1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (C) 2017 Cyril Hrubis <chrubis@suse.cz> 4 */ 5 6 /* 7 * Test Description: 8 * clock_nanosleep() should return with value 0 and the process should be 9 * suspended for time specified by timespec structure. 10 */ 11 12 #include <errno.h> 13 #include "tst_timer_test.h" 14 sample_fn(int clk_id,long long usec)15int sample_fn(int clk_id, long long usec) 16 { 17 struct timespec t = tst_timespec_from_us(usec); 18 19 tst_timer_start(clk_id); 20 TEST(clock_nanosleep(clk_id, 0, &t, NULL)); 21 tst_timer_stop(); 22 tst_timer_sample(); 23 24 if (TST_RET != 0) { 25 tst_res(TFAIL | TTERRNO, 26 "nanosleep() returned %li", TST_RET); 27 return 1; 28 } 29 30 return 0; 31 } 32 33 static struct tst_test test = { 34 .scall = "clock_nanosleep()", 35 .sample = sample_fn, 36 }; 37