Files
scst/scripts/kunit/test_headers.py
T
Gleb Chesnokov c3070172c7 kunit: Add a shared test switch and a core library suite
Integrate optional native KUnit suites with out-of-tree SCST modules.
A single CONFIG_SCST_KUNIT_TEST switch includes all test objects of
each owner. Declare each suite name and label once and discover source
registrations for kunit-list without a build or loaded modules.
Preserve ordinary builds without KUnit.

Start with a fixed-wire LUN regression. Centralize private visibility
and task-scoped static-stub switches, and define retained-fixture
reporting for asynchronous tests. Use current native KUnit APIs
without compatibility shims. Keep optional execution messages behind
CONFIG_SCST_KUNIT_LOG while leaving failure diagnostics unconditional.

Add Makefile/Kbuild regression checks and document the shared switch.

Keep compatibility builds free of KUnit, including inherited test
options and allmodconfig. Generate ordinary in-tree SCST patches with
private declarations but without test suites or KUnit build options.
Check this boundary and preserve kernels without an unwinder option.
2026-10-14 15:08:03 +03:00

29 lines
1.2 KiB
Python

# SPDX-License-Identifier: GPL-2.0-only
"""Keep test access declarations out of ordinary SCST compilation."""
from pathlib import Path
import subprocess
import unittest
ROOT = Path(__file__).resolve().parents[2]
class HeaderTests(unittest.TestCase):
def test_normal_headers_do_not_require_kernel_or_test_types(self):
directories = ('scst/src', 'scst/src/dev_handlers', 'iscsi-scst/kernel')
headers = sorted(header for directory in directories
for header in (ROOT / directory).glob('*_test.h'))
self.assertTrue(headers)
source = ''.join(f'#include "{header}"\n' for header in headers)
# Kernel KUnit support alone must not expose SCST test declarations.
for options in ([], ['-DCONFIG_KUNIT=1'], ['-DCONFIG_KUNIT_MODULE=1']):
with self.subTest(options=options):
result = subprocess.run(['cc', '-E', '-P', '-x', 'c', *options, '-'],
input=source, capture_output=True, text=True)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.strip(), '')
if __name__ == '__main__':
unittest.main()