[3/5] zdtm.py: cache test messages

Submitted by Andrei Vagin on Jan. 2, 2019, 7:06 a.m.

Details

Message ID 20190102070642.27270-4-avagin@gmail.com
State Accepted
Series "travix: a few fixes for docker and fedora jobs"
Headers show

Commit Message

Andrei Vagin Jan. 2, 2019, 7:06 a.m.
Currently, we rely on the fact that nobody else is using random and
parent and child processes will get the same random values.

Now, this test fails on the fedora rawhide. There will be nothing wrong
if we will generate test messages before forking the test process.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
---
 test/zdtm.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm.py b/test/zdtm.py
index f6402c231..5fe8aafc1 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -584,9 +584,14 @@  class inhfd_test:
 		self.__files = None
 		self.__peer_file_names = []
 		self.__dump_opts = []
+		self.__messages = {}
 
 	def __get_message(self, i):
-		return b"".join([random.choice(string.ascii_letters).encode() for _ in range(10)]) + b"%06d" % i
+		m = self.__messages.get(i, None)
+		if not m:
+			m = b"".join([random.choice(string.ascii_letters).encode() for _ in range(10)]) + b"%06d" % i
+		self.__messages[i] = m
+		return m
 
 	def start(self):
 		self.__files = self.__fdtyp.create_fds()