Compare commits

...

2 Commits

Author SHA1 Message Date
Pavel Raiskup 937f421ab3 enable test-lock only, and run verbosely 2017-01-02 12:57:51 +01:00
Pavel Raiskup a50dcb156c test-lock upstream fix 2016-12-25 18:23:01 +01:00
2 changed files with 199 additions and 2 deletions

184
gettext-test-lock-2.patch Normal file
View File

@ -0,0 +1,184 @@
From 8efd076f308626e3c620d70ccba82c2b1bb4f5f6 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Sun, 25 Dec 2016 18:19:28 +0100
Subject: [PATCH] upstream fix
---
gettext-tools/gnulib-tests/test-lock.c | 79 ++++++++++++++++++++++++++++------
1 file changed, 67 insertions(+), 12 deletions(-)
diff --git a/gettext-tools/gnulib-tests/test-lock.c b/gettext-tools/gnulib-tests/test-lock.c
index cb734b4..aa6de27 100644
--- a/gettext-tools/gnulib-tests/test-lock.c
+++ b/gettext-tools/gnulib-tests/test-lock.c
@@ -50,6 +50,13 @@
Uncomment this to see if the operating system has a fair scheduler. */
#define EXPLICIT_YIELD 1
+/* Whether to use 'volatile' on some variables that communicate information
+ between threads. If set to 0, a lock is used to protect these variables.
+ If set to 1, 'volatile' is used; this is theoretically equivalent but can
+ lead to much slower execution (e.g. 30x slower total run time on a 40-core
+ machine. */
+#define USE_VOLATILE 0
+
/* Whether to print debugging messages. */
#define ENABLE_DEBUGGING 0
@@ -103,6 +110,51 @@
# define yield()
#endif
+#if USE_VOLATILE
+struct atomic_int {
+ volatile int value;
+};
+static void
+init_atomic_int (struct atomic_int *ai)
+{
+}
+static int
+get_atomic_int_value (struct atomic_int *ai)
+{
+ return ai->value;
+}
+static void
+set_atomic_int_value (struct atomic_int *ai, int new_value)
+{
+ ai->value = new_value;
+}
+#else
+struct atomic_int {
+ gl_lock_define (, lock)
+ int value;
+};
+static void
+init_atomic_int (struct atomic_int *ai)
+{
+ gl_lock_init (ai->lock);
+}
+static int
+get_atomic_int_value (struct atomic_int *ai)
+{
+ gl_lock_lock (ai->lock);
+ int ret = ai->value;
+ gl_lock_unlock (ai->lock);
+ return ret;
+}
+static void
+set_atomic_int_value (struct atomic_int *ai, int new_value)
+{
+ gl_lock_lock (ai->lock);
+ ai->value = new_value;
+ gl_lock_unlock (ai->lock);
+}
+#endif
+
#define ACCOUNT_COUNT 4
static int account[ACCOUNT_COUNT];
@@ -170,12 +222,12 @@ lock_mutator_thread (void *arg)
return NULL;
}
-static volatile int lock_checker_done;
+static struct atomic_int lock_checker_done;
static void *
lock_checker_thread (void *arg)
{
- while (!lock_checker_done)
+ while (get_atomic_int_value (&lock_checker_done) == 0)
{
dbgprintf ("Checker %p before check lock\n", gl_thread_self_pointer ());
gl_lock_lock (my_lock);
@@ -200,7 +252,8 @@ test_lock (void)
/* Initialization. */
for (i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
- lock_checker_done = 0;
+ init_atomic_int (&lock_checker_done);
+ set_atomic_int_value (&lock_checker_done, 0);
/* Spawn the threads. */
checkerthread = gl_thread_create (lock_checker_thread, NULL);
@@ -210,7 +263,7 @@ test_lock (void)
/* Wait for the threads to terminate. */
for (i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
- lock_checker_done = 1;
+ set_atomic_int_value (&lock_checker_done, 1);
gl_thread_join (checkerthread, NULL);
check_accounts ();
}
@@ -254,12 +307,12 @@ rwlock_mutator_thread (void *arg)
return NULL;
}
-static volatile int rwlock_checker_done;
+static struct atomic_int rwlock_checker_done;
static void *
rwlock_checker_thread (void *arg)
{
- while (!rwlock_checker_done)
+ while (get_atomic_int_value (&rwlock_checker_done) == 0)
{
dbgprintf ("Checker %p before check rdlock\n", gl_thread_self_pointer ());
gl_rwlock_rdlock (my_rwlock);
@@ -284,7 +337,8 @@ test_rwlock (void)
/* Initialization. */
for (i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
- rwlock_checker_done = 0;
+ init_atomic_int (&rwlock_checker_done);
+ set_atomic_int_value (&rwlock_checker_done, 0);
/* Spawn the threads. */
for (i = 0; i < THREAD_COUNT; i++)
@@ -295,7 +349,7 @@ test_rwlock (void)
/* Wait for the threads to terminate. */
for (i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
- rwlock_checker_done = 1;
+ set_atomic_int_value (&rwlock_checker_done, 1);
for (i = 0; i < THREAD_COUNT; i++)
gl_thread_join (checkerthreads[i], NULL);
check_accounts ();
@@ -356,12 +410,12 @@ reclock_mutator_thread (void *arg)
return NULL;
}
-static volatile int reclock_checker_done;
+static struct atomic_int reclock_checker_done;
static void *
reclock_checker_thread (void *arg)
{
- while (!reclock_checker_done)
+ while (get_atomic_int_value (&reclock_checker_done) == 0)
{
dbgprintf ("Checker %p before check lock\n", gl_thread_self_pointer ());
gl_recursive_lock_lock (my_reclock);
@@ -386,7 +440,8 @@ test_recursive_lock (void)
/* Initialization. */
for (i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
- reclock_checker_done = 0;
+ init_atomic_int (&reclock_checker_done);
+ set_atomic_int_value (&reclock_checker_done, 0);
/* Spawn the threads. */
checkerthread = gl_thread_create (reclock_checker_thread, NULL);
@@ -396,7 +451,7 @@ test_recursive_lock (void)
/* Wait for the threads to terminate. */
for (i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
- reclock_checker_done = 1;
+ set_atomic_int_value (&reclock_checker_done, 1);
gl_thread_join (checkerthread, NULL);
check_accounts ();
}
--
2.9.3

View File

@ -9,7 +9,7 @@
Summary: GNU libraries and utilities for producing multi-lingual messages
Name: gettext
Version: 0.19.8.1
Release: 5%{?dist}
Release: 5.1%{?dist}
License: GPLv3+ and LGPLv2+
Group: Development/Tools
URL: http://www.gnu.org/software/gettext/
@ -21,6 +21,7 @@ Patch0: disable-gettext-runtime-test-lock.patch
# Upstreamed patch:
# http://lists.gnu.org/archive/html/bug-gettext/2016-08/msg00006.html
Patch1: gettext-po-send-mail.patch
Patch2: gettext-test-lock-2.patch
Source2: msghack.py
Source3: msghack.1
# for bootstrapping
@ -251,7 +252,16 @@ done
# this takes quite a lot of time to run
# override LIBUNISTRING to prevent reordering of lib objects
make check LIBUNISTRING=-lunistring
cd gettext-tools/gnulib-tests
make test-lock
set +x
timestamp=`date +"%%s"` ; ( for i in a b c d e ; do ./test-lock ; echo ====; done) | \
while read line
do
printf "%4d " `expr $(date +"%s") - $timestamp`
echo "$line"
done
set -x
%endif
@ -358,6 +368,9 @@ fi
%{_mandir}/man1/msghack.1*
%changelog
* Sun Dec 25 2016 Pavel Raiskup <praiskup@redhat.com> - 0.19.8.1-5.1
- test for upstream fix for test-lock
* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 0.19.8.1-5
- Rebuild for Python 3.6