Skip to content

Commit

Permalink
tests: Add tests for MICRO6
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Paulo de Souza <[email protected]>
  • Loading branch information
marcosps committed Jan 8, 2025
1 parent c4d5d23 commit 1e14d78
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions tests/test_templ.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
6 changes: 6 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Author: Marcos Paulo de Souza

from pathlib import Path
import json

from klpbuild.config import Config

Expand All @@ -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())

0 comments on commit 1e14d78

Please sign in to comment.