[Xenomai-git] Gilles Chanteperdrix : testsuite: various improvements in leaks test

2013-12-22 Thread git repository hosting
Module: xenomai-forge
Branch: master
Commit: 7a3c3d156a3fcaab52792dcb0c30d848cf1aadca
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=7a3c3d156a3fcaab52792dcb0c30d848cf1aadca

Author: Gilles Chanteperdrix 
Date:   Sun Dec 15 19:54:36 2013 +0100

testsuite: various improvements in leaks test

Fix timer_create parameters to cope with timer_create API changes
(SIGEV_SIGNAL is no longer supported).  Add a fork test to verify
automatic objects destruction upon process termination.

---

 testsuite/regression/posix/leaks.c |   42 +++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/testsuite/regression/posix/leaks.c 
b/testsuite/regression/posix/leaks.c
index f368cae..4e8a769 100644
--- a/testsuite/regression/posix/leaks.c
+++ b/testsuite/regression/posix/leaks.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -50,6 +53,28 @@ static void *empty(void *cookie)
return cookie;
 }
 
+static void subprocess_leak(void)
+{
+   struct sigevent sevt;
+   pthread_mutex_t mutex;
+   pthread_cond_t cond;
+   pthread_t thread;
+   sem_t sem, *psem;
+   timer_t tm;
+   int fd;
+
+   check_pthread(pthread_create(&thread, NULL, empty, NULL));
+   check_pthread(pthread_mutex_init(&mutex, NULL));
+   check_pthread(pthread_cond_init(&cond, NULL));
+   check_unix(sem_init(&sem, 0, 0));
+   check_unix(-!(psem = sem_open(SEM_NAME, O_CREAT, 0644, 1)));
+   sevt.sigev_notify = SIGEV_THREAD_ID;
+   sevt.sigev_signo = SIGALRM;
+   sevt.sigev_notify_thread_id = syscall(__NR_gettid);
+   check_unix(timer_create(CLOCK_MONOTONIC, &sevt, &tm));
+   check_unix(fd = mq_open(MQ_NAME, O_RDWR | O_CREAT, 0644, NULL));
+}
+
 int main(void)
 {
unsigned long long before;
@@ -60,6 +85,7 @@ int main(void)
pthread_t thread;
sem_t sem, *psem;
timer_t tm;
+   pid_t child;
 
mlockall(MCL_CURRENT|MCL_FUTURE);
 
@@ -93,8 +119,9 @@ int main(void)
check_used("named sem", before, failed);
 
before = get_used();
-   sevt.sigev_notify = SIGEV_SIGNAL;
+   sevt.sigev_notify = SIGEV_THREAD_ID;
sevt.sigev_signo = SIGALRM;
+   sevt.sigev_notify_thread_id = syscall(__NR_gettid);
check_unix(timer_create(CLOCK_MONOTONIC, &sevt, &tm));
check_unix(timer_delete(tm));
check_used("timer", before, failed);
@@ -105,5 +132,18 @@ int main(void)
check_unix(mq_unlink(MQ_NAME));
check_used("mq", before, failed);
 
+   before = get_used();
+   check_unix(child = fork());
+   if (!child) {
+   subprocess_leak();
+   return EXIT_SUCCESS;
+   }
+   while (waitpid(child, NULL, 0) == -1 && errno == EINTR);
+   sleep(1);   /* Leave some time for xnheap
+* deferred free */
+   check_unix(sem_unlink(SEM_NAME));
+   check_unix(mq_unlink(MQ_NAME));
+   check_used("fork", before, failed);
+
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Gilles Chanteperdrix : testsuite: various improvements in leaks test

2013-12-20 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 7a3c3d156a3fcaab52792dcb0c30d848cf1aadca
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=7a3c3d156a3fcaab52792dcb0c30d848cf1aadca

Author: Gilles Chanteperdrix 
Date:   Sun Dec 15 19:54:36 2013 +0100

testsuite: various improvements in leaks test

Fix timer_create parameters to cope with timer_create API changes
(SIGEV_SIGNAL is no longer supported).  Add a fork test to verify
automatic objects destruction upon process termination.

---

 testsuite/regression/posix/leaks.c |   42 +++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/testsuite/regression/posix/leaks.c 
b/testsuite/regression/posix/leaks.c
index f368cae..4e8a769 100644
--- a/testsuite/regression/posix/leaks.c
+++ b/testsuite/regression/posix/leaks.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -50,6 +53,28 @@ static void *empty(void *cookie)
return cookie;
 }
 
