summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-12 10:43:59 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-12 11:17:58 +0200
commit7553ad6e10f76aa703359a10e08138e14501d54d (patch)
tree1e778fa0a06bf91bdc43aa2574be555396e42d5c /lib
parenta4038d3853b98707a803f5d1fb5c9ebe32f0b84b (diff)
tests: use drmtest_skip() in caching ioctl helpers
This way we can rip out all the skip handling from the test control flow, and additionally (by using drmtest_retval()) even get correct exit codes. The only tricky part is that when we only want ot skip parts of a test (like for gem_pread and gem_pwrite) we need to split out those parts as subtests. But no addition of control-flow is required, the set/longjmp magic in the helpers all makes it happen. Also we make extensive use of the behaviour of drmtest_skip to skip all subsequent subtests if it is called outside of a subtest. This allows us to re-flatten the control flow a lot. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/drmtest.c20
-rw-r--r--lib/drmtest.h4
2 files changed, 16 insertions, 8 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 77e8002e6..7e3c1d81c 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -40,6 +40,7 @@
#include <stdlib.h>
#include <linux/kd.h>
#include <unistd.h>
+#include <sys/wait.h>
#include "drm_fourcc.h"
#include "drmtest.h"
@@ -392,23 +393,26 @@ struct local_drm_i915_gem_caching {
#define LOCAL_DRM_IOCTL_I915_GEM_GET_CACHEING \
DRM_IOWR(DRM_COMMAND_BASE + LOCAL_DRM_I915_GEM_GET_CACHEING, struct local_drm_i915_gem_caching)
-int gem_has_caching(int fd)
+void gem_check_caching(int fd)
{
struct local_drm_i915_gem_caching arg;
int ret;
arg.handle = gem_create(fd, 4096);
- if (arg.handle == 0)
- return 0;
+ assert(arg.handle != 0);
arg.caching = 0;
ret = ioctl(fd, LOCAL_DRM_IOCTL_I915_GEM_SET_CACHEING, &arg);
gem_close(fd, arg.handle);
- return ret == 0;
+ if (ret != 0) {
+ if (!drmtest_only_list_subtests())
+ printf("no set_caching support detected\n");
+ drmtest_skip();
+ }
}
-int gem_set_caching(int fd, uint32_t handle, int caching)
+void gem_set_caching(int fd, uint32_t handle, int caching)
{
struct local_drm_i915_gem_caching arg;
int ret;
@@ -416,7 +420,11 @@ int gem_set_caching(int fd, uint32_t handle, int caching)
arg.handle = handle;
arg.caching = caching;
ret = ioctl(fd, LOCAL_DRM_IOCTL_I915_GEM_SET_CACHEING, &arg);
- return ret == 0 ? 0 : -errno;
+
+ if (ret != 0 && (errno == ENOTTY || errno == EINVAL))
+ drmtest_skip();
+ else
+ assert(ret == 0);
}
uint32_t gem_get_caching(int fd, uint32_t handle)
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 13e25bb15..624abb2db 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -54,8 +54,8 @@ 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);
-int gem_has_caching(int fd);
-int gem_set_caching(int fd, uint32_t handle, int caching);
+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);
uint32_t gem_open(int fd, uint32_t name);