tests: add igt_subtest_f for snprintf'ing testnames

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>
This commit is contained in:
Daniel Vetter
2013-08-14 13:47:47 +02:00
parent 1532af19d9
commit 6234658063
3 changed files with 18 additions and 16 deletions
+11
View File
@@ -100,6 +100,17 @@ void igt_progress(const char *header, uint64_t i, uint64_t total);
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())