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>
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 47bcf10..26bb359 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -107,18 +107,20 @@
 	}
 }
 
+uint32_t batch[2] = {MI_BATCH_BUFFER_END};
+uint32_t handle;
+int fd;
+
 int main(int argc, char **argv)
 {
-	uint32_t batch[2] = {MI_BATCH_BUFFER_END};
-	uint32_t handle;
-	int fd;
-
 	igt_subtest_init(argc, argv);
 
-	fd = drm_open_any();
+	igt_fixture {
+		fd = drm_open_any();
 
-	handle = gem_create(fd, 4096);
-	gem_write(fd, handle, 0, batch, sizeof(batch));
+		handle = gem_create(fd, 4096);
+		gem_write(fd, handle, 0, batch, sizeof(batch));
+	}
 
 	igt_subtest("render")
 		loop(fd, handle, I915_EXEC_RENDER, "render");
@@ -132,9 +134,11 @@
 	igt_subtest("vebox")
 		loop(fd, handle, LOCAL_I915_EXEC_VEBOX, "vebox");
 
-	gem_close(fd, handle);
+	igt_fixture {
+		gem_close(fd, handle);
 
-	close(fd);
+		close(fd);
+	}
 
 	igt_exit();
 }