File
Blob: scripts/test_http.py
| 1 | """Exercise the maintained native HTTP adapter with public synthetic responses.""" |
| 2 | from pathlib import Path |
| 3 | import shutil |
| 4 | import subprocess |
| 5 | import tempfile |
| 6 | import unittest |
| 7 | |
| 8 | ROOT = Path(__file__).resolve().parents[1] |
| 9 | |
| 10 | |
| 11 | class HttpTests(unittest.TestCase): |
| 12 | def test_response_borrow_bounds_and_retry_state(self): |
| 13 | compiler = shutil.which("cc") |
| 14 | self.assertIsNotNone(compiler, "A host C compiler is required for native adapter tests") |
| 15 | platform = ROOT / "firmware/platform" |
| 16 | fixtures = platform / "tests/http" |
| 17 | with tempfile.TemporaryDirectory() as directory: |
| 18 | executable = Path(directory) / "http-test" |
| 19 | compiled = subprocess.run( |
| 20 | [ |
| 21 | compiler, "-std=c11", "-Wall", "-Wextra", "-Werror", |
| 22 | "-I", str(fixtures), "-I", str(platform / "include"), |
| 23 | str(platform / "http.c"), str(fixtures / "http_test.c"), |
| 24 | "-o", str(executable), |
| 25 | ], |
| 26 | capture_output=True, text=True, |
| 27 | ) |
| 28 | self.assertEqual(compiled.returncode, 0, compiled.stdout + compiled.stderr) |
| 29 | result = subprocess.run([str(executable)], capture_output=True, text=True) |
| 30 | self.assertEqual(result.returncode, 0, result.stdout + result.stderr) |
| 31 | |
| 32 | |
| 33 | if __name__ == "__main__": |
| 34 | unittest.main() |