svn commit: r329840 - projects/zfsd/head/tests/sys/cddl/zfs/tests/txg_integrity
Alan Somers
asomers at FreeBSD.org
Thu Feb 22 22:24:02 UTC 2018
Author: asomers
Date: Thu Feb 22 22:24:01 2018
New Revision: 329840
URL: https://svnweb.freebsd.org/changeset/base/329840
Log:
apply PEP8 style to a python helper script
Sponsored by: Spectra Logic Corp
Modified:
projects/zfsd/head/tests/sys/cddl/zfs/tests/txg_integrity/make_patterns.py
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/txg_integrity/make_patterns.py
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/txg_integrity/make_patterns.py Thu Feb 22 21:41:58 2018 (r329839)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/txg_integrity/make_patterns.py Thu Feb 22 22:24:01 2018 (r329840)
@@ -1,51 +1,57 @@
#! /usr/bin/env python
# Generate random IO patterns for the txg_integrity test
-# We do this statically and embed the results into the code so that the
+# We do this statically and embed the results into the code so that the
# Testing will be more repeatable compared to generating the tables at runtime
import random
CLUSTERSIZE = (1 << 16)
-NUM_CHUNKS = 64
+NUM_CHUNKS = 64
def rand_partition():
- partitions = []
- while len(partitions) != NUM_CHUNKS:
- #We don't want any duplicates, so we make a set and then check that its
- #length is correct
- partitions = sorted(
- list(
- set(
- [random.randrange(0, 2**31, (2**31) * 8 / (NUM_CHUNKS * CLUSTERSIZE))
- for i in range(NUM_CHUNKS - 1)] + [2**31])))
- return partitions
+ partitions = []
+ while len(partitions) != NUM_CHUNKS:
+ # We don't want any duplicates, so we make a set and then check that
+ # its length is correct
+ partitions = sorted(
+ list(
+ set(
+ [random.randrange(0,
+ 2**31,
+ (2**31) * 8 / (NUM_CHUNKS * CLUSTERSIZE))
+ for i in range(NUM_CHUNKS - 1)] + [2**31])))
+ return partitions
+
def rand_permutation():
- perm = range(NUM_CHUNKS)
- random.shuffle(perm)
- return perm
+ perm = range(NUM_CHUNKS)
+ random.shuffle(perm)
+ return perm
+
def rand_follower_bitmap():
- bmp = 0;
- chunks = random.sample(range(NUM_CHUNKS), NUM_CHUNKS / 2)
- for chunk in chunks:
- bmp |= (1 << chunk)
- return bmp
+ bmp = 0
+ chunks = random.sample(range(NUM_CHUNKS), NUM_CHUNKS / 2)
+ for chunk in chunks:
+ bmp |= (1 << chunk)
+ return bmp
+
def print_pattern(n):
- print "const pattern_t pat%d = {" % n
- print " {",
- for p in rand_partition():
- print "%#x, " % p,
- print " },"
- print " {",
- for p in rand_permutation():
- print "%d, " % p,
- print " },"
- print " %#x" % rand_follower_bitmap()
- print "};"
+ print "const pattern_t pat%d = {" % n
+ print " {",
+ for p in rand_partition():
+ print "%#x, " % p,
+ print " },"
+ print " {",
+ for p in rand_permutation():
+ print "%d, " % p,
+ print " },"
+ print " %#x" % rand_follower_bitmap()
+ print "};"
+
for n in range(32):
- print_pattern(n)
+ print_pattern(n)
More information about the svn-src-projects
mailing list