[PATCH weston v3 02/15] tests: Add client helper routines for output and reference filenames

Bryce Harrington bryce at osg.samsung.com
Thu May 21 01:39:24 PDT 2015


Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
 tests/weston-test-client-helper.c | 38 ++++++++++++++++++++++++++++++++++++++
 tests/weston-test-client-helper.h |  6 ++++++
 2 files changed, 44 insertions(+)

diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
index 41ed208..00fdf8f 100644
--- a/tests/weston-test-client-helper.c
+++ b/tests/weston-test-client-helper.c
@@ -812,3 +812,41 @@ create_client_and_test_surface(int x, int y, int width, int height)
 
 	return client;
 }
+
+static const char*
+output_path(void) {
+	char *path = getenv("WESTON_TEST_OUTPUT_PATH");
+
+	if (!path)
+		return ".";
+	return path;
+	}
+
+char*
+screenshot_output_filename(const char *basename, uint32_t seq) {
+	char *filename;
+
+	if (asprintf(&filename, "%s/%s-%02d.png",
+				 output_path(), basename, seq) < 0)
+		return NULL;
+	return filename;
+}
+
+static const char*
+reference_path(void) {
+	char *path = getenv("WESTON_TEST_REFERENCE_PATH");
+
+	if (!path)
+		return "./tests/reference";
+	return path;
+}
+
+char*
+screenshot_reference_filename(const char *basename, uint32_t seq) {
+	char *filename;
+
+	if (asprintf(&filename, "%s/%s-%02d.png",
+				 reference_path(), basename, seq) < 0)
+		return NULL;
+	return filename;
+}
diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
index 8635471..b46f158 100644
--- a/tests/weston-test-client-helper.h
+++ b/tests/weston-test-client-helper.h
@@ -180,4 +180,10 @@ void
 expect_protocol_error(struct client *client,
 		      const struct wl_interface *intf, uint32_t code);
 
+char*
+screenshot_output_filename(const char *basename, uint32_t seq);
+
+char*
+screenshot_reference_filename(const char *basename, uint32_t seq);
+
 #endif
-- 
1.9.1



More information about the wayland-devel mailing list