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