mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2026-08-21 21:32:56 +00:00
tests: introduce igt_require
Since igt_skip has funny control flow we can abuse it and make it work like a special kind of assert which automatically skips tests if a requirement fails. Note that in places where we have a less strict test which should always succeed (e.g. ioctl works or isn't available) the igt_assert should be place before the igt_require with the more strict requirements. Otherwise we'll skip a test instead of properly failing it. Convert a few users of igt_skip over to igt_require to showcase its use. v2: s/gem_check_/gem_require_/ so that we consistently use "require" to indicate magic check that can call igt_skip. Imo hiding the igt_require for feature checks is ok, but for more traditional assert like use cases an explicit igt_require might be better. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
@@ -146,20 +146,6 @@ static void run_test(int ring, const char *testname)
|
||||
drm_intel_bo_unreference(target_bo);
|
||||
}
|
||||
|
||||
static int has_ring(int ring)
|
||||
{
|
||||
switch (ring) {
|
||||
case I915_EXEC_RENDER: /* test only makes sense with separate blitter */
|
||||
return gem_check_blt(fd);
|
||||
case I915_EXEC_BSD:
|
||||
return gem_check_bsd(fd);
|
||||
case LOCAL_I915_EXEC_VEBOX:
|
||||
return gem_check_vebox(fd);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const struct {
|
||||
@@ -206,8 +192,11 @@ int main(int argc, char **argv)
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tests); i++) {
|
||||
igt_subtest(tests[i].name) {
|
||||
if (has_ring(tests[i].ring))
|
||||
run_test(tests[i].ring, tests[i].name);
|
||||
gem_require_ring(fd, tests[i].ring);
|
||||
/* Testing render only makes sense with separate blt. */
|
||||
if (tests[i].ring == I915_EXEC_RENDER)
|
||||
gem_require_ring(fd, I915_EXEC_BLT);
|
||||
run_test(tests[i].ring, tests[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user