Skip to contentSkip to conversation

tests/kms_psr_sink_crc: Make blt visible to human eyes

PATCH In review Rodrigo Vivi 4 participants 19 messages Jan 12, 2015 – Mar 12, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/15 tests/kms_psr_sink_crc: Make blt visible to human eyes

This will allow manual tests when crc isn't available.

---
 tests/kms_psr_sink_crc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/kms_psr_sink_crc.c +1 -1
index 98b60cf..ad440a8 100644
@@ -123,7 +123,7 @@ static void fill_blt(data_t *data, uint32_t handle, unsigned char color)
 	COLOR_BLIT_COPY_BATCH_START(0);
 	OUT_BATCH((1 << 24) | (0xf0 << 16) | 0);
 	OUT_BATCH(0);
-	OUT_BATCH(1 << 16 | 4);
+	OUT_BATCH(0xfff << 16 | 0xfff);
 	OUT_RELOC(dst, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
 	OUT_BATCH(color);
 	ADVANCE_BATCH();
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/15 tests/kms_psr_sink_crc: Make render visible to human eyes

This will allow manual tests when crc isn't available.

---
 tests/kms_psr_sink_crc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/kms_psr_sink_crc.c +2 -2
index ad440a8..892bba6 100644
@@ -139,7 +139,7 @@ static void scratch_buf_init(struct igt_buf *buf, drm_intel_bo *bo)
 	buf->bo = bo;
 	buf->stride = 4096;
 	buf->tiling = I915_TILING_X;
-	buf->size = 4096;
+	buf->size = 4;
 }
 
 static void fill_render(data_t *data, uint32_t handle, unsigned char color)
@@ -167,7 +167,7 @@ static void fill_render(data_t *data, uint32_t handle, unsigned char color)
 	igt_assert(batch);
 
 	rendercopy(batch, NULL,
-		   &src_buf, 0, 0, 1, 1,
+		   &src_buf, 0, 0, 0xff, 0xff,
 		   &dst_buf, 0, 0);
 
 	intel_batchbuffer_free(batch);
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/15 tests/kms_psr_sink_crc: Make mmaps visible to human eyes

In reply to Rodrigo Vivi

this will allow manual tests when crc isn't available.

---
 tests/kms_psr_sink_crc.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)
tests/kms_psr_sink_crc.c +19 -10
index 892bba6..865ac70 100644
@@ -83,6 +83,7 @@ typedef struct {
 	drm_intel_bufmgr *bufmgr;
 	struct igt_fb fb_green, fb_white;
 	igt_plane_t *primary, *sprite, *cursor;
+	int mod_size;
 } data_t;
 
 static void create_cursor_fb(data_t *data)
@@ -335,19 +336,21 @@ static void test_crc(data_t *data)
 		igt_assert(is_green(crc));
 		break;
 	case MMAP_GTT:
