Browse Source

Add a test for renicing multithreaded processes

Marc Di Luzio 5 years ago
parent
commit
3ac49385dc
1 changed files with 22 additions and 2 deletions
  1. 22 2
      daemon/gamemode-tests.c

+ 22 - 2
daemon/gamemode-tests.c

@@ -677,6 +677,19 @@ static pid_t run_process_tree(int innactive, int active, testfunc func)
 	return status;
 }
 
+int test_renice(int expected, pid_t this)
+{
+	int val = game_mode_get_renice(this);
+	if (val != expected) {
+		LOG_ERROR("nice value was incorrect for thread %d!\nExpected: %d, Was: %d\n",
+		          this,
+		          expected,
+		          val);
+		return -1;
+	}
+	return 0;
+}
+
 int run_renice_tests(struct GameModeConfig *config)
 {
 	/* read configuration "renice" (1..20) */
@@ -717,6 +730,13 @@ int run_renice_tests(struct GameModeConfig *config)
 		ret = -1;
 	}
 
+	/* Check multiprocess nice works as well */
+	val = run_process_tree(0, (int)renice, test_renice);
+	if (val != 0) {
+		LOG_ERROR("Multithreaded renice tests failed!\n");
+		ret = -1;
+	}
+
 	return ret;
 }
 
@@ -858,9 +878,9 @@ static int game_mode_run_feature_tests(struct GameModeConfig *config)
 		else if (renicestatus == 0)
 			LOG_MSG("::: Passed\n");
 		else {
-			LOG_MSG("::: Failed!\n");
+			LOG_MSG("::: Failed! (non-fatal, known issue with multithreaded programs)\n");
 			// Renice should be expected to work, if set
-			status = -1;
+			status = 1;
 		}
 	}