Skip to contentSkip to conversation

tests/kms_psr_sink_crc: moving usleep around.

PATCH New Rodrigo Vivi 1 participant 5 messages Sep 4, 2014 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/kms_psr_sink_crc: moving usleep around.

Lets just do this small sleep to allow human eyes to see what is happening, but let's avoid any kind of interference on the actual test.

---
 tests/kms_psr_sink_crc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tests/kms_psr_sink_crc.c +5 -1
index 0917a7f..bbe18f0 100644
@@ -327,6 +327,11 @@ static void get_sink_crc(data_t *data, char *crc) {
 	igt_require(ret > 0);
 
 	fclose(file);
+
+	/* The important value was already taken.
+	 * Now give a time for human eyes
+	 */
+	usleep(300000);
 }
 
 static void test_crc(data_t *data)
@@ -342,7 +347,6 @@ static void test_crc(data_t *data)
 					     1, 1) == 0);
 	}
 
-	usleep(300000);
 	igt_assert(wait_psr_entry(data, 10));
 	get_sink_crc(data, ref_crc);
 
Signature · 1 line
1.9.3
#1 lore raw

PATCH 1/1 lib/igt_core: add igt_debug_wait

That allows you to read the debug and look to the screen to make sure what is on the screen is what you are expecting on debug line.

---
 lib/igt_core.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
lib/igt_core.h +13 -0
index b4eb724..e006819 100644
@@ -514,6 +514,19 @@ void igt_vlog(enum igt_log_level level, const char *format, va_list args);
 #define igt_debug(f...) igt_log(IGT_LOG_DEBUG, f)
 
 /**
+ * igt_debug_wait:
+ * @wait: seconds to keep waiting
+ * @...: format string and optional arguments
+ *
+ * Wrapper for igt_log() for message at the IGT_LOG_DEBUG level with
+ * waiting time in seconds.
+ */
+#define igt_debug_wait(wait, f...) \
+	igt_log(IGT_LOG_DEBUG, f); \
+	for (int w = 0; igt_log_level == IGT_LOG_DEBUG && w < (wait); w++) \
+		sleep(1);
+
+/**
  * igt_info:
  * @...: format string and optional arguments
  *
Signature · 1 line
1.9.3
#2 lore raw

PATCH 1/1 igt/kms_psr_sink_crc: Add debug for CRC

In reply to Rodrigo Vivi

This helps to debug and check if the CRC you are reading correspond what you are seeing on the screen

---
 tests/kms_psr_sink_crc.c | 2 ++
 1 file changed, 2 insertions(+)
tests/kms_psr_sink_crc.c +2 -0
index bbe18f0..51e54a7 100644
@@ -328,6 +328,8 @@ static void get_sink_crc(data_t *data, char *crc) {
 
 	fclose(file);
 
+	igt_debug_wait(1, "%s\n", crc);
+
 	/* The important value was already taken.
 	 * Now give a time for human eyes
 	 */
Signature · 1 line
1.9.3
#3 lore raw

PATCH 1/1 lib/igt_core: Introduce a dry run debug option

In reply to Rodrigo Vivi

IGT_DRY_RUN allows you to run tests independent of any desired condition. For instance you can allow tests to run with the feature in test disabled in order to compare what results you should expect when the feature is actually enabled.

---
 lib/igt_core.c | 16 ++++++++++------
 lib/igt_core.h |  7 +++++++
 2 files changed, 17 insertions(+), 6 deletions(-)
lib/igt_core.c +10 -6
index 7f14b17..63c6550 100644
@@ -346,19 +346,23 @@ static int common_init(int argc, char **argv,
 	int extra_opt_count;
 	int all_opt_count;
 	int ret = 0;
-	char *env = getenv("IGT_LOG_LEVEL");
+	char *log_level = getenv("IGT_LOG_LEVEL");
+	char *dry_run = getenv("IGT_DRY_RUN");
 
-	if (env) {
-		if (strcmp(env, "debug") == 0)
+	if (log_level) {
+		if (strcmp(log_level, "debug") == 0)
 			igt_log_level = IGT_LOG_DEBUG;
-		else if (strcmp(env, "info") == 0)
+		else if (strcmp(log_level, "info") == 0)
 			igt_log_level = IGT_LOG_INFO;
-		else if (strcmp(env, "warn") == 0)
+		else if (strcmp(log_level, "warn") == 0)
 			igt_log_level = IGT_LOG_WARN;
-		else if (strcmp(env, "none") == 0)
+		else if (strcmp(log_level, "none") == 0)
 			igt_log_level = IGT_LOG_NONE;
 	}
 
+	if (dry_run)
+	    igt_dry_run = true;
+
 	command_str = argv[0];
 	if (strrchr(command_str, '/'))
 		command_str = strrchr(command_str, '/') + 1;
lib/igt_core.h +7 -0
index e006819..a6478a4 100644
@@ -493,6 +493,13 @@ bool igt_run_in_simulation(void);
 
 void igt_skip_on_simulation(void);
 
+/* IGT_DRY_RUN allows you to run tests independent of any desired condition.
+ * For instance you can allow tests to run with the feature in test disabled
+ * in order to compare what results you should expect when the feature is
+ * actually enabled.
+ */
+bool igt_dry_run;
+
 /* structured logging */
 enum igt_log_level {
 	IGT_LOG_DEBUG,
Signature · 1 line
1.9.3
#4 lore raw

PATCH 1/1 tests/kms_psr_sink_crc: Dry run with PSR disabled.

In reply to Rodrigo Vivi

This allows to run tests with psr disabled and know what to expect when PSR is actually enabled.

---
 tests/kms_psr_sink_crc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/kms_psr_sink_crc.c +8 -0
index 51e54a7..1380ca4 100644
@@ -72,6 +72,7 @@ typedef struct {
 	igt_display_t display;
 	struct igt_fb fb[2];
 	igt_plane_t *plane[2];
+	bool running_with_psr_disabled;
 } data_t;
 
 static const char *tests_str(enum tests test)
@@ -264,6 +265,9 @@ static bool psr_enabled(data_t *data)
 	FILE *file;
 	char str[4];
 
+	if (data->running_with_psr_disabled)
+		return true;
+
 	file = igt_debugfs_fopen("i915_edp_psr_status", "r");
 	igt_require(file);
 
@@ -284,6 +288,9 @@ static bool psr_active(data_t *data)
 	FILE *file;
 	char str[4];
 
+	if (data->running_with_psr_disabled)
+		return true;
+
 	file = igt_debugfs_fopen("i915_edp_psr_status", "r");
 	igt_require(file);
 
@@ -604,6 +611,7 @@ igt_main
 		kmstest_set_vt_graphics_mode();
 
 		data.devid = intel_get_drm_devid(data.drm_fd);
+		data.running_with_psr_disabled = igt_dry_run;
 
 		igt_skip_on(!psr_enabled(&data));
 
Signature · 1 line
1.9.3