mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2026-08-20 04:42:53 +00:00
igt/gem_softpin: Repeat tests with signal interruptions
For the long running tests probing error conditions, throwing in the signal interruptions is a good idea. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
@@ -396,6 +396,23 @@ error:
|
||||
return -errno;
|
||||
}
|
||||
|
||||
#define MSEC_PER_SEC (1000)
|
||||
#define USEC_PER_SEC (1000*MSEC_PER_SEC)
|
||||
#define NSEC_PER_SEC (1000*USEC_PER_SEC)
|
||||
uint64_t igt_nsec_elapsed(struct timespec *start)
|
||||
{
|
||||
struct timespec now;
|
||||
|
||||
gettime(&now);
|
||||
if ((start->tv_sec | start->tv_nsec) == 0) {
|
||||
*start = now;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((now.tv_nsec - start->tv_nsec) +
|
||||
NSEC_PER_SEC*(now.tv_sec - start->tv_sec));
|
||||
}
|
||||
|
||||
bool __igt_fixture(void)
|
||||
{
|
||||
assert(!in_fixture);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -775,6 +776,40 @@ extern enum igt_log_level igt_log_level;
|
||||
void igt_set_timeout(unsigned int seconds,
|
||||
const char *op);
|
||||
|
||||
/**
|
||||
* igt_nsec_elapsed:
|
||||
* @start: measure from this point in time
|
||||
*
|
||||
* Reports the difference in the monotonic clock from the start time
|
||||
* in nanoseconds. On the first invocation, start should be zeroed and will
|
||||
* be set by the call.
|
||||
*
|
||||
* Typical use would be:
|
||||
*
|
||||
* igt_subtest("test") {
|
||||
* struct timespec start = {};
|
||||
* while (igt_nsec_elapsed(&start) < test_timeout_ns)
|
||||
* do_test();
|
||||
* }
|
||||
*
|
||||
* A handy approximation is to use nsec >> 30 to convert to seconds,
|
||||
* nsec >> 20 to convert to milliseconds - the error is about 8%, acceptable
|
||||
* for test run times.
|
||||
*/
|
||||
uint64_t igt_nsec_elapsed(struct timespec *start);
|
||||
|
||||
/**
|
||||
* igt_seconds_elapsed:
|
||||
* @start: measure from this point in time
|
||||
*
|
||||
* A wrapper around igt_nsec_elapsed that reports the approximate (8% error)
|
||||
* number of seconds since the start point.
|
||||
*/
|
||||
static inline uint32_t igt_seconds_elapsed(struct timespec *start)
|
||||
{
|
||||
return igt_nsec_elapsed(start) >> 30;
|
||||
}
|
||||
|
||||
void igt_reset_timeout(void);
|
||||
|
||||
FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
|
||||
|
||||
Reference in New Issue
Block a user