|
From: <sv...@va...> - 2015-06-02 09:21:36
|
Author: rhyskidd
Date: Tue Jun 2 10:21:28 2015
New Revision: 15302
Log:
Add regression test for bz#228343.
Added:
trunk/none/tests/darwin/bug228343.c
trunk/none/tests/darwin/bug228343.stderr.exp
trunk/none/tests/darwin/bug228343.stdout.exp
trunk/none/tests/darwin/bug228343.vgtest
Modified:
trunk/none/tests/darwin/ (props changed)
trunk/none/tests/darwin/Makefile.am
Modified: trunk/none/tests/darwin/Makefile.am
==============================================================================
--- trunk/none/tests/darwin/Makefile.am (original)
+++ trunk/none/tests/darwin/Makefile.am Tue Jun 2 10:21:28 2015
@@ -6,12 +6,14 @@
EXTRA_DIST = \
access_extended.stderr.exp access_extended.vgtest \
apple-main-arg.stderr.exp apple-main-arg.vgtest \
+ bug228343.stderr.exp bug228343.stdout.exp bug228343.vgtest \
bug254164.stderr.exp bug254164.vgtest \
rlimit.stderr.exp rlimit.vgtest
check_PROGRAMS = \
access_extended \
apple-main-arg \
+ bug228343 \
bug254164 \
rlimit
Added: trunk/none/tests/darwin/bug228343.c
==============================================================================
--- trunk/none/tests/darwin/bug228343.c (added)
+++ trunk/none/tests/darwin/bug228343.c Tue Jun 2 10:21:28 2015
@@ -0,0 +1,58 @@
+// https://bugs.kde.org/show_bug.cgi?id=228343
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <libkern/OSAtomic.h>
+#include <pthread.h>
+
+OSSpinLock sl = OS_SPINLOCK_INIT;
+typedef void *(*worker_t)(void*);
+typedef void (*Sigaction)(int, siginfo_t *, void *);
+
+int GLOB=0;
+
+static void EnableSigprof(Sigaction SignalHandler) {
+ struct sigaction sa;
+ sa.sa_sigaction = SignalHandler;
+ sa.sa_flags = SA_RESTART | SA_SIGINFO;
+ sigemptyset(&sa.sa_mask);
+ if (sigaction(SIGPROF, &sa, NULL) != 0) {
+ perror("sigaction");
+ abort();
+ }
+ struct itimerval timer;
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = 1000000 / 10000;
+ timer.it_value = timer.it_interval;
+ if (setitimer(ITIMER_PROF, &timer, 0) != 0) {
+ perror("setitimer");
+ abort();
+ }
+}
+
+void *Worker() {
+ for (long int i = 0; i < 100000000; i++) {
+ void *x = malloc((i % 64) + 1);
+ free (x);
+ }
+}
+
+void SignalHandlerWithSpinlock(int sig, siginfo_t *siginfo, void *context) {
+ OSSpinLockLock(&sl);
+ GLOB++;
+ OSSpinLockUnlock(&sl);
+}
+
+int main() {
+ EnableSigprof(SignalHandlerWithSpinlock);
+ pthread_t w_1;
+ pthread_t w_2;
+ pthread_create(&w_1, NULL, Worker, NULL);
+ pthread_create(&w_2, NULL, Worker, NULL);
+ pthread_join(w_1, NULL);
+ pthread_join(w_2, NULL);
+ printf("\tGLOB=%d\n", GLOB);
+ return 0;
+}
Added: trunk/none/tests/darwin/bug228343.stderr.exp
==============================================================================
(empty)
Added: trunk/none/tests/darwin/bug228343.stdout.exp
==============================================================================
--- trunk/none/tests/darwin/bug228343.stdout.exp (added)
+++ trunk/none/tests/darwin/bug228343.stdout.exp Tue Jun 2 10:21:28 2015
@@ -0,0 +1 @@
+ GLOB=0
Added: trunk/none/tests/darwin/bug228343.vgtest
==============================================================================
--- trunk/none/tests/darwin/bug228343.vgtest (added)
+++ trunk/none/tests/darwin/bug228343.vgtest Tue Jun 2 10:21:28 2015
@@ -0,0 +1,2 @@
+prog: bug228343
+vgopts: -q --tool=none
|