Skip to content

Commit 74582b6

Browse files
committed
contest: hw: remove the seen handling
We explicitly add random chars to kernel version, the collisions of kernel versions should not happen. Remove the .seen markers because they interfere with continuing tests after reboot. We could just remove the correct one but really the seen stuff is pointless. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent bb88e15 commit 74582b6

4 files changed

Lines changed: 16 additions & 79 deletions

File tree

contest/hw/README.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,6 @@ coordinate crash recovery between hwksft and hw-worker:
408408
tests in this list are skipped and reported as failures. This ensures
409409
a crashing test is never retried.
410410

411-
``.seen``
412-
Standard "already picked up" marker (an empty file created in each
413-
test directory). Prevents re-discovery of old test sets.
414-
415411
hw-worker
416412
=========
417413

@@ -428,22 +424,20 @@ Operation
428424
``uname -r``. If the running kernel doesn't match, this is a boot into
429425
the wrong kernel (e.g. default kernel after power cycle) — exit
430426
immediately.
431-
3. Mark all entries under ``/srv/hw-worker/tests`` as "seen" (create a
432-
``.seen`` file in each directory). This prevents loop-testing the same set.
433-
4. Open ``/dev/kmsg`` and drain existing boot messages to
427+
3. Open ``/dev/kmsg`` and drain existing boot messages to
434428
``results_dir/boot-dmesg``.
435-
5. Run the tests. For each test:
429+
4. Run the tests. For each test:
436430
a. Check if test name is in ``.attempted`` — if so, skip (crash recovery).
437431
b. Write test name to ``.attempted`` + fsync before execution.
438432
c. Run via ``./run_kselftest.sh -t <target>:<test>`` (installed form).
439433
d. Capture stdout/stderr, save to ``results_dir/<idx>-<name>/``.
440434
e. Drain ``/dev/kmsg`` — if any dmesg output was produced during
441435
the test, save it to ``results_dir/<idx>-<name>/dmesg``.
442436
f. Save metadata to ``results_dir/<idx>-<name>/info`` (JSON).
443-
6. Results are saved under ``/srv/hw-worker/results/$reservation_id/``.
437+
5. Results are saved under ``/srv/hw-worker/results/$reservation_id/``.
444438
hw-worker does **not** determine pass/fail — that is done by hwksft
445439
when it copies back and parses the output files.
446-
7. Service exits.
440+
6. Service exits.
447441

448442
Output artifacts
449443
----------------

contest/hw/hw_worker.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sys
1010
import time
1111

12-
from lib.runner import find_newest_unseen, mark_all_seen, run_tests
12+
from lib.runner import find_newest_test, run_tests
1313

1414

1515
TESTS_DIR = '/srv/hw-worker/tests'
@@ -219,7 +219,7 @@ def main():
219219
tests_dir = TESTS_DIR
220220
results_base = RESULTS_DIR
221221

222-
test_dir = find_newest_unseen(tests_dir)
222+
test_dir = find_newest_test(tests_dir)
223223
if test_dir is None:
224224
print("No outstanding tests found")
225225
return
@@ -243,8 +243,6 @@ def main():
243243
f"Kernel mismatch: running {actual}, expected {expected}")
244244
return
245245

246-
mark_all_seen(tests_dir)
247-
248246
print(test_dir, "Starting tests")
249247

250248
# Configure test interfaces and write net.config

contest/hw/lib/runner.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from lib.nipa import has_crash, extract_crash, namify
1111

1212

13-
def find_newest_unseen(tests_dir):
14-
"""Scan tests_dir for subdirectories without .seen file.
13+
def find_newest_test(tests_dir):
14+
"""Scan tests_dir for the newest test subdirectory.
1515
1616
Returns the newest one (by mtime) or None.
1717
"""
@@ -23,8 +23,6 @@ def find_newest_unseen(tests_dir):
2323
full = os.path.join(tests_dir, entry)
2424
if not os.path.isdir(full):
2525
continue
26-
if os.path.exists(os.path.join(full, '.seen')):
27-
continue
2826
candidates.append((os.path.getmtime(full), full))
2927

3028
if not candidates:
@@ -34,21 +32,6 @@ def find_newest_unseen(tests_dir):
3432
return candidates[0][1]
3533

3634

37-
def mark_all_seen(tests_dir):
38-
"""Touch .seen file in every subdirectory of tests_dir."""
39-
if not os.path.isdir(tests_dir):
40-
return
41-
42-
for entry in os.listdir(tests_dir):
43-
full = os.path.join(tests_dir, entry)
44-
if not os.path.isdir(full):
45-
continue
46-
seen_path = os.path.join(full, '.seen')
47-
if not os.path.exists(seen_path):
48-
with open(seen_path, 'w', encoding='utf-8') as fp:
49-
fp.write('')
50-
51-
5235
def load_attempted(test_dir):
5336
"""Load .attempted file (JSON list of test names already tried).
5437

