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:
Chris Wilson
2016-03-18 09:04:07 +00:00
parent 34098b71fa
commit dcb39b5270
3 changed files with 90 additions and 14 deletions
+17
View File
@@ -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);
+35
View File
@@ -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,