• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * Test Description:
10  *  nanosleep() should return with value 0 and the process should be
11  *  suspended for time specified by timespec structure.
12  */
13 
14 #include <errno.h>
15 #include "tst_timer_test.h"
16 
sample_fn(int clk_id,long long usec)17 int sample_fn(int clk_id, long long usec)
18 {
19 	struct timespec t = tst_timespec_from_us(usec);
20 
21 	tst_timer_start(clk_id);
22 	TEST(nanosleep(&t, NULL));
23 	tst_timer_stop();
24 	tst_timer_sample();
25 
26 	if (TST_RET != 0) {
27 		tst_res(TFAIL | TTERRNO,
28 			"nanosleep() returned %li", TST_RET);
29 		return 1;
30 	}
31 
32 	return 0;
33 }
34 
35 static struct tst_test test = {
36 	.scall = "nanosleep()",
37 	.sample = sample_fn,
38 };
39