contest/hw/tests/test_hw_worker.py

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,21 @@
1010

1111
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
1212

13-
from lib.runner import (find_newest_unseen, mark_all_seen, load_attempted,
13+
from lib.runner import (find_newest_test, load_attempted,
1414
mark_attempted, run_tests, DmesgReader)
1515
from lib.nipa import namify
1616

1717

18-
class TestFindNewestUnseen(unittest.TestCase):
19-
def test_single_unseen(self):
18+
class TestFindNewestTest(unittest.TestCase):
19+
def test_single_dir(self):
2020
with tempfile.TemporaryDirectory() as tmpdir:
2121
test_dir = os.path.join(tmpdir, 'test1')
2222
os.makedirs(test_dir)
2323

24-
result = find_newest_unseen(tmpdir)
24+
result = find_newest_test(tmpdir)
2525
self.assertEqual(result, test_dir)
2626

27-
def test_all_seen(self):
28-
with tempfile.TemporaryDirectory() as tmpdir:
29-
test_dir = os.path.join(tmpdir, 'test1')
30-
os.makedirs(test_dir)
31-
with open(os.path.join(test_dir, '.seen'), 'w') as fp:
32-
fp.write('')
33-
34-
result = find_newest_unseen(tmpdir)
35-
self.assertIsNone(result)
36-
37-
def test_multiple_unseen_picks_newest(self):
27+
def test_multiple_picks_newest(self):
3828
with tempfile.TemporaryDirectory() as tmpdir:
3929
dir1 = os.path.join(tmpdir, 'test1')
4030
dir2 = os.path.join(tmpdir, 'test2')
@@ -46,43 +36,19 @@ def test_multiple_unseen_picks_newest(self):
4636
time.sleep(0.1)
4737
os.utime(dir2, None)
4838

49-
result = find_newest_unseen(tmpdir)
39+
result = find_newest_test(tmpdir)
5040
self.assertEqual(result, dir2)
5141

5242
def test_empty_dir(self):
5343
with tempfile.TemporaryDirectory() as tmpdir:
54-
result = find_newest_unseen(tmpdir)
44+
result = find_newest_test(tmpdir)
5545
self.assertIsNone(result)
5646

5747
def test_nonexistent_dir(self):
58-
result = find_newest_unseen('/nonexistent/path')
48+
result = find_newest_test('/nonexistent/path')
5949
self.assertIsNone(result)
6050

6151

62-
class TestMarkAllSeen(unittest.TestCase):
63-
def test_marks_all(self):
64-
with tempfile.TemporaryDirectory() as tmpdir:
65-
for name in ['test1', 'test2', 'test3']:
66-
os.makedirs(os.path.join(tmpdir, name))
67-
68-
mark_all_seen(tmpdir)
69-
70-
for name in ['test1', 'test2', 'test3']:
71-
self.assertTrue(
72-
os.path.exists(os.path.join(tmpdir, name, '.seen'))
73-
)
74-
75-
def test_already_seen_not_error(self):
76-
with tempfile.TemporaryDirectory() as tmpdir:
77-
test_dir = os.path.join(tmpdir, 'test1')
78-
os.makedirs(test_dir)
79-
with open(os.path.join(test_dir, '.seen'), 'w') as fp:
80-
fp.write('')
81-
82-
# Should not raise
83-
mark_all_seen(tmpdir)
84-
85-
8652
class TestKernelVersionCheck(unittest.TestCase):
8753
@mock.patch('os.uname',
8854
return_value=mock.Mock(release='5.15.0-generic'))
@@ -494,10 +460,6 @@ def test_full_run(self, mock_run, mock_dmesg_cls, mock_uname):
494460
self.assertTrue(os.path.exists(os.path.join(test_output, 'info')))
495461
self.assertTrue(os.path.exists(os.path.join(test_output, 'stdout')))
496462

497-
# .seen should be created
498-
seen_path = os.path.join(test_dir, '.seen')
499-
self.assertTrue(os.path.exists(seen_path))
500-
501463
@mock.patch('os.uname')
502464
@mock.patch('lib.runner.DmesgReader')
503465
@mock.patch('subprocess.run')

0 commit comments

Comments
 (0)