Skip to content

Commit

Permalink
Fix cgroup kselftests collection
Browse files Browse the repository at this point in the history
This patch filters out kselftests binaries using python regexp, instead
of using a bash script.
  • Loading branch information
acerv committed Mar 6, 2024
1 parent bcb2df8 commit 522a162
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions libkirk/kselftests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.. moduleauthor:: Andrea Cervesato <[email protected]>
"""
import re
import os
import shlex
import logging
Expand Down Expand Up @@ -51,21 +52,26 @@ async def _get_cgroup(self, sut: SUT) -> Suite:
raise KirkException(
f"cgroup folder is not available: {cgroup_dir}")

ret = await sut.run_command(
"basename -s .c -- test_*.c",
cwd=cgroup_dir)
ret = await sut.run_command("ls -1 test_*", cwd=cgroup_dir)
if ret["returncode"] != 0 or not ret["stdout"]:
raise KirkException("Can't read cgroup tests")

names = [n.rstrip() for n in ret["stdout"].split('\n')]
# we want to loop into a list rather than using one regexp that
# rules everything. In this way we are not dependent by ls format
names = ret["stdout"].split('\n')
if not names:
raise KirkException("Can't find cgroup tests")

match = re.compile(r'^test_[^.]+$')
tests_obj = []

for name in names:
if not name:
myname = match.search(name)
if not myname:
continue

tests_obj.append(Test(
name=name,
name=myname,
cmd=os.path.join(cgroup_dir, name),
cwd=cgroup_dir,
parallelizable=False))
Expand Down

0 comments on commit 522a162

Please sign in to comment.