+static void subprocess_leak(void)
+{
+   struct sigevent sevt;
+   pthread_mutex_t mutex;
+   pthread_cond_t cond;
+   pthread_t thread;
+   sem_t sem, *psem;
+   timer_t tm;
+   int fd;
+
+   check_pthread(pthread_create(&thread, NULL, empty, NULL));
+   check_pthread(pthread_mutex_init(&mutex, NULL));
+   check_pthread(pthread_cond_init(&cond, NULL));
+   check_unix(sem_init(&sem, 0, 0));
+   check_unix(-!(psem = sem_open(SEM_NAME, O_CREAT, 0644, 1)));
+   sevt.sigev_notify = SIGEV_THREAD_ID;
+   sevt.sigev_signo = SIGALRM;
+   sevt.sigev_notify_thread_id = syscall(__NR_gettid);
+   check_unix(timer_create(CLOCK_MONOTONIC, &sevt, &tm));
+   check_unix(fd = mq_open(MQ_NAME, O_RDWR | O_CREAT, 0644, NULL));
+}
+
 int main(void)
 {
unsigned long long before;
@@ -60,6 +85,7 @@ int main(void)
pthread_t thread;
sem_t sem, *psem;
timer_t tm;
+   pid_t child;
 
mlockall(MCL_CURRENT|MCL_FUTURE);
 
@@ -93,8 +119,9 @@ int main(void)
check_used("named sem", before, failed);
 
before = get_used();
-   sevt.sigev_notify = SIGEV_SIGNAL;
+   sevt.sigev_notify = SIGEV_THREAD_ID;
sevt.sigev_signo = SIGALRM;
+   sevt.sigev_notify_thread_id = syscall(__NR_gettid);
check_unix(timer_create(CLOCK_MONOTONIC, &sevt, &tm));
check_unix(timer_delete(tm));
check_used("timer", before, failed);
@@ -105,5 +132,18 @@ int main(void)
check_unix(mq_unlink(MQ_NAME));
check_used("mq", before, failed);
 
+   before = get_used();
+   check_unix(child = fork());
+   if (!child) {
+   subprocess_leak();
+   return EXIT_SUCCESS;
+   }
+   while (waitpid(child, NULL, 0) == -1 && errno == EINTR);
+   sleep(1);   /* Leave some time for xnheap
+* deferred free */
+   check_unix(sem_unlink(SEM_NAME));
+   check_unix(mq_unlink(MQ_NAME));
+   check_used("fork", before, failed);
+
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Gilles Chanteperdrix : testsuite: various improvements in leaks test

2013-12-19 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 014f7d3bf70c998eb166dcb8637b7f774a1d6d47
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=014f7d3bf70c998eb166dcb8637b7f774a1d6d47

Author: Gilles Chanteperdrix 
Date:   Sun Dec 15 19:54:36 2013 +0100

testsuite: various improvements in leaks test

Fix timer_create parameters to cope with timer_create API changes
(SIGEV_SIGNAL is no longer supported).  Add a fork test to verify
automatic objects destruction upon process termination.

---

 testsuite/regression/posix/leaks.c |   42 +++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/testsuite/regression/posix/leaks.c 
b/testsuite/regression/posix/leaks.c
index f368cae..4e8a769 100644
--- a/testsuite/regression/posix/leaks.c
+++ b/testsuite/regression/posix/leaks.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -50,6 +53,28 @@ static void *empty(void *cookie)
return cookie;
 }
 
