Useful when stitching together combinatorial testnames.
v2:
- ## rules are just fun. We need 2 indirections to actually get
__LINE__ to properly expand.
- Kill stray ; which botched the logic.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
jmp_buf igt_subtest_jmpbuf;
void igt_subtest_init(int argc, char **argv);
bool __igt_run_subtest(const char *subtest_name);
+#define igt_tokencat2(x, y) x ## y
+#define igt_tokencat(x, y) igt_tokencat2(x, y)
+#define __igt_subtest_f(tmp, format, args...) \
+ for (char tmp [256]; \
+ snprintf( tmp , sizeof( tmp ), \
+ format, args), \
+ __igt_run_subtest( tmp ) && \
+ (setjmp(igt_subtest_jmpbuf) == 0); \
+ igt_success())
+#define igt_subtest_f(f, a...) \
+ __igt_subtest_f(igt_tokencat(__tmpchar, __LINE__), f, a)
#define igt_subtest(name) for (; __igt_run_subtest((name)) && \
(setjmp(igt_subtest_jmpbuf) == 0); \
igt_success())
static void do_tests(int cache_level, const char *suffix)
{
- char name[80];
-
if (cache_level != -1)
gem_set_caching(fd, scratch_bo->handle, cache_level);
- snprintf(name, sizeof(name), "reads%s", suffix);
- igt_subtest(name)
+ igt_subtest_f("reads%s", suffix)
test_partial_reads();
- snprintf(name, sizeof(name), "writes%s", suffix);
- igt_subtest(name)
+ igt_subtest_f("write%s", suffix)
test_partial_writes();
- snprintf(name, sizeof(name), "writes-after-reads%s", suffix);
- igt_subtest(name)
+ igt_subtest_f("writes-after-reads%s", suffix)
test_partial_read_writes();
}
*/
#define COLOR 0xffffffff
-static void run_test(int ring, const char *testname)
+static void run_test(int ring)
{
uint32_t *ptr;
int i;
if (ring == I915_EXEC_RENDER)
gem_require_ring(fd, I915_EXEC_BLT);
- printf("running subtest %s\n", testname);
-
target_bo = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
if (!target_bo) {
fprintf(stderr, "failed to alloc target buffer\n");
for (i = 0; i < ARRAY_SIZE(tests); i++) {
igt_subtest(tests[i].name)
- run_test(tests[i].ring, tests[i].name);
+ run_test(tests[i].ring);
}
igt_fork_signal_helper();
for (i = 0; i < ARRAY_SIZE(tests); i++) {
- char name[180];
- snprintf(name, sizeof(name), "%s-interruptible", tests[i].name);
- igt_subtest(name)
- run_test(tests[i].ring, name);
+ igt_subtest_f("%s-interruptible", tests[i].name)
+ run_test(tests[i].ring);
}
igt_stop_signal_helper();