Use deterministic order of dict for tests

This commit is contained in:
Lukas Slebodnik 2019-01-18 20:22:11 +01:00
parent f5b18a5dbb
commit d707c03707
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,43 @@
From b34b0f3459523a93da37e881bc2bb59e5274cff8 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@fedoraproject.org>
Date: Fri, 18 Jan 2019 19:55:02 +0100
Subject: [PATCH] ldb: Use deterministic order of dict for tests
Test failed on s390x but there is a simple reproducer for any
architecture
for i in {1..30}; do
PYTHONHASHSEED=random \
python2 -c 'import ldb; msg = ldb.Message(); msg.dn = ldb.Dn(ldb.Ldb(), "dc=foo29"); msg["dc"] = b"foo"; print(repr(msg)) '
done
======================================================================
FAIL: test_repr (__main__.LdbMsgTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests/python/api.py", line 2322, in test_repr
"Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])})")
AssertionError: "Message({'dc': MessageElement(['foo']), 'dn': Dn('dc=foo29')})" != "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])})"
----------------------------------------------------------------------
Ran 1025 tests in 29.146s
FAILED (failures=1)
---
wscript | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wscript b/wscript
index 851344733645f51186d0b568f2741ac888a52660..02307956ccca7fdec16ba9e3aafc9b56c3a9a3e0 100644
--- a/wscript
+++ b/wscript
@@ -559,7 +559,7 @@ def test(ctx):
if env.HAVE_LMDB:
pyret = samba_utils.RUN_PYTHON_TESTS(
['tests/python/api.py', 'tests/python/index.py'],
- extra_env={'SELFTEST_PREFIX': test_prefix})
+ extra_env={'SELFTEST_PREFIX': test_prefix, 'PYTHONHASHSEED': '0'})
else:
pyret = 0
print("Python testsuite returned %d" % pyret)
--
2.20.1

View File

@ -46,6 +46,7 @@ Source: http://samba.org/ftp/ldb/ldb-%{version}.tar.gz
Patch0001: 0001-Fix-detection-of-HAVE_LARGEFILE-with-python2.patch
Patch0002: 0002-ldb-Run-at-least-some-tests-on-32-bit-machines.patch
Patch0003: 0003-ldb-Out-ouf-bound-read-in-ldb_wildcard_compare.patch
Patch0004: 0004-ldb-Use-deterministic-order-of-dict-for-tests.patch
BuildRequires: gcc
BuildRequires: libtalloc-devel >= %{talloc_version}