[Piglit] [PATCH 11/13] util: Use piglit-log in piglit-util.c

Chad Versace chad.versace at linux.intel.com
Wed Mar 26 10:40:27 PDT 2014


This patch replaces each occurence of printf in piglit-util.c, when
appropriate, with piglit_loge() or piglit_logi().

Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 tests/util/piglit-util.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index ca7d4cd..5f8bdae 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -288,26 +288,24 @@ piglit_set_rlimit(unsigned long lim)
 #if defined(USE_SETRLIMIT) && defined(RLIMIT_AS)
 	struct rlimit rl;
 	if (getrlimit(RLIMIT_AS, &rl) != -1) {
-		printf("Address space limit = %lu, max = %lu\n",
+		piglit_logi("Address space limit = %lu, max = %lu",
 		       (unsigned long) rl.rlim_cur,
 		       (unsigned long) rl.rlim_max);
 
 		if (rl.rlim_max > lim) {
-			printf("Resetting limit to %lu.\n", lim);
+			piglit_logi("Resetting limit to %lu", lim);
 
 			rl.rlim_cur = lim;
 			rl.rlim_max = lim;
 			if (setrlimit(RLIMIT_AS, &rl) == -1) {
-				printf("Could not set rlimit "
-				       "due to: %s (%d)\n",
+				piglit_loge("Could not set rlimit "
+				       "due to: %s (%d)",
 				       strerror(errno), errno);
 			}
 		}
 	}
-
-	printf("\n");
 #else
-	printf("Cannot reset rlimit on this platform.\n\n");
+	piglit_loge("Cannot reset rlimit on this platform");
 #endif
 }
 
@@ -454,7 +452,7 @@ piglit_source_dir(void)
     const char *s = getenv("PIGLIT_SOURCE_DIR");
 
     if (s == NULL) {
-        printf("error: env var PIGLIT_SOURCE_DIR is undefined\n");
+        piglit_loge("env var PIGLIT_SOURCE_DIR is undefined");
         piglit_report_result(PIGLIT_FAIL);
     }
 
@@ -565,14 +563,13 @@ piglit_parse_subtest_args(int *argc, char *argv[],
 
 			++j;
 			if (j >= *argc) {
-				fprintf(stderr,
-					"-subtest requires an argument\n");
+				piglit_loge("-subtest requires an argument");
 				piglit_report_result(PIGLIT_FAIL);
 			}
 
 			if (!piglit_find_subtest(subtests, argv[j])) {
-				fprintf(stderr, "Test defines no subtest with "
-					"name '%s'\n", argv[j]);
+				piglit_loge("Test defines no subtest with "
+					"name '%s'", argv[j]);
 				piglit_report_result(PIGLIT_FAIL);
 			}
 
@@ -593,7 +590,7 @@ piglit_parse_subtest_args(int *argc, char *argv[],
 			int i;
 
 			if (subtests == NULL) {
-				fprintf(stderr, "Test defines no subtests!\n");
+				piglit_loge("Test defines no subtests!");
 				exit(EXIT_FAILURE);
 			}
 
@@ -643,9 +640,7 @@ piglit_run_selected_subtests(const struct piglit_subtest *all_subtests,
 				piglit_find_subtest(all_subtests, name);
 
 			if (subtest == NULL) {
-				fprintf(stderr,
-					"Unknown subtest \"%s\".\n",
-					name);
+				piglit_loge("Unknown subtest \"%s\"", name);
 				piglit_report_result(PIGLIT_FAIL);
 			}
 
-- 
1.8.5.3



More information about the Piglit mailing list