diff mbox series

[v1,2/6] rt:pi-tests::sbrk_mutex: return actual exit code

Message ID 20210914170851.22931-2-bogdan.lezhepekov@suse.com
State Changes Requested
Headers show
Series [v1,1/6] realtime:async_handler_jk: return actual exit code | expand

Commit Message

Bogdan Lezhepekov Sept. 14, 2021, 5:08 p.m. UTC
The original version always returned 0.

Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
 testcases/realtime/func/pi-tests/sbrk_mutex.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Cyril Hrubis Sept. 24, 2021, 3:33 p.m. UTC | #1
Hi!
I'm looking on how the pi-tests are supposed to be executed and it seems
that the return value does not seems to matter at all.

Each of these tests is executed by run_c_files.sh script that writes the
output into a logfile then a python script is used to parse the logfile.

I think that if we want to fix the realtime tests we should simplify
this mess first.
diff mbox series

Patch

diff --git a/testcases/realtime/func/pi-tests/sbrk_mutex.c b/testcases/realtime/func/pi-tests/sbrk_mutex.c
index 7ed7969d9..34e4e9666 100644
--- a/testcases/realtime/func/pi-tests/sbrk_mutex.c
+++ b/testcases/realtime/func/pi-tests/sbrk_mutex.c
@@ -97,7 +97,8 @@  void *worker_thread(void *arg)
 
 int main(int argc, char *argv[])
 {
-	int m, ret, robust;
+	int m, robust;
+	int ret = 0;
 	intptr_t t;
 	pthread_mutexattr_t mutexattr;
 	setup();
@@ -123,7 +124,8 @@  int main(int argc, char *argv[])
 		if (!(mutexes[m] = malloc(sizeof(pthread_mutex_t)))) {
 			perror("malloc failed\n");
 		}
-		if ((ret = pthread_mutex_init(mutexes[m], &mutexattr))) {
+		if (pthread_mutex_init(mutexes[m], &mutexattr)) {
+			ret = 1;
 			perror("pthread_mutex_init() failed\n");
 		}
 	}
@@ -140,11 +142,13 @@  int main(int argc, char *argv[])
 	/* destroy all the mutexes */
 	for (m = 0; m < NUM_MUTEXES; m++) {
 		if (mutexes[m]) {
-			if ((ret = pthread_mutex_destroy(mutexes[m])))
+			if (pthread_mutex_destroy(mutexes[m])) {
+				ret = 1;
 				perror("pthread_mutex_destroy() failed\n");
+			}
 			free(mutexes[m]);
 		}
 	}
 
-	return 0;
+	return ret;
 }