def test_no_validation_callback_for_custom_benchmark(env: LlvmEnv): """Test that a custom benchmark has no validation callback.""" with tempfile.TemporaryDirectory() as d: p = Path(d) / "example.c" with open(p, "w") as f: print("int main() {return 0;}", file=f) benchmark = env.make_benchmark(p) env.reset(benchmark=benchmark) assert not env.benchmark.is_validatable()
def test_fork_custom_benchmark(env: LlvmEnv): benchmark = env.make_benchmark(EXAMPLE_BITCODE_FILE) env.reset(benchmark=benchmark) def ir(env): """Strip the ModuleID line from IR.""" return "\n".join(env.ir.split("\n")[1:]) with env.fork() as fkd: assert ir(env) == ir(fkd) fkd.reset() assert ir(env) == ir(fkd)
def test_failing_build_cmd(env: LlvmEnv, tmpdir): """Test that reset() raises an error if build command fails.""" (Path(tmpdir) / "program.c").touch() benchmark = env.make_benchmark(Path(tmpdir) / "program.c") benchmark.proto.dynamic_config.build_cmd.argument.extend( ["$CC", "$IN", "-invalid-cc-argument"]) benchmark.proto.dynamic_config.build_cmd.timeout_seconds = 10 with pytest.raises( BenchmarkInitError, match=r"clang: error: unknown argument: '-invalid-cc-argument'", ): env.reset(benchmark=benchmark)
def test_fork_custom_benchmark(env: LlvmEnv): benchmark = env.make_benchmark(EXAMPLE_BITCODE_FILE) env.reset(benchmark=benchmark) def ir(env): """Strip the ModuleID line from IR.""" return "\n".join(env.ir.split("\n")[1:]) try: new_env = env.fork() assert ir(env) == ir(new_env) new_env.reset() assert ir(env) == ir(new_env) finally: new_env.close()