aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-07-10 02:42:53 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-07-10 02:42:53 +0200
commita2cfab583c8739356fd7e6c0f822e8f247e61b87 (patch)
treef46a714aeb1f29af5189304615e89a78a404ad40 /test
parentstring: add a comment (diff)
downloadcimple-a2cfab583c8739356fd7e6c0f822e8f247e61b87.tar.gz
cimple-a2cfab583c8739356fd7e6c0f822e8f247e61b87.zip
test: test CI run output containing \0
Diffstat (limited to 'test')
-rw-r--r--test/py/conftest.py11
-rw-r--r--test/py/lib/test_repo.py26
2 files changed, 34 insertions, 3 deletions
diff --git a/test/py/conftest.py b/test/py/conftest.py
index 3a9c589..0131c37 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -8,10 +8,10 @@ import os
from pytest import fixture
+from lib import test_repo
from lib.db import Database
from lib.net import random_unused_port
from lib.process import CmdLine
-from lib.test_repo import TestRepoOutputSimple, TestRepoOutputEmpty, TestRepoOutputLong
class Param:
@@ -188,8 +188,13 @@ def client(client_cmd):
return client_cmd
-@fixture(params=[TestRepoOutputSimple, TestRepoOutputEmpty, TestRepoOutputLong],
- ids=['output_simple', 'output_empty', 'output_long'])
+@fixture(params=[
+ test_repo.TestRepoOutputSimple,
+ test_repo.TestRepoOutputEmpty,
+ test_repo.TestRepoOutputLong,
+ test_repo.TestRepoOutputNull,
+ ],
+ ids=['output_simple', 'output_empty', 'output_long', 'output_null'])
def test_repo(tmp_path, request):
return request.param(os.path.join(tmp_path, 'repo'))
diff --git a/test/py/lib/test_repo.py b/test/py/lib/test_repo.py
index 3234de5..b882d57 100644
--- a/test/py/lib/test_repo.py
+++ b/test/py/lib/test_repo.py
@@ -167,3 +167,29 @@ class TestRepoOutputLong(TestRepoOutput):
def run_output_matches(self, output):
return output.decode() == self.output
+
+
+OUTPUT_SCRIPT_NULL = R'''#!/usr/bin/env python3
+
+output = {output}
+
+import sys
+sys.stdout.buffer.write(output)
+'''
+
+
+class TestRepoOutputNull(TestRepoOutput):
+ __test__ = False
+
+ OUTPUT = b'123\x00456'
+
+ def __init__(self, *args, **kwargs):
+ self.output = TestRepoOutputNull.OUTPUT
+ super().__init__(*args, **kwargs)
+
+ def _format_output_script(self):
+ assert len(self.output) == 7
+ return OUTPUT_SCRIPT_NULL.format(output=repr(self.output))
+
+ def run_output_matches(self, output):
+ return output == self.output