From: Tomas Krizek Date: Tue, 20 Nov 2018 16:25:06 +0000 (+0100) Subject: pytests: parametrize test_prefix_trailing_garbage X-Git-Tag: v3.2.0~18^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56da297b8b006b79274c9d77b04b5076d67e121f;p=thirdparty%2Fknot-resolver.git pytests: parametrize test_prefix_trailing_garbage --- diff --git a/tests/pytests/conftest.py b/tests/pytests/conftest.py index 9e7370d31..0a0431bff 100644 --- a/tests/pytests/conftest.py +++ b/tests/pytests/conftest.py @@ -51,6 +51,22 @@ def sock_family(request): return request.param +@pytest.fixture(params=[ + True, + False +]) +def single_buffer(request): # whether to send all data in a single buffer + return request.param + + +@pytest.fixture(params=[ + True, + False +]) +def query_before(request): # whether to send an initial query + return request.param + + @pytest.mark.optionalhook def pytest_metadata(metadata): # filter potentially sensitive data from GitLab CI keys_to_delete = [] diff --git a/tests/pytests/test_conn_mgmt.py b/tests/pytests/test_conn_mgmt.py index 4613b6468..b5ff92b6c 100644 --- a/tests/pytests/test_conn_mgmt.py +++ b/tests/pytests/test_conn_mgmt.py @@ -9,22 +9,6 @@ import pytest import utils -@pytest.fixture(params=[ - True, - False -]) -def single_buffer(request): # whether to send all data in a single buffer - return request.param - - -@pytest.fixture(params=[ - True, - False -]) -def query_before(request): # whether to send an initial query - return request.param - - @pytest.mark.parametrize('garbage_lengths', [ (1,), (1024,), diff --git a/tests/pytests/test_prefix.py b/tests/pytests/test_prefix.py index 389ef99d5..ed6150205 100644 --- a/tests/pytests/test_prefix.py +++ b/tests/pytests/test_prefix.py @@ -105,11 +105,22 @@ def test_prefix_cuts_message(kresd_sock, send_query_before): send_invalid_repeatedly(kresd_sock, invalid_buff) -def test_trailing_garbage(kresd_sock): +@pytest.mark.parametrize('glength', [ + 0, + 1, + 8, + 1024, + 4096, + 20000, +]) +def test_prefix_trailing_garbage(kresd_sock, glength, query_before): """Send messages with trailing garbage (its length included in prefix).""" + if query_before: + utils.ping_alive(kresd_sock) + for _ in range(10): wire, msgid = utils.prepare_wire() - wire += utils.get_garbage(8) + wire += utils.get_garbage(glength) buff = utils.prepare_buffer(wire) kresd_sock.sendall(buff)