* [LTP] [PATCH v1 2/6] rt:pi-tests::sbrk_mutex: return actual exit code
@ 2021-09-14 17:08 ` Bogdan Lezhepekov via ltp
2021-09-24 15:33 ` Cyril Hrubis
0 siblings, 1 reply; 9+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2021-09-14 17:08 UTC (permalink / raw)
To: ltp
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(-)
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;
}
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH v1 2/6] rt:pi-tests::sbrk_mutex: return actual exit code
@ 2021-09-14 17:08 ` Bogdan Lezhepekov via ltp
2021-09-24 15:33 ` Cyril Hrubis
0 siblings, 1 reply; 9+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2021-09-14 17:08 UTC (permalink / raw)
To: ltp
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(-)
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;
}
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH v1 3/6] rt:pi-tests:testpi-0: return actual exit code
@ 2021-09-14 17:08 ` Bogdan Lezhepekov via ltp
0 siblings, 0 replies; 9+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2021-09-14 17:08 UTC (permalink / raw)
To: ltp
The original version always returned 0.
Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
testcases/realtime/func/pi-tests/testpi-0.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/testcases/realtime/func/pi-tests/testpi-0.c b/testcases/realtime/func/pi-tests/testpi-0.c
index fd8ad0717..64797c899 100644
--- a/testcases/realtime/func/pi-tests/testpi-0.c
+++ b/testcases/realtime/func/pi-tests/testpi-0.c
@@ -94,8 +94,10 @@ int main(int argc, char *argv[])
printf("LIBPTHREAD_VERSION: %s\n", pathbuf);
free(pathbuf);
- if (sysconf(_SC_THREAD_PRIO_INHERIT) == -1)
+ if (sysconf(_SC_THREAD_PRIO_INHERIT) == -1) {
printf("No Prio inheritance support\n");
+ exit(1);
+ }
printf("Prio inheritance support present\n");
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH v1 3/6] rt:pi-tests:testpi-0: return actual exit code
@ 2021-09-14 17:08 ` Bogdan Lezhepekov via ltp
0 siblings, 0 replies; 9+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2021-09-14 17:08 UTC (permalink / raw)
To: ltp
The original version always returned 0.
Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
testcases/realtime/func/pi-tests/testpi-0.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/testcases/realtime/func/pi-tests/testpi-0.c b/testcases/realtime/func/pi-tests/testpi-0.c
index fd8ad0717..64797c899 100644
--- a/testcases/realtime/func/pi-tests/testpi-0.c
+++ b/testcases/realtime/func/pi-tests/testpi-0.c
@@ -94,8 +94,10 @@ int main(int argc, char *argv[])
printf("LIBPTHREAD_VERSION: %s\n", pathbuf);
free(pathbuf);
- if (sysconf(_SC_THREAD_PRIO_INHERIT) == -1)
+ if (sysconf(_SC_THREAD_PRIO_INHERIT) == -1) {
printf("No Prio inheritance support\n");
+ exit(1);
+ }
printf("Prio inheritance support present\n");
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH v1 4/6] rt:pi-tests:test-skeleton: fix wrong return value
@ 2021-09-14 17:08 ` Bogdan Lezhepekov via ltp
0 siblings, 0 replies; 9+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2021-09-14 17:08 UTC (permalink / raw)
To: ltp
Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
testcases/realtime/func/pi-tests/test-skeleton.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testcases/realtime/func/pi-tests/test-skeleton.c b/testcases/realtime/func/pi-tests/test-skeleton.c
index 7816cf877..4a923cd2d 100644
--- a/testcases/realtime/func/pi-tests/test-skeleton.c
+++ b/testcases/realtime/func/pi-tests/test-skeleton.c
@@ -88,7 +88,7 @@ static void timeout_handler(int sig)
exit(1);
}
printf("\nResult:PASS\n");
- exit(1);
+ exit(0);
}
int main(int argc, char **argv)
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH v1 5/6] rt:pi-tests:testpi-5: return exit code
@ 2021-09-14 17:08 ` Bogdan Lezhepekov via ltp
2021-09-24 9:53 ` Petr Vorel
0 siblings, 1 reply; 9+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2021-09-14 17:08 UTC (permalink / raw)
To: ltp
Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
testcases/realtime/func/pi-tests/testpi-5.c | 24 ++++++++++++++-------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/testcases/realtime/func/pi-tests/testpi-5.c b/testcases/realtime/func/pi-tests/testpi-5.c
index a52486417..538be1e44 100644
--- a/testcases/realtime/func/pi-tests/testpi-5.c
+++ b/testcases/realtime/func/pi-tests/testpi-5.c
@@ -68,29 +68,37 @@ int do_test(int argc, char **argv)
{
pthread_mutexattr_t mutexattr;
int retc, protocol;
+ unsigned int err = 0;
#if HAS_PRIORITY_INHERIT
- if (pthread_mutexattr_init(&mutexattr) != 0)
+ if (pthread_mutexattr_init(&mutexattr) != 0) {
printf("Failed to init mutexattr\n");
+ err++;
+ }
if (pthread_mutexattr_setprotocol(&mutexattr,
- PTHREAD_PRIO_INHERIT) != 0)
+ PTHREAD_PRIO_INHERIT) != 0) {
printf("Can't set protocol prio inherit\n");
-
- if (pthread_mutexattr_getprotocol(&mutexattr, &protocol) != 0)
+ err++;
+ }
+
+ if (pthread_mutexattr_getprotocol(&mutexattr, &protocol) != 0) {
printf("Can't get mutexattr protocol\n");
- else
+ err++;
+ } else
printf("protocol in mutexattr is %d\n", protocol);
-
+
retc = pthread_mutex_init(&child_mutex, &mutexattr);
- if (retc != 0)
+ if (retc != 0) {
printf("Failed to init mutex: %d\n", retc);
+ err++;
+ }
create_other_thread(child_thread, NULL);
join_threads();
- return 0;
+ return err > 0 ? 1: 0;
#else
return 1;
#endif
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH v1 5/6] rt:pi-tests:testpi-5: return exit code
@ 2021-09-14 17:08 ` Bogdan Lezhepekov via ltp
2021-09-24 9:53 ` Petr Vorel
0 siblings, 1 reply; 9+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2021-09-14 17:08 UTC (permalink / raw)
To: ltp
Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
testcases/realtime/func/pi-tests/testpi-5.c | 24 ++++++++++++++-------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/testcases/realtime/func/pi-tests/testpi-5.c b/testcases/realtime/func/pi-tests/testpi-5.c
index a52486417..538be1e44 100644
--- a/testcases/realtime/func/pi-tests/testpi-5.c
+++ b/testcases/realtime/func/pi-tests/testpi-5.c
@@ -68,29 +68,37 @@ int do_test(int argc, char **argv)
{
pthread_mutexattr_t mutexattr;
int retc, protocol;
+ unsigned int err = 0;
#if HAS_PRIORITY_INHERIT
- if (pthread_mutexattr_init(&mutexattr) != 0)
+ if (pthread_mutexattr_init(&mutexattr) != 0) {
printf("Failed to init mutexattr\n");
+ err++;
+ }
if (pthread_mutexattr_setprotocol(&mutexattr,
- PTHREAD_PRIO_INHERIT) != 0)
+ PTHREAD_PRIO_INHERIT) != 0) {
printf("Can't set protocol prio inherit\n");
-
- if (pthread_mutexattr_getprotocol(&mutexattr, &protocol) != 0)
+ err++;
+ }
+
+ if (pthread_mutexattr_getprotocol(&mutexattr, &protocol) != 0) {
printf("Can't get mutexattr protocol\n");
- else
+ err++;
+ } else
printf("protocol in mutexattr is %d\n", protocol);
-
+
retc = pthread_mutex_init(&child_mutex, &mutexattr);
- if (retc != 0)
+ if (retc != 0) {
printf("Failed to init mutex: %d\n", retc);
+ err++;
+ }
create_other_thread(child_thread, NULL);
join_threads();
- return 0;
+ return err > 0 ? 1: 0;
#else
return 1;
#endif
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v1 5/6] rt:pi-tests:testpi-5: return exit code
2021-09-14 17:08 ` Bogdan Lezhepekov via ltp
@ 2021-09-24 9:53 ` Petr Vorel
2021-09-24 10:07 ` Bogdan Lezhepekov via ltp
0 siblings, 1 reply; 9+ messages in thread
From: Petr Vorel @ 2021-09-24 9:53 UTC (permalink / raw)
To: Bogdan Lezhepekov; +Cc: ltp
Hi Bogdan,
> +++ b/testcases/realtime/func/pi-tests/testpi-5.c
...
> create_other_thread(child_thread, NULL);
> join_threads();
> - return 0;
> + return err > 0 ? 1: 0;
nit: "1: 0" => "1 : 0" (for better readability).
Whole patchset LGTM, thanks for improving realtime tests.
To whole patchset:
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v1 5/6] rt:pi-tests:testpi-5: return exit code
2021-09-24 9:53 ` Petr Vorel
@ 2021-09-24 10:07 ` Bogdan Lezhepekov via ltp
0 siblings, 0 replies; 9+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2021-09-24 10:07 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
[-- Attachment #1.1: Type: text/plain, Size: 764 bytes --]
Hi Petr,
Thanks for reviewing!
-Bogdan
________________________________
From: Petr Vorel <pvorel@suse.cz>
Sent: Friday, September 24, 2021 12:53
To: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
Cc: ltp@lists.linux.it <ltp@lists.linux.it>; Cyril Hrubis <chrubis@suse.cz>
Subject: Re: [LTP] [PATCH v1 5/6] rt:pi-tests:testpi-5: return exit code
Hi Bogdan,
> +++ b/testcases/realtime/func/pi-tests/testpi-5.c
...
> create_other_thread(child_thread, NULL);
> join_threads();
> - return 0;
> + return err > 0 ? 1: 0;
nit: "1: 0" => "1 : 0" (for better readability).
Whole patchset LGTM, thanks for improving realtime tests.
To whole patchset:
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
[-- Attachment #1.2: Type: text/html, Size: 2192 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH v1 6/6] rt:pi-tests:testpi-6: return exit code
@ 2021-09-14 17:08 ` Bogdan Lezhepekov via ltp
0 siblings, 0 replies; 9+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2021-09-14 17:08 UTC (permalink / raw)
To: ltp
Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
testcases/realtime/func/pi-tests/testpi-6.c | 22 ++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/testcases/realtime/func/pi-tests/testpi-6.c b/testcases/realtime/func/pi-tests/testpi-6.c
index 637d38355..bc271f242 100644
--- a/testcases/realtime/func/pi-tests/testpi-6.c
+++ b/testcases/realtime/func/pi-tests/testpi-6.c
@@ -69,27 +69,35 @@ int do_test(int argc, char **argv)
{
pthread_mutexattr_t mutexattr;
int retc, robust;
+ unsigned int err;
- if (pthread_mutexattr_init(&mutexattr) != 0)
+ if (pthread_mutexattr_init(&mutexattr) != 0) {
printf("Failed to init mutexattr\n");
+ err++;
+ }
if (pthread_mutexattr_setrobust(&mutexattr,
- PTHREAD_MUTEX_ROBUST) != 0)
+ PTHREAD_MUTEX_ROBUST) != 0) {
printf("Can't set robust mutex\n");
-
- if (pthread_mutexattr_getrobust(&mutexattr, &robust) != 0)
+ err++;
+ }
+
+ if (pthread_mutexattr_getrobust(&mutexattr, &robust) != 0) {
printf("Can't get mutexattr protocol\n");
- else
+ err++;
+ } else
printf("robust in mutexattr is %d\n", robust);
retc = pthread_mutex_init(&child_mutex, &mutexattr);
- if (retc != 0)
+ if (retc != 0) {
printf("Failed to init mutex: %d\n", retc);
+ err++;
+ }
create_other_thread(child_thread, NULL);
join_threads();
- return 0;
+ return err > 0 ? 1 : 0;
}
#include "test-skeleton.c"
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH v1 6/6] rt:pi-tests:testpi-6: return exit code
@ 2021-09-14 17:08 ` Bogdan Lezhepekov via ltp
0 siblings, 0 replies; 9+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2021-09-14 17:08 UTC (permalink / raw)
To: ltp
Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
testcases/realtime/func/pi-tests/testpi-6.c | 22 ++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/testcases/realtime/func/pi-tests/testpi-6.c b/testcases/realtime/func/pi-tests/testpi-6.c
index 637d38355..bc271f242 100644
--- a/testcases/realtime/func/pi-tests/testpi-6.c
+++ b/testcases/realtime/func/pi-tests/testpi-6.c
@@ -69,27 +69,35 @@ int do_test(int argc, char **argv)
{
pthread_mutexattr_t mutexattr;
int retc, robust;
+ unsigned int err;
- if (pthread_mutexattr_init(&mutexattr) != 0)
+ if (pthread_mutexattr_init(&mutexattr) != 0) {
printf("Failed to init mutexattr\n");
+ err++;
+ }
if (pthread_mutexattr_setrobust(&mutexattr,
- PTHREAD_MUTEX_ROBUST) != 0)
+ PTHREAD_MUTEX_ROBUST) != 0) {
printf("Can't set robust mutex\n");
-
- if (pthread_mutexattr_getrobust(&mutexattr, &robust) != 0)
+ err++;
+ }
+
+ if (pthread_mutexattr_getrobust(&mutexattr, &robust) != 0) {
printf("Can't get mutexattr protocol\n");
- else
+ err++;
+ } else
printf("robust in mutexattr is %d\n", robust);
retc = pthread_mutex_init(&child_mutex, &mutexattr);
- if (retc != 0)
+ if (retc != 0) {
printf("Failed to init mutex: %d\n", retc);
+ err++;
+ }
create_other_thread(child_thread, NULL);
join_threads();
- return 0;
+ return err > 0 ? 1 : 0;
}
#include "test-skeleton.c"
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread