[PATCH libinput v3] test: check getcwd() and system() return values in litest

Jon A. Cruz jonc at osg.samsung.com
Mon Jun 1 18:04:59 PDT 2015


Added code to check for errors in getcwd() and system() that
were previously ignored and silently dropped.

Signed-off-by: Jon A. Cruz <jonc at osg.samsung.com>
---
 test/litest.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/test/litest.c b/test/litest.c
index 30d3056..d457a27 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -84,8 +84,10 @@ litest_backtrace_get_lineno(const char *executable,
 	char *s;
 	unsigned int i;
 
-	if (!cwd[0])
-		getcwd(cwd, sizeof(cwd));
+	if (!cwd[0]) {
+		if (getcwd(cwd, sizeof(cwd)) == NULL)
+			cwd[0] = 0; /* contents otherwise undefined. */
+	}
 
 	sprintf (buffer,
 		 ADDR2LINE " -C -e %s -i %lx",
@@ -375,7 +377,17 @@ static struct list all_tests;
 static void
 litest_reload_udev_rules(void)
 {
-	system("udevadm control --reload-rules");
+	int ret = system("udevadm control --reload-rules");
+	if (ret == -1) {
+		litest_abort_msg("Failed to execute: udevadm");
+	} else if (WIFEXITED(ret)) {
+		if (WEXITSTATUS(ret))
+			litest_abort_msg("udevadm failed with %d",
+					 WEXITSTATUS(ret));
+	} else if (WIFSIGNALED(ret)) {
+		litest_abort_msg("udevadm terminated with signal %d",
+				 WTERMSIG(ret));
+	}
 }
 
 static int
-- 
2.1.0



More information about the wayland-devel mailing list