(self)
| 80 | |
| 81 | class KconfigGraphTest(unittest.TestCase): |
| 82 | def setUp(self) -> None: |
| 83 | self.tmpdir = tempfile.TemporaryDirectory() |
| 84 | self.addCleanup(self.tmpdir.cleanup) |
| 85 | root = Path(self.tmpdir.name) |
| 86 | |
| 87 | # Lay out the fake Buildroot tree so build_report()'s default paths |
| 88 | # resolve. |
| 89 | self.br2_output_dir = root / "br_output" |
| 90 | self.br_ver = "2024.02.10" |
| 91 | srctree = self.br2_output_dir / f"buildroot-{self.br_ver}" |
| 92 | # Synthesised "package/" tree under srctree so the package_of() |
| 93 | # attribution can pull a name from the file path. |
| 94 | pkg_dir = srctree / "package" / "fakepkg" |
| 95 | pkg_dir.mkdir(parents=True) |
| 96 | (pkg_dir / "Config.in").write_text(SYNTH_CONFIG_IN) |
| 97 | (srctree / "Config.in").write_text( |
| 98 | f'source "{pkg_dir / "Config.in"}"\n' |
| 99 | ) |
| 100 | (self.br2_output_dir / ".config").write_text(SYNTH_DOT_CONFIG) |
| 101 | # build_report uses TARGET_DIR only to satisfy its env contract. |
| 102 | (self.br2_output_dir / "target").mkdir() |
| 103 | # openipc_defconfig is referenced by setup_kconfig_env defaults. |
| 104 | (self.br2_output_dir / "openipc_defconfig").write_text("") |
| 105 | |
| 106 | self.images_dir = root / "images" |
| 107 | self.images_dir.mkdir() |
| 108 | |
| 109 | self.env_snapshot = os.environ.copy() |
| 110 | for k in ( |
| 111 | "TARGET_DIR", |
| 112 | "BR2_OUTPUT_DIR", |
| 113 | "IMAGES_DIR", |
| 114 | "OPENIPC_SOC_MODEL", |
| 115 | "OPENIPC_VARIANT", |
| 116 | "BR_VER", |
| 117 | "PWD", |
| 118 | "CONFIG_", |
| 119 | "BR2_SKIP_LEGACY", |
| 120 | "srctree", |
| 121 | "BR2_BASE_DIR", |
| 122 | "BR2_EXTERNAL", |
| 123 | "BR2_EXTERNAL_GENERAL_PATH", |
| 124 | "BR2_EXTERNAL_GENERAL_DESC", |
| 125 | ): |
| 126 | os.environ.pop(k, None) |
| 127 | os.environ["TARGET_DIR"] = str(self.br2_output_dir / "target") |
| 128 | os.environ["BR2_OUTPUT_DIR"] = str(self.br2_output_dir) |
| 129 | os.environ["IMAGES_DIR"] = str(self.images_dir) |
| 130 | os.environ["OPENIPC_SOC_MODEL"] = "testboard" |
| 131 | os.environ["OPENIPC_VARIANT"] = "testvariant" |
| 132 | os.environ["BR_VER"] = self.br_ver |
| 133 | os.environ["PWD"] = str(root) |
| 134 | |
| 135 | def tearDown(self) -> None: |
| 136 | os.environ.clear() |
nothing calls this directly
no outgoing calls
no test coverage detected