[PATCH i-g-t v10 19/21] tests/sw_sync: Add subtest test_sync_merge_invalid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add subtest test_sync_merge_invalid that tests merging invalid fences.

Signed-off-by: Robert Foss <robert.foss@xxxxxxxxxxxxx>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@xxxxxxxxxxxxx>
---
 tests/sw_sync.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 5bccb053..3c876e03 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -172,6 +172,44 @@ static void test_sync_busy(void)
 	close(timeline);
 }
 
+static void test_sync_merge_invalid(void)
+{
+	int in_fence;
+	int fence_invalid;
+	int fence_merge;
+	int timeline;
+	char tmppath[] = "/tmp/igt-XXXXXX";
+	int skip = 0;
+
+	timeline = sw_sync_timeline_create();
+	in_fence = sw_sync_fence_create(timeline, 1);
+
+	fence_invalid = -1;
+	fence_merge = sync_merge(in_fence, fence_invalid);
+	igt_assert_f(fence_merge < 0, "Verify invalid fd (-1) handling");
+
+	fence_invalid = drm_open_driver(DRIVER_ANY);
+	fence_merge = sync_merge(in_fence, fence_invalid);
+	igt_assert_f(fence_merge < 0, "Verify invalid fd (device fd) handling");
+
+	fence_invalid = mkstemp(tmppath);
+	if (fence_invalid == -1) {
+		skip = 1;
+		goto out;
+	}
+	unlink(tmppath);
+	fence_invalid = drm_open_driver(DRIVER_ANY);
+	fence_merge = sync_merge(in_fence, fence_invalid);
+	close(fence_invalid);
+	igt_assert_f(fence_merge < 0, "Verify invalid fd (file fd) handling");
+
+out:
+	close(in_fence);
+	close(fence_merge);
+	close(timeline);
+	igt_require(skip == 0);
+}
+
 static void test_sync_merge(void)
 {
 	int in_fence[3];
@@ -746,6 +784,9 @@ igt_main
 	igt_subtest("sync_busy")
 		test_sync_busy();
 
+	igt_subtest("sync_merge_invalid")
+		test_sync_merge_invalid();
+
 	igt_subtest("sync_merge")
 		test_sync_merge();
 
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux