mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
A bit of testsuite cleanup.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2012-02-10 Thomas Schwinge <thomas@codesourcery.com>
|
||||||
|
|
||||||
|
* rt/tst-cpuclock1.c: Add a few comments, and error checking for
|
||||||
|
nanosleep invocations.
|
||||||
|
* rt/tst-cpuclock2.c: Print some values as intended, fix explanatory
|
||||||
|
strings, and add error checking for a nanosleep invocations.
|
||||||
|
|
||||||
2012-02-09 Paul Eggert <eggert@cs.ucla.edu>
|
2012-02-09 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
Replace FSF snail mail address with URLs, as per GNU coding standards.
|
Replace FSF snail mail address with URLs, as per GNU coding standards.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* Test program for process CPU clocks.
|
/* 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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@@ -130,11 +130,17 @@ do_test (void)
|
|||||||
result = 1;
|
result = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
/* Should be close to 0.0. */
|
||||||
printf ("live PID %d before sleep => %lu.%.9lu\n",
|
printf ("live PID %d before sleep => %lu.%.9lu\n",
|
||||||
child, before.tv_sec, before.tv_nsec);
|
child, before.tv_sec, before.tv_nsec);
|
||||||
|
|
||||||
struct timespec sleeptime = { .tv_nsec = 500000000 };
|
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)
|
if (clock_gettime (child_clock, &after) < 0)
|
||||||
{
|
{
|
||||||
@@ -143,6 +149,7 @@ do_test (void)
|
|||||||
result = 1;
|
result = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
/* Should be close to 0.5. */
|
||||||
printf ("live PID %d after sleep => %lu.%.9lu\n",
|
printf ("live PID %d after sleep => %lu.%.9lu\n",
|
||||||
child, after.tv_sec, after.tv_nsec);
|
child, after.tv_sec, after.tv_nsec);
|
||||||
|
|
||||||
@@ -213,7 +220,12 @@ do_test (void)
|
|||||||
/* Wait long enough to let the child finish dying. */
|
/* Wait long enough to let the child finish dying. */
|
||||||
|
|
||||||
sleeptime.tv_nsec = 200000000;
|
sleeptime.tv_nsec = 200000000;
|
||||||
nanosleep (&sleeptime, NULL);
|
if (nanosleep (&sleeptime, NULL) != 0)
|
||||||
|
{
|
||||||
|
perror ("nanosleep");
|
||||||
|
result = 1;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
struct timespec dead;
|
struct timespec dead;
|
||||||
if (clock_gettime (child_clock, &dead) < 0)
|
if (clock_gettime (child_clock, &dead) < 0)
|
||||||
@@ -223,6 +235,7 @@ do_test (void)
|
|||||||
result = 1;
|
result = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
/* Should be close to 0.6. */
|
||||||
printf ("dead PID %d => %lu.%.9lu\n",
|
printf ("dead PID %d => %lu.%.9lu\n",
|
||||||
child, dead.tv_sec, dead.tv_nsec);
|
child, dead.tv_sec, dead.tv_nsec);
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* Test program for process and thread CPU clocks.
|
/* Test program for process and thread CPU clocks.
|
||||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
Copyright (C) 2005, 2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@@ -216,7 +216,7 @@ do_test (void)
|
|||||||
struct timespec res;
|
struct timespec res;
|
||||||
if (clock_getres (th_clock, &res) < 0)
|
if (clock_getres (th_clock, &res) < 0)
|
||||||
{
|
{
|
||||||
printf ("clock_getres on thread clock %lx => %s\n",
|
printf ("clock_getres on live thread clock %lx => %s\n",
|
||||||
(unsigned long int) th_clock, strerror (errno));
|
(unsigned long int) th_clock, strerror (errno));
|
||||||
result = 1;
|
result = 1;
|
||||||
return 1;
|
return 1;
|
||||||
@@ -228,7 +228,7 @@ do_test (void)
|
|||||||
if (clock_gettime (process_clock, &process_before) < 0)
|
if (clock_gettime (process_clock, &process_before) < 0)
|
||||||
{
|
{
|
||||||
printf ("clock_gettime on process clock %lx => %s\n",
|
printf ("clock_gettime on process clock %lx => %s\n",
|
||||||
(unsigned long int) th_clock, strerror (errno));
|
(unsigned long int) process_clock, strerror (errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,15 +245,19 @@ do_test (void)
|
|||||||
struct timespec me_before, me_after;
|
struct timespec me_before, me_after;
|
||||||
if (clock_gettime (my_thread_clock, &me_before) < 0)
|
if (clock_gettime (my_thread_clock, &me_before) < 0)
|
||||||
{
|
{
|
||||||
printf ("clock_gettime on live thread clock %lx => %s\n",
|
printf ("clock_gettime on self thread clock %lx => %s\n",
|
||||||
(unsigned long int) th_clock, strerror (errno));
|
(unsigned long int) my_thread_clock, strerror (errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
printf ("self thread before sleep => %lu.%.9lu\n",
|
printf ("self thread before sleep => %lu.%.9lu\n",
|
||||||
me_before.tv_sec, me_before.tv_nsec);
|
me_before.tv_sec, me_before.tv_nsec);
|
||||||
|
|
||||||
struct timespec sleeptime = { .tv_nsec = 500000000 };
|
struct timespec sleeptime = { .tv_nsec = 500000000 };
|
||||||
nanosleep (&sleeptime, NULL);
|
if (nanosleep (&sleeptime, NULL) != 0)
|
||||||
|
{
|
||||||
|
perror ("nanosleep");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (clock_gettime (th_clock, &after) < 0)
|
if (clock_gettime (th_clock, &after) < 0)
|
||||||
{
|
{
|
||||||
@@ -267,14 +271,14 @@ do_test (void)
|
|||||||
if (clock_gettime (process_clock, &process_after) < 0)
|
if (clock_gettime (process_clock, &process_after) < 0)
|
||||||
{
|
{
|
||||||
printf ("clock_gettime on process clock %lx => %s\n",
|
printf ("clock_gettime on process clock %lx => %s\n",
|
||||||
(unsigned long int) th_clock, strerror (errno));
|
(unsigned long int) process_clock, strerror (errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clock_gettime (my_thread_clock, &me_after) < 0)
|
if (clock_gettime (my_thread_clock, &me_after) < 0)
|
||||||
{
|
{
|
||||||
printf ("clock_gettime on live thread clock %lx => %s\n",
|
printf ("clock_gettime on self thread clock %lx => %s\n",
|
||||||
(unsigned long int) th_clock, strerror (errno));
|
(unsigned long int) my_thread_clock, strerror (errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
printf ("self thread after sleep => %lu.%.9lu\n",
|
printf ("self thread after sleep => %lu.%.9lu\n",
|
||||||
@@ -286,7 +290,7 @@ do_test (void)
|
|||||||
|
|
||||||
if (th_diff < 100000000 || th_diff > 600000000)
|
if (th_diff < 100000000 || th_diff > 600000000)
|
||||||
{
|
{
|
||||||
printf ("thread before - after %llu outside reasonable range\n",
|
printf ("live thread before - after %llu outside reasonable range\n",
|
||||||
th_diff);
|
th_diff);
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
@@ -305,7 +309,7 @@ do_test (void)
|
|||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
process_after.tv_nsec += test_nanosleep (th_clock, "thread",
|
process_after.tv_nsec += test_nanosleep (th_clock, "live thread",
|
||||||
&after, &result);
|
&after, &result);
|
||||||
process_after.tv_nsec += test_nanosleep (process_clock, "process",
|
process_after.tv_nsec += test_nanosleep (process_clock, "process",
|
||||||
&process_after, &result);
|
&process_after, &result);
|
||||||
|
Reference in New Issue
Block a user