[Intel-gfx] [PATCH 7/7] tests: use drmtest_skip to check for rings
Daniel Vetter
daniel.vetter at ffwll.ch
Mon Aug 12 11:10:01 CEST 2013
To simplify things add a set of gem_check_<ring> functions which take
care of this. Since I've opted for static inlines drmtest.h grew a few
more header includes which was a neat opportunity to dump a few redundant
#defines.
This kills all the skipped_all hand-rolled logic we have.
Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
demos/intel_sprite_on.c | 2 --
lib/drmtest.h | 33 ++++++++++++++++++++++++++++++++-
tests/gem_bad_length.c | 2 --
tests/gem_cs_tlb.c | 12 ++++--------
tests/gem_ctx_bad_exec.c | 1 -
tests/gem_dummy_reloc_loop.c | 8 ++++----
tests/gem_exec_big.c | 1 -
tests/gem_exec_lut_handle.c | 1 -
tests/gem_exec_nop.c | 11 ++++-------
tests/gem_lut_handle.c | 1 -
tests/gem_pwrite.c | 1 -
tests/gem_write_read_ring_switch.c | 6 +++---
tests/prime_self_import.c | 2 --
tests/testdisplay.c | 2 --
14 files changed, 47 insertions(+), 36 deletions(-)
diff --git a/demos/intel_sprite_on.c b/demos/intel_sprite_on.c
index 783f9af..5c380c1 100644
--- a/demos/intel_sprite_on.c
+++ b/demos/intel_sprite_on.c
@@ -51,8 +51,6 @@
#include "drm_fourcc.h"
#endif
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
/*
* Mode setting with the kernel interfaces is a bit of a chore.
* First you have to find the connector in question and make sure the
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 624abb2..b687411 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -37,6 +37,8 @@
#include "xf86drm.h"
#include "xf86drmMode.h"
#include "intel_batchbuffer.h"
+#include "intel_chipset.h"
+#include "intel_gpu_tools.h"
drm_intel_bo * gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd,
const char *name, uint32_t handle);
@@ -54,7 +56,7 @@ bool gem_has_bsd(int fd);
bool gem_has_blt(int fd);
bool gem_has_vebox(int fd);
int gem_get_num_rings(int fd);
-void gem_check_caching(int fd);
+
void gem_set_caching(int fd, uint32_t handle, int caching);
uint32_t gem_get_caching(int fd, uint32_t handle);
uint32_t gem_flink(int fd, uint32_t handle);
@@ -106,6 +108,35 @@ void drmtest_success(void);
void drmtest_fail(int exitcode) __attribute__((noreturn));
int drmtest_retval(void);
+/* check functions which auto-skip tests by calling drmtest_skip() */
+void gem_check_caching(int fd);
+static inline bool gem_check_vebox(int fd)
+{
+ if (gem_has_vebox(fd))
+ return true;
+
+ drmtest_skip();
+ return false;
+}
+
+static inline bool gem_check_bsd(int fd)
+{
+ if (HAS_BSD_RING(intel_get_drm_devid(fd)))
+ return true;
+
+ drmtest_skip();
+ return false;
+}
+
+static inline bool gem_check_blt(int fd)
+{
+ if (HAS_BLT_RING(intel_get_drm_devid(fd)))
+ return true;
+
+ drmtest_skip();
+ return false;
+}
+
/* helpers to automatically reduce test runtime in simulation */
bool drmtest_run_in_simulation(void);
#define SLOW_QUICK(slow,quick) (drmtest_run_in_simulation() ? (quick) : (slow))
diff --git a/tests/gem_bad_length.c b/tests/gem_bad_length.c
index bb8b6b8..2d5f977 100644
--- a/tests/gem_bad_length.c
+++ b/tests/gem_bad_length.c
@@ -40,8 +40,6 @@
#include "i915_drm.h"
#include "drmtest.h"
-#define MI_BATCH_BUFFER_END (0xA<<23)
-
/*
* Testcase: Minmal bo_create and batchbuffer exec
*
diff --git a/tests/gem_cs_tlb.c b/tests/gem_cs_tlb.c
index 081b6f2..0378fdb 100644
--- a/tests/gem_cs_tlb.c
+++ b/tests/gem_cs_tlb.c
@@ -55,7 +55,6 @@
#define LOCAL_I915_EXEC_VEBOX (4<<0)
#define BATCH_SIZE (1024*1024)
-bool skipped_all = true;
static int exec(int fd, uint32_t handle, int split,
uint64_t *gtt_ofs, unsigned ring_id)
@@ -104,7 +103,6 @@ static void run_on_ring(int fd, unsigned ring_id, const char *ring_name)
int i;
sprintf(buf, "testing %s cs tlb coherency: ", ring_name);
- skipped_all = false;
/* Shut up gcc, too stupid. */
batch_ptr_old = NULL;
@@ -149,13 +147,11 @@ static void run_on_ring(int fd, unsigned ring_id, const char *ring_name)
int main(int argc, char **argv)
{
int fd;
- uint32_t devid;
drmtest_subtest_init(argc, argv);
drmtest_skip_on_simulation();
fd = drm_open_any();
- devid = intel_get_drm_devid(fd);
if (!drmtest_only_list_subtests()) {
/* This test is very sensitive to residual gtt_mm noise from previous
@@ -168,18 +164,18 @@ int main(int argc, char **argv)
run_on_ring(fd, I915_EXEC_RENDER, "render");
drmtest_subtest_block("bsd")
- if (HAS_BSD_RING(devid))
+ if (gem_check_bsd(fd))
run_on_ring(fd, I915_EXEC_BSD, "bsd");
drmtest_subtest_block("blt")
- if (HAS_BLT_RING(devid))
+ if (gem_check_blt(fd))
run_on_ring(fd, I915_EXEC_BLT, "blt");
drmtest_subtest_block("vebox")
- if (gem_has_vebox(fd))
+ if (gem_check_vebox(fd))
run_on_ring(fd, LOCAL_I915_EXEC_VEBOX, "vebox");
close(fd);
- return skipped_all ? 77 : 0;
+ return drmtest_retval();
}
diff --git a/tests/gem_ctx_bad_exec.c b/tests/gem_ctx_bad_exec.c
index f6463ac..b7e5db0 100644
--- a/tests/gem_ctx_bad_exec.c
+++ b/tests/gem_ctx_bad_exec.c
@@ -104,7 +104,6 @@ static int exec(int fd, uint32_t handle, int ring, int ctx_id)
return ret;
}
-#define MI_BATCH_BUFFER_END (0xA<<23)
int main(int argc, char *argv[])
{
uint32_t handle;
diff --git a/tests/gem_dummy_reloc_loop.c b/tests/gem_dummy_reloc_loop.c
index 7cffbbe..2d0a245 100644
--- a/tests/gem_dummy_reloc_loop.c
+++ b/tests/gem_dummy_reloc_loop.c
@@ -167,7 +167,7 @@ int main(int argc, char **argv)
}
drmtest_subtest_block("bsd") {
- if (HAS_BSD_RING(devid)) {
+ if (gem_check_bsd(fd)) {
sleep(2);
printf("running dummy loop on bsd\n");
dummy_reloc_loop(I915_EXEC_BSD);
@@ -176,7 +176,7 @@ int main(int argc, char **argv)
}
drmtest_subtest_block("blt") {
- if (HAS_BLT_RING(devid)) {
+ if (gem_check_blt(fd)) {
sleep(2);
printf("running dummy loop on blt\n");
dummy_reloc_loop(I915_EXEC_BLT);
@@ -185,7 +185,7 @@ int main(int argc, char **argv)
}
drmtest_subtest_block("vebox") {
- if (gem_has_vebox(fd)) {
+ if (gem_check_vebox(fd)) {
sleep(2);
printf("running dummy loop on vebox\n");
dummy_reloc_loop(LOCAL_I915_EXEC_VEBOX);
@@ -208,5 +208,5 @@ int main(int argc, char **argv)
close(fd);
- return 0;
+ return drmtest_retval();
}
diff --git a/tests/gem_exec_big.c b/tests/gem_exec_big.c
index 9dddfac..b67aba1 100644
--- a/tests/gem_exec_big.c
+++ b/tests/gem_exec_big.c
@@ -49,7 +49,6 @@
#include "i915_drm.h"
#include "drmtest.h"
-#define MI_BATCH_BUFFER_END (0xA<<23)
#define BATCH_SIZE (1024*1024)
static int exec(int fd, uint32_t handle, uint32_t reloc_ofs)
diff --git a/tests/gem_exec_lut_handle.c b/tests/gem_exec_lut_handle.c
index 54ed3dd..8ea889a 100644
--- a/tests/gem_exec_lut_handle.c
+++ b/tests/gem_exec_lut_handle.c
@@ -40,7 +40,6 @@
#include "i915_drm.h"
#include "drmtest.h"
-#define MI_BATCH_BUFFER_END (0xA<<23)
#define BATCH_SIZE (1024*1024)
#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index ca1f580..a821440 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -44,7 +44,6 @@
#include "intel_gpu_tools.h"
#define LOCAL_I915_EXEC_VEBOX (4<<0)
-bool skipped_all = true;
static double elapsed(const struct timeval *start,
const struct timeval *end,
@@ -94,8 +93,6 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, const char *ring_nam
{
int count;
- skipped_all = false;
-
for (count = 1; count <= SLOW_QUICK(1<<17, 1<<4); count <<= 1) {
struct timeval start, end;
@@ -128,20 +125,20 @@ int main(int argc, char **argv)
loop(fd, handle, I915_EXEC_RENDER, "render");
drmtest_subtest_block("bsd")
- if (HAS_BSD_RING(devid))
+ if (gem_check_blt(fd))
loop(fd, handle, I915_EXEC_BSD, "bsd");
drmtest_subtest_block("blt")
- if (HAS_BLT_RING(devid))
+ if (gem_check_blt(fd))
loop(fd, handle, I915_EXEC_BLT, "blt");
drmtest_subtest_block("vebox")
- if (gem_has_vebox(fd))
+ if (gem_check_vebox(fd))
loop(fd, handle, LOCAL_I915_EXEC_VEBOX, "vebox");
gem_close(fd, handle);
close(fd);
- return skipped_all ? 77 : 0;
+ return drmtest_retval();
}
diff --git a/tests/gem_lut_handle.c b/tests/gem_lut_handle.c
index f3e5734..1b7974b 100644
--- a/tests/gem_lut_handle.c
+++ b/tests/gem_lut_handle.c
@@ -40,7 +40,6 @@
#include "i915_drm.h"
#include "drmtest.h"
-#define MI_BATCH_BUFFER_END (0xA<<23)
#define BATCH_SIZE (1024*1024)
#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
diff --git a/tests/gem_pwrite.c b/tests/gem_pwrite.c
index bd9d9cd..f6a0ffc 100644
--- a/tests/gem_pwrite.c
+++ b/tests/gem_pwrite.c
@@ -49,7 +49,6 @@
#define BLT_WRITE_RGB (1<<20)
#define BLT_SRC_TILED (1<<15)
#define BLT_DST_TILED (1<<11)
-#define MI_BATCH_BUFFER_END (0xA<<23)
static void do_gem_write(int fd, uint32_t handle, void *buf, int len, int loops)
{
diff --git a/tests/gem_write_read_ring_switch.c b/tests/gem_write_read_ring_switch.c
index 211b530..bd50520 100644
--- a/tests/gem_write_read_ring_switch.c
+++ b/tests/gem_write_read_ring_switch.c
@@ -151,11 +151,11 @@ static int has_ring(int ring)
{
switch (ring) {
case I915_EXEC_RENDER: /* test only makes sense with separate blitter */
- return HAS_BLT_RING(intel_get_drm_devid(fd));
+ return gem_check_blt(fd);
case I915_EXEC_BSD:
- return HAS_BSD_RING(intel_get_drm_devid(fd));
+ return gem_check_bsd(fd);
case LOCAL_I915_EXEC_VEBOX:
- return gem_has_vebox(fd);
+ return gem_check_vebox(fd);
default:
return 0;
}
diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c
index 1bd0bb5..8b0a198 100644
--- a/tests/prime_self_import.c
+++ b/tests/prime_self_import.c
@@ -51,8 +51,6 @@
#define BO_SIZE (16*1024)
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
static char counter;
volatile int pls_die = 0;
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 3781612..06dd0e3 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -86,8 +86,6 @@ int plane_width, plane_height;
static const uint32_t SPRITE_COLOR_KEY = 0x00aaaaaa;
uint32_t *fb_ptr;
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
/*
* Mode setting with the kernel interfaces is a bit of a chore.
* First you have to find the connector in question and make sure the
--
1.8.3.2
More information about the Intel-gfx
mailing list