mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
9d9f26d8b1
There were several problems in the gprofng testing: - we did not catch a timeout for each test. - we used exit() to stop a failed test. But this stops all other tests. - we used a time_t (long) type in smalltest.c instead of a long long type. PR gprofng/30602 * configure.ac: Launch only native testing. * configure: Rebuild. * testsuite/config/default.exp: Set TEST_TIMEOUT. * testsuite/gprofng.display/setpath_map.exp: Use return instead of exit. * testsuite/gprofng.display/gp-archive.exp: Likewise. * testsuite/gprofng.display/gp-collect-app_F.exp: Likewise. * testsuite/gprofng.display/display.exp: Delete an unnecessary test for native testing. * testsuite/lib/display-lib.exp (run_native_host_cmd): Add timeout. * testsuite/lib/smalltest.c: Use a long long type instead of time_t.
42 lines
715 B
C
42 lines
715 B
C
#include <stdio.h>
|
|
#include <time.h>
|
|
|
|
typedef long long hrtime_t;
|
|
|
|
hrtime_t
|
|
gethrtime (void)
|
|
{
|
|
struct timespec tp;
|
|
hrtime_t rc = 0;
|
|
#ifdef CLOCK_MONOTONIC_RAW
|
|
int r = clock_gettime (CLOCK_MONOTONIC_RAW, &tp);
|
|
#else
|
|
int r = clock_gettime (CLOCK_MONOTONIC, &tp);
|
|
#endif
|
|
|
|
if (r == 0)
|
|
rc = ((hrtime_t) tp.tv_sec) * 1e9 + (hrtime_t) tp.tv_nsec;
|
|
return rc;
|
|
}
|
|
|
|
volatile long x; /* temp variable for long calculation */
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
long long count = 0;
|
|
hrtime_t start = gethrtime ();
|
|
|
|
do
|
|
{
|
|
x = 0;
|
|
for (int j = 0; j < 1000000; j++)
|
|
x = x + 1;
|
|
count++;
|
|
}
|
|
while (start + 2e9 > gethrtime ());
|
|
printf("count=%lld x=%lld\n", count, x);
|
|
return 0;
|
|
}
|
|
|