-		ptr = gem_mmap__gtt(data->drm_fd, handle, 4096, PROT_WRITE);
+		ptr = gem_mmap__gtt(data->drm_fd, handle, data->mod_size,
+				    PROT_WRITE);
 		gem_set_domain(data->drm_fd, handle,
 			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
-		memset(ptr, 0, 4);
-		munmap(ptr, 4096);
+		memset(ptr, 0xcc, data->mod_size);
+		munmap(ptr, data->mod_size);
 		break;
 	case MMAP_GTT_WAITING:
-		ptr = gem_mmap__gtt(data->drm_fd, handle, 4096, PROT_WRITE);
+		ptr = gem_mmap__gtt(data->drm_fd, handle, data->mod_size,
+				    PROT_WRITE);
 		gem_set_domain(data->drm_fd, handle,
 			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 
 		/* Printing white on white so the screen shouldn't change */
-		memset(ptr, 0xff, 4);
+		memset(ptr, 0xff, data->mod_size);
 		get_sink_crc(data, crc);
 		igt_assert(strcmp(ref_crc, crc) == 0);
 
@@ -355,15 +358,15 @@ static void test_crc(data_t *data)
 		sleep(10);
 
 		/* Now lets print black to change the screen */
-		memset(ptr, 0, 4);
-		munmap(ptr, 4096);
+		memset(ptr, 0, data->mod_size);
+		munmap(ptr, data->mod_size);
 		break;
 	case MMAP_CPU:
-		ptr = gem_mmap__cpu(data->drm_fd, handle, 0, 4096, PROT_WRITE);
+		ptr = gem_mmap__cpu(data->drm_fd, handle, 0, data->mod_size, PROT_WRITE);
 		gem_set_domain(data->drm_fd, handle,
 			       I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
-		memset(ptr, 0, 4);
-		munmap(ptr, 4096);
+		memset(ptr, 0, data->mod_size);
+		munmap(ptr, data->mod_size);
 		gem_sw_finish(data->drm_fd, handle);
 		break;
 	case BLT:
@@ -431,6 +434,9 @@ static void run_test(data_t *data)
 		white_h = mode->hdisplay;
 		white_v = mode->vdisplay;
 
+		/* Ignoring pitch and bpp to avoid changing full screen */
+		data->mod_size = white_h * white_v;
+
 		switch (data->test_plane) {
 		case SPRITE:
 			data->sprite = igt_output_get_plane(output,
@@ -454,6 +460,9 @@ static void run_test(data_t *data)
 			igt_plane_set_fb(data->cursor, NULL);
 			create_cursor_fb(data);
 			igt_plane_set_position(data->cursor, 0, 0);
+
+			/* Cursor is 64 x 64, ignoring pitch and bbp again */
+			data->mod_size = 64 * 64;
 			break;
 		}
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 4/15 tests/kms_psr_sink_crc: Make plane_move visible to human eyes

In reply to Rodrigo Vivi

this will allow manual tests when crc isn't available.

---
 tests/kms_psr_sink_crc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/kms_psr_sink_crc.c +1 -1
index 865ac70..155c25f 100644
@@ -377,7 +377,7 @@ static void test_crc(data_t *data)
 		break;
 	case PLANE_MOVE:
 		/* Only in use when testing Sprite and Cursor */
-		igt_plane_set_position(test_plane, 1, 1);
+		igt_plane_set_position(test_plane, 500, 500);
 		igt_display_commit(&data->display);
 		break;
 	case PLANE_ONOFF:
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH 5/15 lib/igt_aux: Don't remove echo from terminal

In reply to Rodrigo Vivi

It is simply annoying to loose terminal echo. When debugging many times you CTRL+C on terminal to kill test while it is waiting for key and than you keep without echo. And this function is used whey you are debugging in manual modes. So let's keep ECHO.

---
 lib/igt_aux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_aux.c +1 -1
index 7668106..3bad6c0 100644
@@ -482,7 +482,7 @@ void igt_debug_wait_for_keypress(const char *key)
 
 	tcgetattr ( STDIN_FILENO, &oldt );
 	newt = oldt;
-	newt.c_lflag &= ~( ICANON | ECHO );
+	newt.c_lflag &= ~ICANON;
 	tcsetattr ( STDIN_FILENO, TCSANOW, &newt );
 	getchar();
 	tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH 6/15 lib: s/IGT_DEBUG_INTERACTIVE/--interactive-debug=var

In reply to Rodrigo Vivi

Use cmdline variable for interactive debug instead of env var.

v2: Make interactive-debug domain optional and use "all" when not set.

---
 lib/igt_aux.c  | 20 ++++++++++----------
 lib/igt_aux.h  |  2 +-
 lib/igt_core.c |  9 +++++++++
 lib/igt_core.h |  2 ++
 4 files changed, 22 insertions(+), 11 deletions(-)
lib/igt_aux.c +10 -10
index 3bad6c0..54e5c58 100644
@@ -450,32 +450,32 @@ void igt_drop_root(void)
 
 /**
  * igt_debug_wait_for_keypress:
- * @key: env var lookup to to enable this wait
+ * @var: var lookup to to enable this wait
  *
  * Waits for a key press when run interactively and when the corresponding debug
- * key is set in the IGT_DEBUG_INTERACTIVE environment variable. Multiple keys
+ * var is set in the --interactive-debug=<var> variable. Multiple keys
  * can be specified as a comma-separated list or alternatively "all" if a wait
- * should happen for all keys.  When not connected to a terminal the environment
- * setting is ignored and execution immediately continues.
+ * should happen for all cases.
+ *
+ * When not connected to a terminal interactive_debug is ignored
+ * and execution immediately continues.
  *
  * This is useful for display tests where under certain situation manual
  * inspection of the display is useful. Or when running a testcase in the
  * background.
  */
-void igt_debug_wait_for_keypress(const char *key)
+void igt_debug_wait_for_keypress(const char *var)
 {
 	struct termios oldt, newt;
-	const char *env;
 
 	if (!isatty(STDIN_FILENO))
 		return;
 
-	env = getenv("IGT_DEBUG_INTERACTIVE");
-
-	if (!env)
+	if (!igt_interactive_debug)
 		return;
 
-	if (!strstr(env, key) && !strstr(env, "all"))
+	if (!strstr(igt_interactive_debug, var) &&
+	    !strstr(igt_interactive_debug, "all"))
 		return;
 
 	igt_info("Press any key to continue ...\n");
lib/igt_aux.h +1 -1
index e1909a9..798a5b4 100644
@@ -64,7 +64,7 @@ void igt_system_suspend_autoresume(void);
 /* dropping priviledges */
 void igt_drop_root(void);
 
-void igt_debug_wait_for_keypress(const char *key);
+void igt_debug_wait_for_keypress(const char *var);
 
 enum igt_runtime_pm_status {
 	IGT_RUNTIME_PM_STATUS_ACTIVE,
lib/igt_core.c +9 -0
index a74fe09..bd655be 100644
@@ -233,6 +233,7 @@ enum {
  OPT_RUN_SUBTEST,
  OPT_DESCRIPTION,
  OPT_DEBUG,
+ OPT_INTERACTIVE_DEBUG,
  OPT_HELP = 'h'
 };
 
@@ -403,6 +404,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
 	fprintf(f, "  --list-subtests\n"
 		   "  --run-subtest <pattern>\n"
 		   "  --debug[=log-domain]\n"
+		   "  --interactive-debug[=domain]\n"
 		   "  --help-description\n"
 		   "  --help\n");
 	if (help_str)
@@ -435,6 +437,7 @@ static int common_init(int argc, char **argv,
 		{"run-subtest", 1, 0, OPT_RUN_SUBTEST},
 		{"help-description", 0, 0, OPT_DESCRIPTION},
 		{"debug", optional_argument, 0, OPT_DEBUG},
+		{"interactive-debug", optional_argument, 0, OPT_INTERACTIVE_DEBUG},
 		{"help", 0, 0, OPT_HELP},
 		{0, 0, 0, 0}
 	};
@@ -520,6 +523,12 @@ static int common_init(int argc, char **argv,
 	while ((c = getopt_long(argc, argv, short_opts, combined_opts,
 			       &option_index)) != -1) {
 		switch(c) {
+		case OPT_INTERACTIVE_DEBUG:
+			if (optarg && strlen(optarg) > 0)
+				igt_interactive_debug = strdup(optarg);
+			else
+				igt_interactive_debug = "all";
+			break;
 		case OPT_DEBUG:
 			igt_log_level = IGT_LOG_DEBUG;
 			if (optarg && strlen(optarg) > 0)
lib/igt_core.h +2 -0
index 5c5ee25..32041f6 100644
@@ -511,6 +511,8 @@ bool igt_run_in_simulation(void);
 
 void igt_skip_on_simulation(void);
 
+const char *igt_interactive_debug;
+
 /* structured logging */
 #ifndef IGT_LOG_DOMAIN
 #define IGT_LOG_DOMAIN (NULL)
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

Re: [PATCH i-g-t 06/15] lib: s/IGT_DEBUG_INTERACTIVE/--interactive-debug=var

Quoted 5 lines · Rodrigo Vivi

Use cmdline variable for interactive debug instead of env var.

v2: Make interactive-debug domain optional and use "all" when not set.

I went ahead and applied this one to igt.
-Daniel

Quoted 128 lines
---
 lib/igt_aux.c  | 20 ++++++++++----------
 lib/igt_aux.h  |  2 +-
 lib/igt_core.c |  9 +++++++++
 lib/igt_core.h |  2 ++
 4 files changed, 22 insertions(+), 11 deletions(-)
lib/igt_aux.c +10 -10
index 3bad6c0..54e5c58 100644
@@ -450,32 +450,32 @@ void igt_drop_root(void)
 
 /**
  * igt_debug_wait_for_keypress:
- * @key: env var lookup to to enable this wait
+ * @var: var lookup to to enable this wait
  *
  * Waits for a key press when run interactively and when the corresponding debug
- * key is set in the IGT_DEBUG_INTERACTIVE environment variable. Multiple keys
+ * var is set in the --interactive-debug=<var> variable. Multiple keys
  * can be specified as a comma-separated list or alternatively "all" if a wait
- * should happen for all keys.  When not connected to a terminal the environment
- * setting is ignored and execution immediately continues.
+ * should happen for all cases.
+ *
+ * When not connected to a terminal interactive_debug is ignored
+ * and execution immediately continues.
  *
  * This is useful for display tests where under certain situation manual
  * inspection of the display is useful. Or when running a testcase in the
  * background.
  */
-void igt_debug_wait_for_keypress(const char *key)
+void igt_debug_wait_for_keypress(const char *var)
 {
 	struct termios oldt, newt;
-	const char *env;
 
 	if (!isatty(STDIN_FILENO))
 		return;
 
-	env = getenv("IGT_DEBUG_INTERACTIVE");
-
-	if (!env)
+	if (!igt_interactive_debug)
 		return;
 
-	if (!strstr(env, key) && !strstr(env, "all"))
+	if (!strstr(igt_interactive_debug, var) &&
+	    !strstr(igt_interactive_debug, "all"))
 		return;
 
 	igt_info("Press any key to continue ...\n");
lib/igt_aux.h +1 -1
index e1909a9..798a5b4 100644
@@ -64,7 +64,7 @@ void igt_system_suspend_autoresume(void);
 /* dropping priviledges */
 void igt_drop_root(void);
 
-void igt_debug_wait_for_keypress(const char *key);
+void igt_debug_wait_for_keypress(const char *var);
 
 enum igt_runtime_pm_status {
 	IGT_RUNTIME_PM_STATUS_ACTIVE,
lib/igt_core.c +9 -0
index a74fe09..bd655be 100644
@@ -233,6 +233,7 @@ enum {
  OPT_RUN_SUBTEST,
  OPT_DESCRIPTION,
  OPT_DEBUG,
+ OPT_INTERACTIVE_DEBUG,
  OPT_HELP = 'h'
 };
 
@@ -403,6 +404,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
 	fprintf(f, "  --list-subtests\n"
 		   "  --run-subtest <pattern>\n"
 		   "  --debug[=log-domain]\n"
+		   "  --interactive-debug[=domain]\n"
 		   "  --help-description\n"
 		   "  --help\n");
 	if (help_str)
@@ -435,6 +437,7 @@ static int common_init(int argc, char **argv,
 		{"run-subtest", 1, 0, OPT_RUN_SUBTEST},
 		{"help-description", 0, 0, OPT_DESCRIPTION},
 		{"debug", optional_argument, 0, OPT_DEBUG},
+		{"interactive-debug", optional_argument, 0, OPT_INTERACTIVE_DEBUG},
 		{"help", 0, 0, OPT_HELP},
 		{0, 0, 0, 0}
 	};
@@ -520,6 +523,12 @@ static int common_init(int argc, char **argv,
 	while ((c = getopt_long(argc, argv, short_opts, combined_opts,
 			       &option_index)) != -1) {
 		switch(c) {
+		case OPT_INTERACTIVE_DEBUG:
+			if (optarg && strlen(optarg) > 0)
+				igt_interactive_debug = strdup(optarg);
+			else
+				igt_interactive_debug = "all";
+			break;
 		case OPT_DEBUG:
 			igt_log_level = IGT_LOG_DEBUG;
 			if (optarg && strlen(optarg) > 0)
lib/igt_core.h +2 -0
index 5c5ee25..32041f6 100644
@@ -511,6 +511,8 @@ bool igt_run_in_simulation(void);
 
 void igt_skip_on_simulation(void);
 
+const char *igt_interactive_debug;
+
 /* structured logging */
 #ifndef IGT_LOG_DOMAIN
 #define IGT_LOG_DOMAIN (NULL)
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

Re: [PATCH i-g-t 06/15] lib: s/IGT_DEBUG_INTERACTIVE/--interactive-debug=var

Quoted 8 lines · Daniel Vetter
Quoted 5 lines · Rodrigo Vivi

Use cmdline variable for interactive debug instead of env var.

v2: Make interactive-debug domain optional and use "all" when not set.

I went ahead and applied this one to igt.

in igt_core.h:

const char *igt_interactive_debug;

and not declared in any .c. Which means we'll define one such global variable per compilation unit, not good :)

Signature · 5 lines
Damien
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

PATCH 1/1 lib: move igt_interactive_debug into igt_core.c

igt_interactive_debug should be defined in igt_core.c, rather than the header, to avoid it being defined more than once.

---
 lib/igt_core.c | 1 +
 lib/igt_core.h | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
lib/igt_core.c +1 -0
index c217a01..4ae3524 100644
@@ -209,6 +209,7 @@
  */
 
 static unsigned int exit_handler_count;
+const char *igt_interactive_debug;
 
 /* subtests helpers */
 static bool list_subtests = false;
lib/igt_core.h +1 -1
index c2c820d..0716000 100644
@@ -557,7 +557,7 @@ bool igt_run_in_simulation(void);
 
 void igt_skip_on_simulation(void);
 
-const char *igt_interactive_debug;
+extern const char *igt_interactive_debug;
 
 /* structured logging */
 enum igt_log_level {
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

PATCH 7/15 tests/kms_psr_sink_crc: Add manual mode.

In reply to Rodrigo Vivi

Sink CRC is the most reliable way to test PSR. However in some platforms apparently auto generated packages force panel to keep calculating CRC invalidating our current sink crc check over debugfs.

So, this manual test help us to find possible gaps on this platforms where we cannot trust on sink crc checks.

v2: Accept Daniel's suggestions:
* Avoid strcpy
* don't override assert definition
* Make --interactive-debug for every testcases instead using local --manual

v3: Sink CRC can be unreliable for other platforms as well so let's skip and warn
when we detect the misbehaviour instead hardcoded per platform.

---
 tests/kms_psr_sink_crc.c | 46 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 7 deletions(-)
tests/kms_psr_sink_crc.c +39 -7
index 155c25f..9903d00 100644
@@ -244,11 +244,14 @@ static void get_sink_crc(data_t *data, char *crc) {
 	int ret;
 	FILE *file;
 
+	if (igt_interactive_debug)
+		return;
+
 	file = igt_debugfs_fopen("i915_sink_crc_eDP1", "r");
 	igt_require(file);
 
 	ret = fscanf(file, "%s\n", crc);
-	igt_require(ret > 0);
+	igt_require_f(ret > 0, "Sink CRC is unreliable on this machine. Try manual debug with --interactive-debug=manual\n");
 
 	fclose(file);
 
@@ -271,6 +274,9 @@ static bool is_green(char *crc)
 	unsigned int rh, gh, bh, mask;
 	int ret;
 
+	if (igt_interactive_debug)
+		return false;
+
 	sscanf(color_mask, "%4x", &mask);
 
 	memcpy(rs, &crc[0], 4);
@@ -293,6 +299,16 @@ static bool is_green(char *crc)
 		(bh & mask) == 0);
 }
 
+static void assert_or_manual(bool condition, const char *expected)
+{
+	if (igt_interactive_debug)
+		igt_info("Is %s?\n", expected);
+	else
+		igt_debug("%s\n", expected);
+	igt_debug_wait_for_keypress("manual");
+	igt_assert(igt_interactive_debug || condition);
+}
+
 static void test_crc(data_t *data)
 {
 	uint32_t handle = data->fb_white.gem_handle;
@@ -300,18 +316,19 @@ static void test_crc(data_t *data)
 	void *ptr;
 	char ref_crc[12];
 	char crc[12];
+	const char *expected = "";
 
 	igt_plane_set_fb(data->primary, &data->fb_green);
 	igt_display_commit(&data->display);
 
 	/* Confirm that screen became Green */
 	get_sink_crc(data, ref_crc);
-	igt_assert(is_green(ref_crc));
+	assert_or_manual(is_green(ref_crc), "screen GREEN");
 
 	/* Confirm screen stays Green after PSR got active */
 	igt_assert(wait_psr_entry(data, 10));
 	get_sink_crc(data, ref_crc);
-	igt_assert(is_green(ref_crc));
+	assert_or_manual(is_green(ref_crc), "screen GREEN");
 
 	/* Setting a secondary fb/plane */
 	switch (data->test_plane) {
@@ -325,7 +342,10 @@ static void test_crc(data_t *data)
 	/* Confirm it is not Green anymore */
 	igt_assert(wait_psr_entry(data, 10));
 	get_sink_crc(data, ref_crc);
-	igt_assert(!is_green(ref_crc));
+	if (data->test_plane == PRIMARY)
+		assert_or_manual(!is_green(ref_crc), "screen WHITE");
+	else
+		assert_or_manual(!is_green(ref_crc), "GREEN background with WHITE box");
 
 	switch (data->op) {
 	case PAGE_FLIP:
@@ -333,7 +353,8 @@ static void test_crc(data_t *data)
 		igt_assert(drmModePageFlip(data->drm_fd, data->crtc_id,
 					   data->fb_green.fb_id, 0, NULL) == 0);
 		get_sink_crc(data, crc);
-		igt_assert(is_green(crc));
+		assert_or_manual(is_green(crc), "screen GREEN");
+		expected = "still GREEN";
 		break;
 	case MMAP_GTT:
 		ptr = gem_mmap__gtt(data->drm_fd, handle, data->mod_size,
@@ -342,6 +363,7 @@ static void test_crc(data_t *data)
 			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 		memset(ptr, 0xcc, data->mod_size);
 		munmap(ptr, data->mod_size);
+		expected = "BLACK or TRANSPARENT mark on top of plane in test";
 		break;
 	case MMAP_GTT_WAITING:
 		ptr = gem_mmap__gtt(data->drm_fd, handle, data->mod_size,
@@ -352,7 +374,11 @@ static void test_crc(data_t *data)
 		/* Printing white on white so the screen shouldn't change */
 		memset(ptr, 0xff, data->mod_size);
 		get_sink_crc(data, crc);
-		igt_assert(strcmp(ref_crc, crc) == 0);
+		if (data->test_plane == PRIMARY)
+			assert_or_manual(strcmp(ref_crc, crc) == 0, "screen WHITE");
+		else
+			assert_or_manual(strcmp(ref_crc, crc) == 0,
+			       "GREEN background with WHITE box");
 
 		igt_info("Waiting 10s...\n");
 		sleep(10);
@@ -360,6 +386,7 @@ static void test_crc(data_t *data)
 		/* Now lets print black to change the screen */
 		memset(ptr, 0, data->mod_size);
 		munmap(ptr, data->mod_size);
+		expected = "BLACK or TRANSPARENT mark on top of plane in test";
 		break;
 	case MMAP_CPU:
 		ptr = gem_mmap__cpu(data->drm_fd, handle, 0, data->mod_size, PROT_WRITE);
@@ -368,26 +395,31 @@ static void test_crc(data_t *data)
 		memset(ptr, 0, data->mod_size);
 		munmap(ptr, data->mod_size);
 		gem_sw_finish(data->drm_fd, handle);
+		expected = "BLACK or TRANSPARENT mark on top of plane in test";
 		break;
 	case BLT:
 		fill_blt(data, handle, 0);
+		expected = "BLACK or TRANSPARENT mark on top of plane in test";
 		break;
 	case RENDER:
 		fill_render(data, handle, 0);
+		expected = "BLACK or TRANSPARENT mark on top of plane in test";
 		break;
 	case PLANE_MOVE:
 		/* Only in use when testing Sprite and Cursor */
 		igt_plane_set_position(test_plane, 500, 500);
 		igt_display_commit(&data->display);
+		expected = "White box moved to 500x500";
 		break;
 	case PLANE_ONOFF:
 		/* Only in use when testing Sprite and Cursor */
 		igt_plane_set_fb(test_plane, NULL);
 		igt_display_commit(&data->display);
+		expected = "screen GREEN";
 		break;
 	}
 	get_sink_crc(data, crc);
-	igt_assert(strcmp(ref_crc, crc) != 0);
+	assert_or_manual(strcmp(ref_crc, crc) != 0, expected);
 }
 
 static void test_cleanup(data_t *data) {
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

PATCH 8/15 lib/igt_aux: Introduce igt_debug_warn_and_wait_for_key.

In reply to Rodrigo Vivi

This is an extention of igt_debug_wait_for_keypress that also can have customized message and return key pressed.

v2: This is actualy a v2. V1 was an extension of original
igt_debug_wait_for_keypress but it was nacked.

---
 lib/igt_aux.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_aux.h |  1 +
 2 files changed, 47 insertions(+)
lib/igt_aux.c +46 -0
index 54e5c58..8f25845 100644
@@ -488,6 +488,52 @@ void igt_debug_wait_for_keypress(const char *var)
 	tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );
 }
 
+/**
+ * igt_debug_wait_for_key:
+ * @var: var lookup to to enable this wait
+ * @msg: message to be printed before wait for key
+ *
+ * Waits for a key press when run interactively and when the corresponding debug
+ * var is set in the --interactive-debug=<var> variable. Multiple keys
+ * can be specified as a comma-separated list or alternatively "all" if a wait
+ * should happen for all cases.
+ *
+ * When not connected to a terminal interactive_debug is ignored
+ * and execution immediately continues.
+ *
+ * This is useful for display tests where under certain situation manual
+ * inspection of the display is useful. Or when running a testcase in the
+ * background.
+ *
+ * Returns: key pressed block
+ */
+char igt_debug_warn_and_wait_for_key(const char *var, const char *msg)
+{
+	struct termios oldt, newt;
+	char key = 0;
+
+	if (!isatty(STDIN_FILENO))
+		return key;
+
+	if (!igt_interactive_debug)
+		return key;
+
+	if (!strstr(igt_interactive_debug, var) &&
+	    !strstr(igt_interactive_debug, "all"))
+		return key;
+
+	igt_info("%s", msg);
+
+	tcgetattr ( STDIN_FILENO, &oldt );
+	newt = oldt;
+	newt.c_lflag &= ~ICANON;
+	tcsetattr ( STDIN_FILENO, TCSANOW, &newt );
+	key = getchar();
+	tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );
+
+	return key;
+}
+
 #define POWER_DIR "/sys/devices/pci0000:00/0000:00:02.0/power"
 /* We just leak this on exit ... */
 int pm_status_fd = -1;
lib/igt_aux.h +1 -0
index 798a5b4..87b3e35 100644
@@ -65,6 +65,7 @@ void igt_system_suspend_autoresume(void);
 void igt_drop_root(void);
 
 void igt_debug_wait_for_keypress(const char *var);
+char igt_debug_warn_and_wait_for_key(const char *var, const char *msg);
 
 enum igt_runtime_pm_status {
 	IGT_RUNTIME_PM_STATUS_ACTIVE,
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

PATCH 9/15 tests/kms_psr_sink_crc: Use pressed key to pass/fail.

In reply to Rodrigo Vivi

This is useful when 1 person is running all tests and other one is reading log willing to know what tests passed and which failed. So tester is able to run all tests without stop and send log to developer.

v2: Rebased after igt_debug_warn_and_wait_for_key

---
 tests/kms_psr_sink_crc.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
tests/kms_psr_sink_crc.c +15 -5
index 9903d00..553a1f8 100644
@@ -301,11 +301,21 @@ static bool is_green(char *crc)
 
 static void assert_or_manual(bool condition, const char *expected)
 {
-	if (igt_interactive_debug)
-		igt_info("Is %s?\n", expected);
-	else
-		igt_debug("%s\n", expected);
-	igt_debug_wait_for_keypress("manual");
+	char msg[50];
+	char c;
+
+	igt_debug("%s\n", expected);
+
+	sprintf(msg, "Is %s [Y/n]? ", expected);
+	c = igt_debug_warn_and_wait_for_key("manual", msg);
+
+	if (c) {
+		if (c == 'n' || c == 'N')
+			igt_fail(-1);
+		else
+			igt_info("\n");
+	}
+
 	igt_assert(igt_interactive_debug || condition);
 }
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw

PATCH 10/15 tests/kms_psr_sink_crc: Use PSR wakeup 2 + timeout for waiting psr active.

In reply to Rodrigo Vivi

This wakeup time is now set from VBT and sometimes it can be bigger than 10 seconds we used here.
So let's use at least 2 seconds plus VBT. We grab this info from debugfs.

Also since this timeout can be bigger, in manual mode we warn tester we are waiting.

---
 tests/kms_psr_sink_crc.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
tests/kms_psr_sink_crc.c +22 -4
index 553a1f8..285600f 100644
@@ -84,6 +84,7 @@ typedef struct {
 	struct igt_fb fb_green, fb_white;
 	igt_plane_t *primary, *sprite, *cursor;
 	int mod_size;
+	int psr_wakeup_time;
 } data_t;
 
 static void create_cursor_fb(data_t *data)
@@ -195,8 +196,19 @@ static bool psr_enabled(data_t *data)
 	ret = fscanf(file, "Enabled: %s\n", str);
 	igt_assert(ret != 0);
 
+	/* This function will return if psr is enabled, however we can reuse
+	 * it to read and set wakeup_time */
+	ret = strcmp(str, "yes") == 0;
+
+	fscanf(file, "Active: %s\n", str);
+	fscanf(file, "Busy frontbuffer bits: %s\n", str);
+	fscanf(file, "Re-enable work scheduled: %s\n", str);
+	fscanf(file, "HW Enabled & Active bit: %s\n", str);
+	fscanf(file, "Link standby: %s\n", str);
+	fscanf(file, "Wakeup time: %d\n", &data->psr_wakeup_time);
+
 	fclose(file);
-	return strcmp(str, "yes") == 0;
+	return ret;
 }
 
 static bool psr_active(data_t *data)
@@ -230,8 +242,14 @@ static bool psr_active(data_t *data)
 	return strcmp(str, "yes") == 0;
 }
 
-static bool wait_psr_entry(data_t *data, int timeout)
+static bool wait_psr_entry(data_t *data)
 {
+	int timeout = 2 + data->psr_wakeup_time;
+
+	if (igt_interactive_debug)
+		igt_info("Waiting up to %d seconds for PSR to get active...\n",
+			 timeout);
+
 	while (timeout--) {
 		if (psr_active(data))
 			return true;
@@ -336,7 +354,7 @@ static void test_crc(data_t *data)
 	assert_or_manual(is_green(ref_crc), "screen GREEN");
 
 	/* Confirm screen stays Green after PSR got active */
-	igt_assert(wait_psr_entry(data, 10));
+	igt_assert(wait_psr_entry(data));
 	get_sink_crc(data, ref_crc);
 	assert_or_manual(is_green(ref_crc), "screen GREEN");
 
@@ -350,7 +368,7 @@ static void test_crc(data_t *data)
 	igt_display_commit(&data->display);
 
 	/* Confirm it is not Green anymore */
-	igt_assert(wait_psr_entry(data, 10));
+	igt_assert(wait_psr_entry(data));
 	get_sink_crc(data, ref_crc);
 	if (data->test_plane == PRIMARY)
 		assert_or_manual(!is_green(ref_crc), "screen WHITE");
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

PATCH 11/15 test/kms_psr_sink_crc: Split plane setup operations

In reply to Rodrigo Vivi

No functional changes. This reorg will allow to do some operations like suspend/resume and dpms off/on at some specific points where we know PSR state.

---
 tests/kms_psr_sink_crc.c | 141 +++++++++++++++++++++++++----------------------
 1 file changed, 75 insertions(+), 66 deletions(-)
tests/kms_psr_sink_crc.c +75 -66
index 285600f..4e4a4cd 100644
@@ -85,6 +85,8 @@ typedef struct {
 	igt_plane_t *primary, *sprite, *cursor;
 	int mod_size;
 	int psr_wakeup_time;
+	drmModeModeInfo *mode;
+	igt_output_t *output;
 } data_t;
 
 static void create_cursor_fb(data_t *data)
@@ -102,9 +104,32 @@ static void create_cursor_fb(data_t *data)
 	igt_assert(cairo_status(cr) == 0);
 }
 
+
+static void setup_output(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+
+	for_each_connected_output(display, output) {
+		drmModeConnectorPtr c = output->config.connector;
+
+		if (c->connector_type != DRM_MODE_CONNECTOR_eDP ||
+		    c->connection != DRM_MODE_CONNECTED)
+			continue;
+
+		igt_output_set_pipe(output, PIPE_ANY);
+		data->crtc_id = output->config.crtc->crtc_id;
+		data->output = output;
+		data->mode = igt_output_get_mode(output);
+
+		return;
+	}
+}
+
 static void display_init(data_t *data)
 {
 	igt_display_init(&data->display, data->drm_fd);
+	setup_output(data);
 }
 
 static void display_fini(data_t *data)
@@ -337,7 +362,7 @@ static void assert_or_manual(bool condition, const char *expected)
 	igt_assert(igt_interactive_debug || condition);
 }
 
-static void test_crc(data_t *data)
+static void run_test(data_t *data)
 {
 	uint32_t handle = data->fb_white.gem_handle;
 	igt_plane_t *test_plane;
@@ -346,18 +371,10 @@ static void test_crc(data_t *data)
 	char crc[12];
 	const char *expected = "";
 
-	igt_plane_set_fb(data->primary, &data->fb_green);
-	igt_display_commit(&data->display);
-
 	/* Confirm that screen became Green */
 	get_sink_crc(data, ref_crc);
 	assert_or_manual(is_green(ref_crc), "screen GREEN");
 
-	/* Confirm screen stays Green after PSR got active */
-	igt_assert(wait_psr_entry(data));
-	get_sink_crc(data, ref_crc);
-	assert_or_manual(is_green(ref_crc), "screen GREEN");
-
 	/* Setting a secondary fb/plane */
 	switch (data->test_plane) {
 	case PRIMARY: default: test_plane = data->primary; break;
@@ -463,75 +480,58 @@ static void test_cleanup(data_t *data) {
 	igt_remove_fb(data->drm_fd, &data->fb_white);
 }
 
-static void run_test(data_t *data)
+static void setup_test_plane(data_t *data)
 {
-	igt_display_t *display = &data->display;
-	igt_output_t *output;
-	drmModeModeInfo *mode;
 	uint32_t white_h, white_v;
 
-	for_each_connected_output(display, output) {
-		drmModeConnectorPtr c = output->config.connector;
+	igt_create_color_fb(data->drm_fd,
+			    data->mode->hdisplay, data->mode->vdisplay,
+			    DRM_FORMAT_XRGB8888, I915_TILING_X,
+			    0.0, 1.0, 0.0,
+			    &data->fb_green);
 
-		if (c->connector_type != DRM_MODE_CONNECTOR_eDP ||
-		    c->connection != DRM_MODE_CONNECTED)
-			continue;
+	data->primary = igt_output_get_plane(data->output, IGT_PLANE_PRIMARY);
+	igt_plane_set_fb(data->primary, NULL);
 
-		igt_output_set_pipe(output, PIPE_ANY);
-		data->crtc_id = output->config.crtc->crtc_id;
+	white_h = data->mode->hdisplay;
+	white_v = data->mode->vdisplay;
 
-		mode = igt_output_get_mode(output);
+	/* Ignoring pitch and bpp to avoid changing full screen */
+	data->mod_size = white_h * white_v;
 
+	switch (data->test_plane) {
+	case SPRITE:
+		data->sprite = igt_output_get_plane(data->output,
+						    IGT_PLANE_2);
+		igt_plane_set_fb(data->sprite, NULL);
+		/* To make it different for human eyes let's make
+		 * sprite visible in only one quarter of the primary
+		 */
+		white_h = white_h/2;
+		white_v = white_v/2;
+	case PRIMARY:
 		igt_create_color_fb(data->drm_fd,
-				    mode->hdisplay, mode->vdisplay,
+				    white_h, white_v,
 				    DRM_FORMAT_XRGB8888, I915_TILING_X,
-				    0.0, 1.0, 0.0,
-				    &data->fb_green);
-
-		data->primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
-		igt_plane_set_fb(data->primary, NULL);
-
-		white_h = mode->hdisplay;
-		white_v = mode->vdisplay;
-
-		/* Ignoring pitch and bpp to avoid changing full screen */
-		data->mod_size = white_h * white_v;
-
-		switch (data->test_plane) {
-		case SPRITE:
-			data->sprite = igt_output_get_plane(output,
-							    IGT_PLANE_2);
-			igt_plane_set_fb(data->sprite, NULL);
-			/* To make it different for human eyes let's make
-			 * sprite visible in only one quarter of the primary
-			 */
-			white_h = white_h/2;
-			white_v = white_v/2;
-		case PRIMARY:
-			igt_create_color_fb(data->drm_fd,
-					    white_h, white_v,
-					    DRM_FORMAT_XRGB8888, I915_TILING_X,
-					    1.0, 1.0, 1.0,
-					    &data->fb_white);
-			break;
-		case CURSOR:
-			data->cursor = igt_output_get_plane(output,
-							    IGT_PLANE_CURSOR);
-			igt_plane_set_fb(data->cursor, NULL);
-			create_cursor_fb(data);
-			igt_plane_set_position(data->cursor, 0, 0);
-
-			/* Cursor is 64 x 64, ignoring pitch and bbp again */
-			data->mod_size = 64 * 64;
-			break;
-		}
+				    1.0, 1.0, 1.0,
+				    &data->fb_white);
+		break;
+	case CURSOR:
+		data->cursor = igt_output_get_plane(data->output,
+						    IGT_PLANE_CURSOR);
+		igt_plane_set_fb(data->cursor, NULL);
+		create_cursor_fb(data);
+		igt_plane_set_position(data->cursor, 0, 0);
 
-		igt_display_commit(&data->display);
+		/* Cursor is 64 x 64, ignoring pitch and bbp again */
+		data->mod_size = 64 * 64;
+		break;
+	}
 
-		test_crc(data);
+	igt_display_commit(&data->display);
 
-		test_cleanup(data);
-	}
+	igt_plane_set_fb(data->primary, &data->fb_green);
+	igt_display_commit(&data->display);
 }
 
 static int opt_handler(int opt, int opt_index)
@@ -580,7 +580,10 @@ int main(int argc, char *argv[])
 		igt_subtest_f("primary_%s", op_str(op)) {
 			data.test_plane = PRIMARY;
 			data.op = op;
+			setup_test_plane(&data);
+			igt_assert(wait_psr_entry(&data));
 			run_test(&data);
+			test_cleanup(&data);
 		}
 	}
 
@@ -588,7 +591,10 @@ int main(int argc, char *argv[])
 		igt_subtest_f("sprite_%s", op_str(op)) {
 			data.test_plane = SPRITE;
 			data.op = op;
+			setup_test_plane(&data);
+			igt_assert(wait_psr_entry(&data));
 			run_test(&data);
+			test_cleanup(&data);
 		}
 	}
 
@@ -596,7 +602,10 @@ int main(int argc, char *argv[])
 		igt_subtest_f("cursor_%s", op_str(op)) {
 			data.test_plane = CURSOR;
 			data.op = op;
+			setup_test_plane(&data);
+			igt_assert(wait_psr_entry(&data));
 			run_test(&data);
+			test_cleanup(&data);
 		}
 	}
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

PATCH 12/15 test/kms_psr_sink_crc: Add suspend/resume tests

In reply to Rodrigo Vivi
---
 tests/kms_psr_sink_crc.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
tests/kms_psr_sink_crc.c +24 -0
index 4e4a4cd..331ac5b 100644
@@ -609,6 +609,30 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	igt_subtest_f("suspend_psr_active") {
+		data.test_plane = PRIMARY;
+		data.op = RENDER;
+		setup_test_plane(&data);
+		igt_assert(wait_psr_entry(&data));
+
+		igt_system_suspend_autoresume();
+
+		run_test(&data);
+		test_cleanup(&data);
+	}
+
+	igt_subtest_f("suspend_psr_exit") {
+		data.test_plane = CURSOR;
+		data.op = PLANE_MOVE;
+		setup_test_plane(&data);
+
+		igt_system_suspend_autoresume();
+
+		igt_assert(wait_psr_entry(&data));
+		run_test(&data);
+		test_cleanup(&data);
+	}
+
 	igt_fixture {
 		drm_intel_bufmgr_destroy(data.bufmgr);
 		display_fini(&data);
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw

PATCH 13/15 test/kms_psr_sink_crc: Add dpms off/on tests.

In reply to Rodrigo Vivi
---
 tests/kms_psr_sink_crc.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
tests/kms_psr_sink_crc.c +33 -0
index 331ac5b..9616b4c 100644
@@ -534,6 +534,15 @@ static void setup_test_plane(data_t *data)
 	igt_display_commit(&data->display);
 }
 
+static void dpms_off_on(data_t data)
+{
+	kmstest_set_connector_dpms(data.drm_fd, data.output->config.connector,
+				   DRM_MODE_DPMS_OFF);
+	sleep(1);
+	kmstest_set_connector_dpms(data.drm_fd, data.output->config.connector,
+				   DRM_MODE_DPMS_ON);
+}
+
 static int opt_handler(int opt, int opt_index)
 {
 	switch (opt) {
@@ -633,6 +642,30 @@ int main(int argc, char *argv[])
 		test_cleanup(&data);
 	}
 
+	igt_subtest_f("dpms_off_psr_active") {
+		data.test_plane = PRIMARY;
+		data.op = RENDER;
+		setup_test_plane(&data);
+		igt_assert(wait_psr_entry(&data));
+
+		dpms_off_on(data);
+
+		run_test(&data);
+		test_cleanup(&data);
+	}
+
+	igt_subtest_f("dpms_off_psr_exit") {
+		data.test_plane = SPRITE;
+		data.op = PLANE_ONOFF;
+		setup_test_plane(&data);
+
+		dpms_off_on(data);
+
+		igt_assert(wait_psr_entry(&data));
+		run_test(&data);
+		test_cleanup(&data);
+	}
+
 	igt_fixture {
 		drm_intel_bufmgr_destroy(data.bufmgr);
 		display_fini(&data);
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

PATCH 14/15 lib/igt_core: introduce --loop.

In reply to Rodrigo Vivi

This loop option can help intensive tests everywhere.
The only caveat is that tests reimplementing main function has to implement his own loop.

---
 lib/igt_core.c | 11 +++++++++++
 lib/igt_core.h | 18 ++++++++++++------
 2 files changed, 23 insertions(+), 6 deletions(-)
lib/igt_core.c +11 -0
index bd655be..3724348 100644
@@ -234,6 +234,7 @@ enum {
  OPT_DESCRIPTION,
  OPT_DEBUG,
  OPT_INTERACTIVE_DEBUG,
+ OPT_LOOP,
  OPT_HELP = 'h'
 };
 
@@ -405,6 +406,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
 		   "  --run-subtest <pattern>\n"
 		   "  --debug[=log-domain]\n"
 		   "  --interactive-debug[=domain]\n"
+		   "  --loop[=times]\n"
 		   "  --help-description\n"
 		   "  --help\n");
 	if (help_str)
@@ -438,6 +440,7 @@ static int common_init(int argc, char **argv,
 		{"help-description", 0, 0, OPT_DESCRIPTION},
 		{"debug", optional_argument, 0, OPT_DEBUG},
 		{"interactive-debug", optional_argument, 0, OPT_INTERACTIVE_DEBUG},
+		{"loop", optional_argument, 0, OPT_LOOP},
 		{"help", 0, 0, OPT_HELP},
 		{0, 0, 0, 0}
 	};
@@ -520,9 +523,17 @@ static int common_init(int argc, char **argv,
 		       std_short_opts);
 	assert(ret >= 0);
 
+	igt_loop = 0;
+
 	while ((c = getopt_long(argc, argv, short_opts, combined_opts,
 			       &option_index)) != -1) {
 		switch(c) {
+		case OPT_LOOP:
+			if (optarg && strlen(optarg) > 0)
+				igt_loop = atoi(optarg);
+			else
+				igt_loop = -1;
+			break;
 		case OPT_INTERACTIVE_DEBUG:
 			if (optarg && strlen(optarg) > 0)
 				igt_interactive_debug = strdup(optarg);
lib/igt_core.h +12 -6
index 32041f6..4dbe893 100644
@@ -175,9 +175,11 @@ bool igt_only_list_subtests(void);
 #define igt_main \
 	static void igt_tokencat(__real_main, __LINE__)(void); \
 	int main(int argc, char **argv) { \
-		igt_subtest_init(argc, argv); \
-		igt_tokencat(__real_main, __LINE__)(); \
-		igt_exit(); \
+		do { \
+			igt_subtest_init(argc, argv);  \
+			igt_tokencat(__real_main, __LINE__)();	\
+			igt_exit();				\
+		} while (igt_loop == -1 || --igt_loop);		\
 	} \
 	static void igt_tokencat(__real_main, __LINE__)(void) \
 
@@ -198,9 +200,11 @@ void igt_simple_init_parse_opts(int argc, char **argv,
 #define igt_simple_main \
 	static void igt_tokencat(__real_main, __LINE__)(void); \
 	int main(int argc, char **argv) { \
-		igt_simple_init(argc, argv); \
-		igt_tokencat(__real_main, __LINE__)(); \
-		igt_exit(); \
+		do { \
+			igt_simple_init(argc, argv);   \
+			igt_tokencat(__real_main, __LINE__)();	\
+			igt_exit();					\
+		} while (igt_loop == -1 || --igt_loop);			\
 	} \
 	static void igt_tokencat(__real_main, __LINE__)(void) \
 
@@ -511,6 +515,8 @@ bool igt_run_in_simulation(void);
 
 void igt_skip_on_simulation(void);
 
+int igt_loop;
+
 const char *igt_interactive_debug;
 
 /* structured logging */
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw

Re: [PATCH i-g-t 14/15] lib/igt_core: introduce --loop.

Quoted 2 lines · Rodrigo Vivi

This loop option can help intensive tests everywhere.
The only caveat is that tests reimplementing main function has to implement his own loop.

Could you also add a short description of the new command line options to the test program documentation?

Quoted 99 lines
---
 lib/igt_core.c | 11 +++++++++++
 lib/igt_core.h | 18 ++++++++++++------
 2 files changed, 23 insertions(+), 6 deletions(-)
lib/igt_core.c +11 -0
index bd655be..3724348 100644
@@ -234,6 +234,7 @@ enum {
  OPT_DESCRIPTION,
  OPT_DEBUG,
  OPT_INTERACTIVE_DEBUG,
+ OPT_LOOP,
  OPT_HELP = 'h'
 };
 
@@ -405,6 +406,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
                   "  --run-subtest <pattern>\n"
                   "  --debug[=log-domain]\n"
                   "  --interactive-debug[=domain]\n"
+                  "  --loop[=times]\n"
                   "  --help-description\n"
                   "  --help\n");
        if (help_str)
@@ -438,6 +440,7 @@ static int common_init(int argc, char **argv,
                {"help-description", 0, 0, OPT_DESCRIPTION},
                {"debug", optional_argument, 0, OPT_DEBUG},
                {"interactive-debug", optional_argument, 0, OPT_INTERACTIVE_DEBUG},
+               {"loop", optional_argument, 0, OPT_LOOP},
                {"help", 0, 0, OPT_HELP},
                {0, 0, 0, 0}
        };
@@ -520,9 +523,17 @@ static int common_init(int argc, char **argv,
                       std_short_opts);
        assert(ret >= 0);
 
+       igt_loop = 0;
+
        while ((c = getopt_long(argc, argv, short_opts, combined_opts,
                               &option_index)) != -1) {
                switch(c) {
+               case OPT_LOOP:
+                       if (optarg && strlen(optarg) > 0)
+                               igt_loop = atoi(optarg);
+                       else
+                               igt_loop = -1;
+                       break;
                case OPT_INTERACTIVE_DEBUG:
                        if (optarg && strlen(optarg) > 0)
                                igt_interactive_debug = strdup(optarg);
lib/igt_core.h +12 -7
index 32041f6..4dbe893 100644
@@ -175,9 +175,11 @@ bool igt_only_list_subtests(void);
 #define igt_main \
        static void igt_tokencat(__real_main, __LINE__)(void); \
        int main(int argc, char **argv) { \
-               igt_subtest_init(argc, argv); \
-               igt_tokencat(__real_main, __LINE__)(); \
-               igt_exit(); \
+               do { \
+                       igt_subtest_init(argc, argv);  \
+                       igt_tokencat(__real_main, __LINE__)();  \
+                       igt_exit();                             \
+               } while (igt_loop == -1 || --igt_loop);         \
        } \
        static void igt_tokencat(__real_main, __LINE__)(void) \
 
@@ -198,9 +200,11 @@ void igt_simple_init_parse_opts(int argc, char **argv,
 #define igt_simple_main \
        static void igt_tokencat(__real_main, __LINE__)(void); \
        int main(int argc, char **argv) { \
-               igt_simple_init(argc, argv); \
-               igt_tokencat(__real_main, __LINE__)(); \
-               igt_exit(); \
+               do { \
+                       igt_simple_init(argc, argv);   \
+                       igt_tokencat(__real_main, __LINE__)();  \
+                       igt_exit();                                     \
+               } while (igt_loop == -1 || --igt_loop);                 \
        } \
        static void igt_tokencat(__real_main, __LINE__)(void) \
 
@@ -511,6 +515,8 @@ bool igt_run_in_simulation(void);
 
 void igt_skip_on_simulation(void);
 
+int igt_loop;
+
 const char *igt_interactive_debug;
 
 /* structured logging */
--

2.1.0

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#18 lore raw

PATCH 15/15 tests/kms_psr_sink_crc: Add own loop.

In reply to Rodrigo Vivi
---
 tests/kms_psr_sink_crc.c | 119 ++++++++++++++++++++++++-----------------------
 1 file changed, 61 insertions(+), 58 deletions(-)
tests/kms_psr_sink_crc.c +61 -58
index 9616b4c..741c45d 100644
@@ -585,86 +585,89 @@ int main(int argc, char *argv[])
 		display_init(&data);
 	}
 
-	for (op = PAGE_FLIP; op <= RENDER; op++) {
-		igt_subtest_f("primary_%s", op_str(op)) {
+	do {
+		for (op = PAGE_FLIP; op <= RENDER; op++) {
+			igt_subtest_f("primary_%s", op_str(op)) {
+				data.test_plane = PRIMARY;
+				data.op = op;
+				setup_test_plane(&data);
+				igt_assert(wait_psr_entry(&data));
+				run_test(&data);
+				test_cleanup(&data);
+			}
+		}
+
+		for (op = MMAP_GTT; op <= PLANE_ONOFF; op++) {
+			igt_subtest_f("sprite_%s", op_str(op)) {
+				data.test_plane = SPRITE;
+				data.op = op;
+				setup_test_plane(&data);
+				igt_assert(wait_psr_entry(&data));
+				run_test(&data);
+				test_cleanup(&data);
+			}
+		}
+
+		for (op = MMAP_GTT; op <= PLANE_ONOFF; op++) {
+			igt_subtest_f("cursor_%s", op_str(op)) {
+				data.test_plane = CURSOR;
+				data.op = op;
+				setup_test_plane(&data);
+				igt_assert(wait_psr_entry(&data));
+				run_test(&data);
+				test_cleanup(&data);
+			}
+		}
+
+		igt_subtest_f("suspend_psr_active") {
 			data.test_plane = PRIMARY;
-			data.op = op;
+			data.op = RENDER;
 			setup_test_plane(&data);
 			igt_assert(wait_psr_entry(&data));
+
+			igt_system_suspend_autoresume();
+
 			run_test(&data);
 			test_cleanup(&data);
 		}
-	}
 
-	for (op = MMAP_GTT; op <= PLANE_ONOFF; op++) {
-		igt_subtest_f("sprite_%s", op_str(op)) {
-			data.test_plane = SPRITE;
-			data.op = op;
+		igt_subtest_f("suspend_psr_exit") {
+			data.test_plane = CURSOR;
+			data.op = PLANE_MOVE;
 			setup_test_plane(&data);
+
+			igt_system_suspend_autoresume();
+
 			igt_assert(wait_psr_entry(&data));
 			run_test(&data);
 			test_cleanup(&data);
 		}
-	}
 
-	for (op = MMAP_GTT; op <= PLANE_ONOFF; op++) {
-		igt_subtest_f("cursor_%s", op_str(op)) {
-			data.test_plane = CURSOR;
-			data.op = op;
+		igt_subtest_f("dpms_off_psr_active") {
+			data.test_plane = PRIMARY;
+			data.op = RENDER;
 			setup_test_plane(&data);
 			igt_assert(wait_psr_entry(&data));
+
+			dpms_off_on(data);
+
 			run_test(&data);
 			test_cleanup(&data);
 		}
-	}
 
-	igt_subtest_f("suspend_psr_active") {
-		data.test_plane = PRIMARY;
-		data.op = RENDER;
-		setup_test_plane(&data);
-		igt_assert(wait_psr_entry(&data));
-
-		igt_system_suspend_autoresume();
-
-		run_test(&data);
-		test_cleanup(&data);
-	}
-
-	igt_subtest_f("suspend_psr_exit") {
-		data.test_plane = CURSOR;
-		data.op = PLANE_MOVE;
-		setup_test_plane(&data);
-
-		igt_system_suspend_autoresume();
-
-		igt_assert(wait_psr_entry(&data));
-		run_test(&data);
-		test_cleanup(&data);
-	}
-
-	igt_subtest_f("dpms_off_psr_active") {
-		data.test_plane = PRIMARY;
-		data.op = RENDER;
-		setup_test_plane(&data);
-		igt_assert(wait_psr_entry(&data));
-
-		dpms_off_on(data);
-
-		run_test(&data);
-		test_cleanup(&data);
-	}
+		igt_subtest_f("dpms_off_psr_exit") {
+			data.test_plane = SPRITE;
+			data.op = PLANE_ONOFF;
+			setup_test_plane(&data);
 
-	igt_subtest_f("dpms_off_psr_exit") {
-		data.test_plane = SPRITE;
-		data.op = PLANE_ONOFF;
-		setup_test_plane(&data);
+			dpms_off_on(data);
 
-		dpms_off_on(data);
+			igt_assert(wait_psr_entry(&data));
+			run_test(&data);
+			test_cleanup(&data);
+		}
 
-		igt_assert(wait_psr_entry(&data));
-		run_test(&data);
-		test_cleanup(&data);
-	}
+	} while (igt_loop == -1 || --igt_loop);
 
 	igt_fixture {
 		drm_intel_bufmgr_destroy(data.bufmgr);
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx