diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-14 18:02:46 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-14 18:02:46 +0200 |
commit | b3880d3a969656b78fe246e5ca4dd5a4a2c70ef5 (patch) | |
tree | 471f1d9f81ec5299615cf59cb1787afac09a5367 /tests/gem_pread.c | |
parent | c3dd8a8c85b3e1a4329282cbe82fd7f387cd2643 (diff) |
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 <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/gem_pread.c')
-rw-r--r-- | tests/gem_pread.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/gem_pread.c b/tests/gem_pread.c index 74e7321a3..ea789ebdc 100644 --- a/tests/gem_pread.c +++ b/tests/gem_pread.c @@ -76,12 +76,13 @@ static const char *bytes_per_sec(char *buf, double v) } +uint32_t *src, dst; +int fd, count; + int main(int argc, char **argv) { int object_size = 0; uint32_t buf[20]; - uint32_t *src, dst; - int fd, count; const struct { int level; const char *name; @@ -101,10 +102,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) { @@ -140,10 +143,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(); } |