Skip to contentSkip to conversation

lib: warning messages should be sent to stderr

PATCH New Thomas Wood 1 participant 3 messages Jan 27, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 lib: warning messages should be sent to stderr

This is a regression from commit df11a0f (lib: add a critical warning level).

---
 lib/igt_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_core.c +1 -1
index 7b47b32..2692fe4 100644
@@ -1522,7 +1522,7 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format,
 			return;
 	}
 
-	if (level > IGT_LOG_WARN) {
+	if (level >= IGT_LOG_WARN) {
 		file = stderr;
 		fflush(stdout);
 	}
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/3 lib: print warning and critical messages when listing subtests

These messages are sent to stderr and could indicate an issue when enumerating subtests.

---
 lib/igt_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_core.c +1 -1
index 2692fe4..bc588e2 100644
@@ -1507,7 +1507,7 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format,
 	program_name = command_str;
 #endif
 
-	if (list_subtests)
+	if (list_subtests && level <= IGT_LOG_WARN)
 		return;
 
 	if (igt_log_level > level)
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/3 lib: validate subtest names

In reply to Thomas Wood

Subtest names should only contain '-', '_' and alphanumeric characters.

---
 lib/igt_core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
lib/igt_core.c +12 -0
index bc588e2..d74f6f8 100644
@@ -54,6 +54,7 @@
 #include <termios.h>
 #include <errno.h>
 #include <time.h>
+#include <ctype.h>
 
 #include "drmtest.h"
 #include "intel_chipset.h"
@@ -693,10 +694,21 @@ void igt_simple_init_parse_opts(int argc, char **argv,
  */
 bool __igt_run_subtest(const char *subtest_name)
 {
+	int i;
+
 	assert(!in_subtest);
 	assert(!in_fixture);
 	assert(test_with_subtests);
 
+	/* check the subtest name only contains a-z, A-Z, 0-9, '-' and '_' */
+	for (i = 0; subtest_name[i] != '\0'; i++)
+		if (subtest_name[i] != '_' && subtest_name[i] != '-'
+		    && !isalnum(subtest_name[i])) {
+			igt_critical("Invalid subtest name \"%s\".\n",
+				     subtest_name);
+			igt_exit();
+		}
+
 	if (list_subtests) {
 		printf("%s\n", subtest_name);
 		return false;
Signature · 6 lines
2.1.0

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