summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-14 15:48:54 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-14 17:04:56 +0200
commit2dbd998429dc1c449abfa153060aba5a97b7c8aa (patch)
treea6fdf8eb71ba8078b855da5990d601bb580d40ca
parentf8c0dfe399d7b5351a16d111285e85f54a5725ff (diff)
tests: Introduce igt_fixturefixtures
Just a tiny wrapper to protect global test setup/teardown code when just listing subtests. Rolling this out over all tests with subtests should allow us to generate the testlist with piglit as an unpriviledged user on a non-intel system. The aim here is to make our QA team happy who currently suffers from this. Even more so for the prime tests since you need a system with intel _and_ nouveau gpus to just be able to list tests. Exemplary conversion with gem_concurrent_blt.c Fixture is the same name other test suites like googletest use for setup/teardown code used by multiple tests. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--lib/drmtest.h2
-rw-r--r--tests/gem_concurrent_blit.c20
2 files changed, 13 insertions, 9 deletions
diff --git a/lib/drmtest.h b/lib/drmtest.h
index d18b541a..b6d6dfba 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -174,6 +174,8 @@ void igt_exit(void) __attribute__((noreturn));
*/
#define igt_require(expr) do { if (!(expr)) __igt_skip_check(__FILE__, __LINE__, __func__, #expr ); } while (0)
+#define igt_fixture if (!igt_only_list_subtests())
+
/* check functions which auto-skip tests by calling igt_skip() */
void gem_require_caching(int fd);
static inline void gem_require_ring(int fd, int ring_id)
diff --git a/tests/gem_concurrent_blit.c b/tests/gem_concurrent_blit.c
index b019f027..4c7fd142 100644
--- a/tests/gem_concurrent_blit.c
+++ b/tests/gem_concurrent_blit.c
@@ -318,7 +318,7 @@ run_modes(struct access_mode *mode)
drm_intel_bo *src[128], *dst[128], *dummy = NULL;
- if (!igt_only_list_subtests()) {
+ igt_fixture {
for (i = 0; i < num_buffers; i++) {
src[i] = mode->create_bo(bufmgr, i, width, height);
dst[i] = mode->create_bo(bufmgr, ~i, width, height);
@@ -336,7 +336,7 @@ run_modes(struct access_mode *mode)
igt_stop_signal_helper();
- if (!igt_only_list_subtests()) {
+ igt_fixture {
for (i = 0; i < num_buffers; i++) {
drm_intel_bo_unreference(src[i]);
drm_intel_bo_unreference(dst[i]);
@@ -353,15 +353,17 @@ main(int argc, char **argv)
igt_subtest_init(argc, argv);
igt_skip_on_simulation();
- fd = drm_open_any();
+ igt_fixture {
+ fd = drm_open_any();
- max = gem_aperture_size (fd) / (1024 * 1024) / 2;
- if (num_buffers > max)
- num_buffers = max;
+ max = gem_aperture_size (fd) / (1024 * 1024) / 2;
+ if (num_buffers > max)
+ num_buffers = max;
- bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- drm_intel_bufmgr_gem_enable_reuse(bufmgr);
- batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
+ bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
+ drm_intel_bufmgr_gem_enable_reuse(bufmgr);
+ batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
+ }
for (i = 0; i < ARRAY_SIZE(access_modes); i++)
run_modes(&access_modes[i]);