From b3880d3a969656b78fe246e5ca4dd5a4a2c70ef5 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Wed, 14 Aug 2013 18:02:46 +0200 Subject: tests: roll out igt_fixture Also sprinkle igt_assert and igt_require over the setup code to clean up code while at it. To avoid gcc getting upset about unitialized variables just move them out of main as global data (where they always get initialized to 0) - gcc can't see through our igt_fixture and igt_subtest maze properly. Signed-off-by: Daniel Vetter --- tests/gem_pwrite.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'tests/gem_pwrite.c') diff --git a/tests/gem_pwrite.c b/tests/gem_pwrite.c index 62b5c2f2..5ea7d169 100644 --- a/tests/gem_pwrite.c +++ b/tests/gem_pwrite.c @@ -82,12 +82,14 @@ static const char *bytes_per_sec(char *buf, double v) } +uint32_t *src, dst; +int fd; + int main(int argc, char **argv) { int object_size = 0; uint32_t buf[20]; - uint32_t *src, dst; - int fd, count; + int count; const struct { int level; const char *name; @@ -101,7 +103,6 @@ int main(int argc, char **argv) igt_skip_on_simulation(); igt_subtest_init(argc, argv); - igt_skip_on_simulation(); if (argc > 1 && atoi(argv[1])) object_size = atoi(argv[1]); @@ -109,10 +110,12 @@ int main(int argc, char **argv) object_size = OBJECT_SIZE; object_size = (object_size + 3) & -4; - fd = drm_open_any(); + igt_fixture { + fd = drm_open_any(); - dst = gem_create(fd, object_size); - src = malloc(object_size); + dst = gem_create(fd, object_size); + src = malloc(object_size); + } igt_subtest("normal") { for (count = 1; count <= 1<<17; count <<= 1) { @@ -148,10 +151,12 @@ int main(int argc, char **argv) } } - free(src); - gem_close(fd, dst); + igt_fixture { + free(src); + gem_close(fd, dst); - close(fd); + close(fd); + } igt_exit(); } -- cgit v1.2.3