mirror of
https://github.com/SCST-project/scst.git
synced 2026-10-22 14:12:33 +00:00
Manual review of the allocation path flagged by Coccinelle's null/kmerr.cocci rule found two resource leaks. No separate analyzer diagnostic is recorded for these leaks. Failed SCST target registration frees only sqa_tgt, and normal target release also leaves its command map and tag pool behind. Repeated registration failures or target recreation retain those allocations indefinitely. Move allocation and cleanup into SCST-owned resource helpers. Unwind the command map if tag initialization fails, and destroy both resources if registration fails or the target is released. Preserve the bitmap, percpu_ida and sbitmap backends selected by the existing kernel guards. Target stop phase 1 uses bounded session waits. Before dropping lport callbacks and releasing command storage, wait for the SCST session list to drain. SCST removes each session after its commands and unregistration callback have completed, so late command releases can still return tags. Keep the helpers in scst_qla2xxx.c and link the QLA KUnit suite into qla2x00tgt.ko, following the existing SCST module layout. Expose private helpers only in test builds and use task-scoped registration and allocation stubs. Cover map allocation failure, tag initialization failure, registration failure and normal resource destruction. Build and record the matching qla2xxx_scst.ko dependency for the runner, and clean both module builds together. Extend the build and cleanup fixtures to check this dependency and failure propagation. The dependency has no tests of its own. Requiring every supplied module to have a KUnit manifest made the runner abort before loading any module: Module has no KUnit label manifest; rebuild with kunit-build Accept modules without suites only when they are dependencies of supplied test owners. Keep rejecting missing or malformed test manifests and unrelated modules. Exercise native metadata parsing, label selection, dependency load order and reverse cleanup in isolated runner fixtures. The fixtures need no real target, but loading their owner still initializes the QLogic drivers. Run them in a disposable VM without an HBA; hardware session teardown requires separate integration validation.
30 lines
1.2 KiB
Python
30 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',
|
|
'qla2x00t-32gbit/qla2x00-target')
|
|
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()
|