blob: 27f197e82a1059de02572ef2933122a4ea6f817c [file] [log] [blame]
Daniel Lezcano596be9b2011-07-26 14:38:59 +02001/*******************************************************************************
Daniel Lezcano35fb1722011-10-03 13:56:11 +02002 * PM-QA validation test suite for the power management on Linux
Daniel Lezcano596be9b2011-07-26 14:38:59 +02003 *
4 * Copyright (C) 2011, Linaro Limited.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (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 the
14 * 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
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 * Contributors:
21 * Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation)
22 * - initial API and implementation
23 *
24 *******************************************************************************/
25#include <stdio.h>
26#include <stdlib.h>
27#include <errno.h>
28#include <time.h>
29
30int main(int argc, char *argv[])
31{
32 struct timespec req = { 0 }, rem = { 0 };
33
34 if (argc != 2) {
35 fprintf(stderr, "%s <nanoseconds>\n", argv[0]);
36 return 1;
37 }
38
39 req.tv_nsec = atoi(argv[1]);
40
41 for (;;) {
42 if (!nanosleep(&req, &rem))
43 break;
44
45 if (errno == EINTR) {
46 req = rem;
47 continue;
48 }
49
50 perror("failed to nanosleep");
51 return 1;
52 }
53
54 return 0;
55}