aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/py/lib
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-07-18 20:51:39 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-07-18 20:51:39 +0200
commit89531fe099473d13c83cfdb2712fa9841fb6a172 (patch)
tree53e51150bb6f2937e196ee92a0452e34872889e2 /test/py/lib
parentimplement flame graph generation (diff)
downloadcimple-89531fe099473d13c83cfdb2712fa9841fb6a172.tar.gz
cimple-89531fe099473d13c83cfdb2712fa9841fb6a172.zip
test: speed up output_long test_repo tests
Diffstat (limited to 'test/py/lib')
-rw-r--r--test/py/lib/test_repo.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/test/py/lib/test_repo.py b/test/py/lib/test_repo.py
index e3e875b..2820659 100644
--- a/test/py/lib/test_repo.py
+++ b/test/py/lib/test_repo.py
@@ -159,12 +159,8 @@ class TestRepoOutputEmpty(TestRepoOutput):
return len(output) == 0
-# Making it a bash script introduces way too much overhead with all the
-# argument expansions; it slows things down considerably.
-OUTPUT_SCRIPT_LONG = r'''#!/usr/bin/env python3
-output = {output}
-import sys
-sys.stdout.write(output)
+OUTPUT_SCRIPT_LONG = r'''#!/bin/sh -e
+dd if=/dev/urandom count={output_len_kb} bs=1024 | base64
'''
@@ -173,11 +169,6 @@ class TestRepoOutputLong(TestRepoOutput):
OUTPUT_LEN_KB = 300
- def __init__(self, *args, **kwargs):
- nb = TestRepoOutputLong.OUTPUT_LEN_KB * 1024
- self.output = base64.encodebytes(random.randbytes(nb)).decode()
- super().__init__(*args, **kwargs)
-
@staticmethod
def codename():
return 'output_long'
@@ -187,10 +178,12 @@ class TestRepoOutputLong(TestRepoOutput):
return True
def format_output_script(self):
- return OUTPUT_SCRIPT_LONG.format(output=repr(self.output))
+ output_len = TestRepoOutputLong.OUTPUT_LEN_KB
+ output_len = shlex.quote(str(output_len))
+ return OUTPUT_SCRIPT_LONG.format(output_len_kb=output_len)
def run_output_matches(self, output):
- return output.decode() == self.output
+ return len(output) > TestRepoOutputLong.OUTPUT_LEN_KB * 1024
OUTPUT_SCRIPT_NULL = r'''#!/usr/bin/env python3