From 1e14d782fcd1ff9a11914280fd64ff1877edad5e Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza Date: Wed, 8 Jan 2025 14:36:57 -0300 Subject: [PATCH] tests: Add tests for MICRO6 Signed-off-by: Marcos Paulo de Souza --- tests/test_setup.py | 20 ++++++++++++++++++++ tests/test_templ.py | 27 +++++++++++++++++++++++++++ tests/utils.py | 6 ++++++ 3 files changed, 53 insertions(+) diff --git a/tests/test_setup.py b/tests/test_setup.py index b5a9aaa..7b117d0 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -7,6 +7,7 @@ from klpbuild.setup import Setup from klpbuild import utils +from tests.utils import get_codestreams_file CS = "15.5u19" DEFAULT_DATA = {"cve": None, "lp_filter": CS, "lp_skips": None, "conf": "CONFIG_TUN", "no_check": False} @@ -77,6 +78,25 @@ def test_invalid_sym(caplog): assert "Symbols tun_chr_ioctll not found on tun" in caplog.text +def test_valid_micro_patchid(): + # Make sure that patchid is informed for SLE MICRO + lp = "bsc_" + inspect.currentframe().f_code.co_name + lp_setup = Setup(lp) + + ffuncs = {"drivers/net/tun.c": {"module": "tun", "conf": "CONFIG_TUN", + "symbols": ["tun_chr_ioctl", "tun_free_netdev"]}} + + micro_cs = "6.0u2" + micro_data = {"cve": None, "lp_filter": micro_cs, "lp_skips": None, "conf": "CONFIG_TUN", "no_check": False} + + codestreams = lp_setup.setup_codestreams(micro_data) + lp_setup.setup_project_files(codestreams, ffuncs, utils.ARCHS) + + cs_conf = get_codestreams_file(lp)["codestreams"][micro_cs] + + assert cs_conf["patchid"] + + def test_valite_conf_mod_file_funcs(): # Check that passing mod-file-funcs can create entries differently from general # --module and --file-funcs diff --git a/tests/test_templ.py b/tests/test_templ.py index 67ce01e..698ed4f 100644 --- a/tests/test_templ.py +++ b/tests/test_templ.py @@ -91,6 +91,11 @@ def test_check_header_file_included(): # test the livepatch_ prefix file assert "Upstream commit:" in get_file_content(lp, cs) + # Check for all supported codestreams + for item in ["SLE12-SP5", "SLE15-SP2 and -SP3", "SLE15-SP4 and -SP5", + "SLE15-SP6", "SLE MICRO6-0"]: + assert item in get_file_content(lp, cs) + # Check the other two files assert "Upstream commit:" not in get_file_content(lp, cs, f"{lp}_kernel_events_core.c") assert "Upstream commit:" not in get_file_content(lp, cs, f"{lp}_net_ipv6_rpl.c") @@ -136,3 +141,25 @@ def test_templ_exts_mod_name(): # The module name should be nvme_core instead of nvme-core assert '{ "nvme_should_fail", (void *)&klpe_nvme_should_fail, "nvme_core" },' in get_file_content(lp, cs) + + +def test_templ_micro_not_mod_mutex(): + """ + SLE Micro doesn't use module_mutex because it uses kernel 6.5, so + make sure TemplateGen doesn't use it. + """ + lp = "bsc_" + inspect.currentframe().f_code.co_name + cs = "6.0u2" + + lp_setup = Setup(lp) + ffuncs = Setup.setup_file_funcs("CONFIG_NVME_TCP", "nvme-tcp", [ + ["drivers/nvme/host/tcp.c", "nvme_tcp_io_work"]], [], []) + + codestreams = lp_setup.setup_codestreams( + {"cve": None, "lp_filter": cs, "lp_skips": None, "conf": "CONFIG_NVME_TCP", "no_check": True}) + + lp_setup.setup_project_files(codestreams, ffuncs, utils.ARCHS) + + Extractor(lp_name=lp, lp_filter=cs, apply_patches=False, avoid_ext=[]).run() + + assert 'module_mutex' not in get_file_content(lp, cs) diff --git a/tests/utils.py b/tests/utils.py index 1002286..47226c2 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -4,6 +4,7 @@ # Author: Marcos Paulo de Souza from pathlib import Path +import json from klpbuild.config import Config @@ -21,3 +22,8 @@ def get_file_content(lp_name, lp_filter, fname=None): with open(Path(path, fname)) as f: return f.read() + + +def get_codestreams_file(lp_name): + with open(Path(get_workdir(lp_name), "codestreams.json")) as f: + return json.loads(f.read())