Skip to content

Commit

Permalink
Use hashlib.md5 for computing hashes for TEST-SERIALIZE commands
Browse files Browse the repository at this point in the history
Windows has some issue where `hash()` returns different values for the
same string in the different child processes. md5() returns the same
values in each.
  • Loading branch information
timwoj committed Dec 13, 2022
1 parent 8a84682 commit 754bc09
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions btest
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import configparser
import copy
import fnmatch
import glob
import hashlib
import io
import multiprocess as mp
import multiprocess.managers as mp_managers
Expand Down Expand Up @@ -498,7 +499,7 @@ class TestManager(mp_managers.SyncManager):
if not t:
continue

if t.serialize and hash(t.serialize) % self._options.threads != thread_num:
if t.serialize and int(hashlib.md5(t.serialize.encode('utf-8')).hexdigest(), 16) % self._options.threads != thread_num:
# Not ours.
continue

Expand Down Expand Up @@ -902,7 +903,7 @@ class Test(object):
self.cmdseqs.append(seq)

if "serialize" in cmds:
self.serialize = cmds["serialize"]
self.serialize = cmds["serialize"].strip()

if "port" in cmds:
self.ports |= set(cmd.strip() for cmd in cmds['port'])
Expand Down

0 comments on commit 754bc09

Please sign in to comment.