summaryrefslogtreecommitdiff
path: root/libc/rt/tst-cpuclock1.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/rt/tst-cpuclock1.c')
-rw-r--r--libc/rt/tst-cpuclock1.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/libc/rt/tst-cpuclock1.c b/libc/rt/tst-cpuclock1.c
index 024df6314..edc04761f 100644
--- a/libc/rt/tst-cpuclock1.c
+++ b/libc/rt/tst-cpuclock1.c
@@ -1,5 +1,5 @@
/* Test program for process CPU clocks.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -13,9 +13,8 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
@@ -131,11 +130,17 @@ do_test (void)
result = 1;
goto done;
}
+ /* Should be close to 0.0. */
printf ("live PID %d before sleep => %lu.%.9lu\n",
child, before.tv_sec, before.tv_nsec);
struct timespec sleeptime = { .tv_nsec = 500000000 };
- nanosleep (&sleeptime, NULL);
+ if (nanosleep (&sleeptime, NULL) != 0)
+ {
+ perror ("nanosleep");
+ result = 1;
+ goto done;
+ }
if (clock_gettime (child_clock, &after) < 0)
{
@@ -144,6 +149,7 @@ do_test (void)
result = 1;
goto done;
}
+ /* Should be close to 0.5. */
printf ("live PID %d after sleep => %lu.%.9lu\n",
child, after.tv_sec, after.tv_nsec);
@@ -214,7 +220,12 @@ do_test (void)
/* Wait long enough to let the child finish dying. */
sleeptime.tv_nsec = 200000000;
- nanosleep (&sleeptime, NULL);
+ if (nanosleep (&sleeptime, NULL) != 0)
+ {
+ perror ("nanosleep");
+ result = 1;
+ goto done;
+ }
struct timespec dead;
if (clock_gettime (child_clock, &dead) < 0)
@@ -224,6 +235,7 @@ do_test (void)
result = 1;
goto done;
}
+ /* Should be close to 0.6. */
printf ("dead PID %d => %lu.%.9lu\n",
child, dead.tv_sec, dead.tv_nsec);