mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-06 20:43:46 +08:00
6d742eb343
Add control trace and platform qualification tools that exercise explicit safety modes and vehicle coverage. Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com> Co-authored-by: Kacper Rączy <gfw.kra@gmail.com> Co-authored-by: YassineYousfi <yyousfi1@binghamton.edu> Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com> Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com> Co-authored-by: prabhaavp <prabhaav@msu.edu>
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
CHECKER = Path(__file__).resolve().parents[3] / 'scripts/lint/check_shebang_format.sh'
|
|
|
|
|
|
class ShebangFormatTest(unittest.TestCase):
|
|
def check(self, content: bytes) -> subprocess.CompletedProcess:
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
script = Path(directory) / 'script with spaces'
|
|
script.write_bytes(content)
|
|
return subprocess.run(['bash', str(CHECKER), str(script)], capture_output=True, text=True)
|
|
|
|
def test_binary_payload_with_embedded_shebang_is_not_a_script(self):
|
|
result = self.check(b'\x7fELF\x00\n#!/usr/bin/python\n')
|
|
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
|
|
|
def test_text_script_format_is_still_enforced(self):
|
|
for language in ('python3', 'bash'):
|
|
with self.subTest(language=language):
|
|
self.assertEqual(self.check(f'#!/usr/bin/env {language}\n'.encode()).returncode, 0)
|
|
self.assertNotEqual(self.check(f'#!/usr/bin/{language}\n'.encode()).returncode, 0)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|