INNER CODE UNIT · Python

test_auto_affinity_option

openHiTLS/openHiTLS · testcode/benchmark/async_perf/test_async_perf.py:105

    def test_auto_affinity_option(self):
        proc = subprocess.run([str(BINARY), "--list", "--pin-cpu", "auto"],
                              text=True, capture_output=True, timeout=10)
        self.assertEqual(proc.returncode, 0, proc.stdout)

    @unittest.skipUnless(hasattr(os, "sched_getaffinity"), "Linux affinity required")
    def test_auto_affinity_insufficient_cores(self):
        cpu = min(os.sched_getaffinity(0))
        with tempfile.TemporaryDirectory(prefix="async-affinity-test-") as directory:
            proc = subprocess.run(
                [str(BINARY), "-a", "hs-sync-tls13-psk", "--device-mode", "worker",
                 "-w", "4", "--pin-cpu", "auto", "--repeat", "1", "--out", directory],
                preexec_fn=lambda: os.sched_setaffinity(0, {cpu}),
                text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=10)
        self.assertNotEqual(proc.returncode, 0, proc.stdout)
        self.assertIn("idle physical cores", proc.stdout)

    @unittest.skipUnless(hasattr(os, "sched_getaffinity"), "Linux affinity required")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…