"""Regression guard for ``gpgpu-sim/setup.sh`` clone-source policy. The script must default to the upstream URL and use a local mirror only via the explicit ``GPGPUSIM_CLONE_SOURCE`` environment variable; no personal host path may be hardcoded. These checks are static (plus ``bash -n``/``--help``) so they need neither a network nor a GPGPU-Sim checkout. """ import os import subprocess import sys import unittest sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) TOOL_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SETUP = os.path.join(TOOL_ROOT, "gpgpu-sim", "setup.sh") PIN = "90ec3399763d7c8512cfe7dc193473086c38ca38" UPSTREAM_URL = "https://github.com/gpgpu-sim/gpgpu-sim_distribution.git" class SetupShTests(unittest.TestCase): def test_clone_source_policy(self): with open(SETUP, "r", encoding="utf-8") as fh: text = fh.read() self.assertNotIn("LOCAL_SRC=", text) self.assertNotIn("/home/rmcore", text) self.assertIn("GPGPUSIM_CLONE_SOURCE", text) self.assertIn(UPSTREAM_URL, text) self.assertIn(PIN, text) # pin enforcement stays in the script def test_script_syntax_and_help(self): result = subprocess.run(["bash", "-n", SETUP], capture_output=True, text=True) self.assertEqual(result.returncode, 0, result.stderr) result = subprocess.run(["bash", SETUP, "--help"], capture_output=True, text=True) self.assertEqual(result.returncode, 0, result.stderr) self.assertIn("GPGPUSIM_CLONE_SOURCE", result.stdout) self.assertIn("upstream URL", result.stdout) if __name__ == "__main__": unittest.main()