Skip to content

Commit 4512cbf

Browse files
rluboskartben
authored andcommitted
tests: net: sockets: tls_configurations: Use fixture for openssl
Currently, creating and killing openssl process was part of the test. In result, if the test case failed for whatever reason, the openssl process would remain open, causing disruptions in consecutive test executions. Fix that by defining openssl server instance as a pytest fixture. That way, openssl process will be terminated regardless of the test result. Signed-off-by: Robert Lubos <[email protected]>
1 parent 7619592 commit 4512cbf

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/net/socket/tls_configurations/pytest/test_app_vs_openssl.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import subprocess
88
from twister_harness import DeviceAdapter
99

10+
import pytest
11+
1012
logger = logging.getLogger(__name__)
1113

1214
def get_arguments_from_server_type(server_type, port):
@@ -51,7 +53,8 @@ def get_arguments_from_server_type(server_type, port):
5153
"-accept", "{}".format(port)])
5254
return args
5355

54-
def start_server(server_type, port):
56+
@pytest.fixture()
57+
def openssl_server(server_type, port):
5558
logger.info("Server type: " + server_type)
5659
args = get_arguments_from_server_type(server_type, port)
5760
logger.info("Launch command:")
@@ -67,14 +70,12 @@ def start_server(server_type, port):
6770
except subprocess.TimeoutExpired:
6871
logger.info("Server is up")
6972

70-
return openssl
73+
yield
7174

72-
def test_app_vs_openssl(dut: DeviceAdapter, server_type, port):
73-
server = start_server(server_type, port)
75+
logger.info("Kill server")
76+
openssl.kill()
7477

78+
def test_app_vs_openssl(dut: DeviceAdapter, openssl_server):
7579
logger.info("Launch Zephyr application")
7680
dut.launch()
7781
dut.readlines_until("Test PASSED", timeout=3.0)
78-
79-
logger.info("Kill server")
80-
server.kill()

0 commit comments

Comments
 (0)