+static void subprocess_leak(void)
+{
+   struct sigevent sevt;
+   pthread_mutex_t mutex;
+   pthread_cond_t cond;
+   pthread_t thread;
+   sem_t sem, *psem;
+   timer_t tm;
+   int fd;
+
+   check_pthread(pthread_create(&thread, NULL, empty, NULL));
+   check_pthread(pthread_mutex_init(&mutex, NULL));
+   check_pthread(pthread_cond_init(&cond, NULL));
+   check_unix(sem_init(&sem, 0, 0));
+   check_unix(-!(psem = sem_open(SEM_NAME, O_CREAT, 0644, 1)));
+   sevt.sigev_notify = SIGEV_THREAD_ID;
+   sevt.sigev_signo = SIGALRM;
+   sevt.sigev_notify_thread_id = syscall(__NR_gettid);
+   check_unix(timer_create(CLOCK_MONOTONIC, &sevt, &tm));
+   check_unix(fd = mq_open(MQ_NAME, O_RDWR | O_CREAT, 0644, NULL));
+}
+
 int main(void)
 {
unsigned long long before;
@@ -60,6 +85,7 @@ int main(void)
pthread_t thread;
sem_t sem, *psem;
timer_t tm;
+   pid_t child;
 
mlockall(MCL_CURRENT|MCL_FUTURE);
 
@@ -93,8 +119,9 @@ int main(void)
check_used("named sem", before, failed);
 
before = get_used();
-   sevt.sigev_notify = SIGEV_SIGNAL;
+   sevt.sigev_notify = SIGEV_THREAD_ID;
sevt.sigev_signo = SIGALRM;
+   sevt.sigev_notify_thread_id = syscall(__NR_gettid);
check_unix(timer_create(CLOCK_MONOTONIC, &sevt, &tm));
check_unix(timer_delete(tm));
check_used("timer", before, failed);
@@ -105,5 +132,18 @@ int main(void)
check_unix(mq_unlink(MQ_NAME));
check_used("mq", before, failed);
 
+   before = get_used();
+   check_unix(child = fork());
+   if (!child) {
+   subprocess_leak();
+   return EXIT_SUCCESS;
+   }
+   while (waitpid(child, NULL, 0) == -1 && errno == EINTR);
+   sleep(1);   /* Leave some time for xnheap
+* deferred free */
+   check_unix(sem_unlink(SEM_NAME));
+   check_unix(mq_unlink(MQ_NAME));
+   check_used("fork", before, failed);
+
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Gilles Chanteperdrix : testsuite: various improvements in leaks test

2013-12-19 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: c2b15ac0f5f150a3e956cb6ecb8adda1b6ea4792
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=c2b15ac0f5f150a3e956cb6ecb8adda1b6ea4792

Author: Gilles Chanteperdrix 
Date:   Sun Dec 15 19:54:36 2013 +0100

testsuite: various improvements in leaks test

Fix timer_create parameters to cope with timer_create API changes
(SIGEV_SIGNAL is no longer supported).  Add a fork test to verify
automatic objects destruction upon process termination.

---

 testsuite/regression/posix/leaks.c |   42 +++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/testsuite/regression/posix/leaks.c 
b/testsuite/regression/posix/leaks.c
index f368cae..4e8a769 100644
--- a/testsuite/regression/posix/leaks.c
+++ b/testsuite/regression/posix/leaks.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -50,6 +53,28 @@ static void *empty(void *cookie)
return cookie;
 }
 
