• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) International Business Machines  Corp., 2001
3  *  07/2001 Ported by Wayne Boyer
4  * Copyright (C) 2015-2017 Cyril Hrubis <chrubis@suse.cz>
5  *
6  * This program is free software;  you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program;  if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * Test Description:
23  *  nanosleep() should return with value 0 and the process should be
24  *  suspended for time specified by timespec structure.
25  */
26 
27 #include <errno.h>
28 
29 #include "tst_timer_test.h"
30 
sample_fn(int clk_id,long long usec)31 int sample_fn(int clk_id, long long usec)
32 {
33 	struct timespec t = tst_us_to_timespec(usec);
34 
35 	tst_timer_start(clk_id);
36 	TEST(nanosleep(&t, NULL));
37 	tst_timer_stop();
38 	tst_timer_sample();
39 
40 	if (TST_RET != 0) {
41 		tst_res(TFAIL | TERRNO,
42 			"nanosleep() returned %li", TST_RET);
43 		return 1;
44 	}
45 
46 	return 0;
47 }
48 
49 static struct tst_test test = {
50 	.scall = "nanosleep()",
51 	.sample = sample_fn,
52 };
53