Index: uspace/lib/pcut/src/main.c
===================================================================
--- uspace/lib/pcut/src/main.c	(revision 9b201262edcb92c27cf4a25a8379320113426ab7)
+++ uspace/lib/pcut/src/main.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -90,8 +90,11 @@
  * @param last Pointer to first item after this suite is stored here.
  * @param prog_path Path to the current binary (used in forked mode).
- */
-static void run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) {
+ * @return Error code.
+ */
+static int run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) {
 	int is_first_test = 1;
 	int total_count = 0;
+	int ret_code = PCUT_OUTCOME_PASS;
+	int ret_code_tmp;
 
 	pcut_item_t *it = pcut_get_real_next(suite);
@@ -114,8 +117,19 @@
 
 		if (pcut_run_mode == PCUT_RUN_MODE_FORKING) {
-			pcut_run_test_forking(prog_path, it);
+			ret_code_tmp = pcut_run_test_forking(prog_path, it);
 		} else {
-			pcut_run_test_single(it);
-		}
+			ret_code_tmp = pcut_run_test_single(it);
+		}
+
+		/*
+		 * Override final return code in case of failure.
+		 *
+		 * In this case we suppress any special error codes as
+		 * to the outside, there was a failure.
+		 */
+		if (ret_code_tmp != PCUT_OUTCOME_PASS) {
+			ret_code = PCUT_OUTCOME_FAIL;
+		}
+
 		total_count++;
 	}
@@ -130,4 +144,6 @@
 		*last = it;
 	}
+
+	return ret_code;
 }
 
@@ -181,4 +197,6 @@
 	int run_only_test = -1;
 
+	int rc, rc_tmp;
+
 	if (main_extras == NULL) {
 		main_extras = empty_main_extra;
@@ -203,5 +221,5 @@
 			if (pcut_str_equals(argv[i], "-l")) {
 				pcut_print_tests(items);
-				return 0;
+				return PCUT_OUTCOME_PASS;
 			}
 			if (pcut_str_equals(argv[i], "-x")) {
@@ -229,5 +247,5 @@
 	if ((run_only_suite >= 0) && (run_only_test >= 0)) {
 		printf("Specify either -s or -t!\n");
-		return 1;
+		return PCUT_OUTCOME_BAD_INVOCATION;
 	}
 
@@ -236,25 +254,24 @@
 		if (suite == NULL) {
 			printf("Suite not found, aborting!\n");
-			return 2;
+			return PCUT_OUTCOME_BAD_INVOCATION;
 		}
 		if (suite->kind != PCUT_KIND_TESTSUITE) {
 			printf("Invalid suite id!\n");
-			return 3;
+			return PCUT_OUTCOME_BAD_INVOCATION;
 		}
 
 		run_suite(suite, NULL, argv[0]);
-		return 0;
+		return PCUT_OUTCOME_PASS;
 	}
 
 	if (run_only_test > 0) {
-		int rc;
 		pcut_item_t *test = pcut_find_by_id(items, run_only_test);
 		if (test == NULL) {
 			printf("Test not found, aborting!\n");
-			return 2;
+			return PCUT_OUTCOME_BAD_INVOCATION;
 		}
 		if (test->kind != PCUT_KIND_TEST) {
 			printf("Invalid test id!\n");
-			return 3;
+			return PCUT_OUTCOME_BAD_INVOCATION;
 		}
 
@@ -271,9 +288,14 @@
 	pcut_report_init(items);
 
+	rc = PCUT_OUTCOME_PASS;
+
 	it = items;
 	while (it != NULL) {
 		if (it->kind == PCUT_KIND_TESTSUITE) {
 			pcut_item_t *tmp;
-			run_suite(it, &tmp, argv[0]);
+			rc_tmp = run_suite(it, &tmp, argv[0]);
+			if (rc_tmp != PCUT_OUTCOME_PASS) {
+				rc = rc_tmp;
+			}
 			it = tmp;
 		} else {
@@ -284,4 +306,4 @@
 	pcut_report_done();
 
-	return 0;
-}
+	return rc;
+}