+static void subprocess_leak(void)
+{
+   struct sigevent sevt;
+   pthread_mutex_t mutex;
+   pthread_cond_t cond;
+   pthread_t thread;
+   sem_t sem, *psem;
+   timer_t tm;
+   int fd;
+
+   check_pthread(pthread_create(&thread, NULL, empty, NULL));
+   check_pthread(pthread_mutex_init(&mutex, NULL));
+   check_pthread(pthread_cond_init(&cond, NULL));
+   check_unix(sem_init(&sem, 0, 0));
+   check_unix(-!(psem = sem_open(SEM_NAME, O_CREAT, 0644, 1)));
+   sevt.sigev_notify = SIGEV_THREAD_ID;
+   sevt.sigev_signo = SIGALRM;
+   sevt.sigev_notify_thread_id = syscall(__NR_gettid);
+   check_unix(timer_create(CLOCK_MONOTONIC, &sevt, &tm));
+   check_unix(fd = mq_open(MQ_NAME, O_RDWR | O_CREAT, 0644, NULL));
+}
+
 int main(void)
 {
unsigned long long before;
@@ -60,6 +85,7 @@ int main(void)
pthread_t thread;
sem_t sem, *psem;
timer_t tm;
+   pid_t child;
 
mlockall(MCL_CURRENT|MCL_FUTURE);
 
@@ -93,8 +119,9 @@ int main(void)
check_used("named sem", before, failed);
 
before = get_used();
-   sevt.sigev_notify = SIGEV_SIGNAL;
+   sevt.sigev_notify = SIGEV_THREAD_ID;
sevt.sigev_signo = SIGALRM;
+   sevt.sigev_notify_thread_id = syscall(__NR_gettid);
check_unix(timer_create(CLOCK_MONOTONIC, &sevt, &tm));
check_unix(timer_delete(tm));
check_used("timer", before, failed);
@@ -105,5 +132,18 @@ int main(void)
check_unix(mq_unlink(MQ_NAME));
check_used("mq", before, failed);
 
+   before = get_used();
+   check_unix(child = fork());
+   if (!child) {
+   subprocess_leak();
+   return EXIT_SUCCESS;
+   }
+   while (waitpid(child, NULL, 0) == -1 && errno == EINTR);
+   sleep(1);   /* Leave some time for xnheap
+* deferred free */
+   check_unix(sem_unlink(SEM_NAME));
+   check_unix(mq_unlink(MQ_NAME));
+   check_used("fork", before, failed);
+
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Gilles Chanteperdrix : testsuite: various improvements in leaks test

2013-12-19 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 1410e01b42289d58f9e7bef1e4bfc12de4620b3d
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=1410e01b42289d58f9e7bef1e4bfc12de4620b3d

Author: Gilles Chanteperdrix 
Date:   Sun Dec 15 19:54:36 2013 +0100

testsuite: various improvements in leaks test

Fix timer_create parameters to cope with timer_create API changes
(SIGEV_SIGNAL is no longer supported).  Add a fork test to verify
automatic objects destruction upon process termination.

---

 testsuite/regression/posix/leaks.c |   42 +++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/testsuite/regression/posix/leaks.c 
b/testsuite/regression/posix/leaks.c
index f368cae..4e8a769 100644
--- a/testsuite/regression/posix/leaks.c
+++ b/testsuite/regression/posix/leaks.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -50,6 +53,28 @@ static void *empty(void *cookie)
return cookie;
 }
 
+static void subprocess_leak(void)
+{
+   struct sigevent sevt;
+   pthread_mutex_t mutex;
+   pthread_cond_t cond;
+   pthread_t thread;
+   sem_t sem, *psem;
+   timer_t tm;
+   int fd;
+
+   check_pthread(pthread_create(&thread, NULL, empty, NULL));
+   check_pthread(pthread_mutex_init(&mutex, NULL));
+   check_pthread(pthread_cond_init(&cond, NULL));
+   check_unix(sem_init(&sem, 0, 0));
+   check_unix(-!(psem = sem_open(SEM_NAME, O_CREAT, 0644, 1)));
+   sevt.sigev_notify = SIGEV_THREAD_ID;
+   sevt.sigev_signo = SIGALRM;
+   sevt.sigev_notify_thread_id = syscall(__NR_gettid);
+   check_unix(timer_create(CLOCK_MONOTONIC, &sevt, &tm));
+   check_unix(fd = mq_open(MQ_NAME, O_RDWR | O_CREAT, 0644, NULL));
+}
+
 int main(void)
 {
unsigned long long before;
@@ -60,6 +85,7 @@ int main(void)
pthread_t thread;
sem_t sem, *psem;
timer_t tm;
+   pid_t child;
 
mlockall(MCL_CURRENT|MCL_FUTURE);
 
@@ -93,8 +119,9 @@ int main(void)
check_used("named sem", before, failed);
 
before = get_used();
-   sevt.sigev_notify = SIGEV_SIGNAL;
+   sevt.sigev_notify = SIGEV_THREAD_ID;
sevt.sigev_signo = SIGALRM;
+   sevt.sigev_notify_thread_id = syscall(__NR_gettid);
check_unix(timer_create(CLOCK_MONOTONIC, &sevt, &tm));
check_unix(timer_delete(tm));
check_used("timer", before, failed);
@@ -105,5 +132,18 @@ int main(void)
check_unix(mq_unlink(MQ_NAME));
check_used("mq", before, failed);
 
+   before = get_used();
+   check_unix(child = fork());
+   if (!child) {
+   subprocess_leak();
+   return EXIT_SUCCESS;
+   }
+   while (waitpid(child, NULL, 0) == -1 && errno == EINTR);
+   sleep(1);   /* Leave some time for xnheap
+* deferred free */
+   check_unix(sem_unlink(SEM_NAME));
+   check_unix(mq_unlink(MQ_NAME));
+   check_used("fork", before, failed);
+
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git