(root, mode, inputs)
| 125 | |
| 126 | |
| 127 | def run_case(root, mode, inputs): |
| 128 | case = root / mode |
| 129 | case.mkdir(mode=0o700) |
| 130 | coverage = case / "coverage" |
| 131 | coverage.mkdir(mode=0o700) |
| 132 | suite_dir = coverage / SUITE |
| 133 | result = {"mode": mode, "controls_passed": False} |
| 134 | environment = os.environ.copy() |
| 135 | environment["LLVM_PROFILE_FILE"] = "/dev/null" |
| 136 | environment["CBM_TEST_COVERAGE_DIR"] = str(coverage) |
| 137 | environment["CBM_TEST_ONLY"] = ",".join(SUITE + ":" + test for test in TESTS) |
| 138 | environment.pop("CBM_TEST_ONLY_FILE", None) |
| 139 | argv = [inputs["runner"]["path"]] + ([OPTION] if mode == "emfile" else []) + [SUITE] |
| 140 | try: |
| 141 | process = common.run_process(case, "runner", argv, environment) |
| 142 | result["runner"] = process |
| 143 | if process["failure"] or not process["quiescent"] or process["returncode"] not in (0, 1): |
| 144 | raise common.Infrastructure("runner infrastructure/usage/containment failed") |
| 145 | code = process["returncode"] |
| 146 | stdout = common.read_log(case, process, "stdout") |
| 147 | stderr = common.read_log(case, process, "stderr") |
| 148 | result["summary"] = output_controls(stdout, code) |
| 149 | events = event_controls(stderr, mode, process["pid"]) |
| 150 | result["events"] = events |
| 151 | diagnostics = accounting_controls(stderr, process["pid"]) |
| 152 | result["accounting_diagnostics"] = diagnostics |
| 153 | child_pid = events[0]["child_pid"] |
| 154 | raw = suite_dir / (TESTS[0] + "." + str(child_pid) + ".profraw") |
| 155 | if os.path.lexists(str(raw.with_suffix(".forked"))): |
| 156 | raise common.Infrastructure("final marker receipt differs from actual filesystem") |
| 157 | if code == 0: |
| 158 | for test in TESTS: |
| 159 | if not common.regular_nonempty(suite_dir / (test + ".parent.profraw")): |
| 160 | raise common.Infrastructure("zero-status parent lacks its ordinary genuine profile") |
| 161 | result["profiles"] = common.profile_controls(case, suite_dir, inputs["profdata"]["path"], |
| 162 | environment, {raw.name: FUNCTION}) |
| 163 | result["rows"] = common.reduce_actual(case, SUITE, suite_dir, inputs["profdata"]["path"], |
| 164 | inputs["reducer"]["path"], process, environment) |
| 165 | result["feature_problems"], result["baseline_false_success"] = verdict(mode, code, diagnostics, result["rows"]) |
| 166 | result["controls_passed"] = True |
| 167 | except (common.Infrastructure, OSError, ValueError, KeyboardInterrupt) as exc: |
| 168 | result["infrastructure_error"] = type(exc).__name__ + ": " + str(exc) |
| 169 | finally: |
| 170 | common.save(case / "result.json", result) |
| 171 | return result |
| 172 | |
| 173 | |
| 174 | def main(): |
no test coverage detected