示例#1
0
def test_benchmark_constructor_arg(env: LlvmEnv):
    env.close()  # Fixture only required to pull in dataset.

    with gym.make("llvm-v0", benchmark="cbench-v1/dijkstra") as env:
        assert env.benchmark == "benchmark://cbench-v1/dijkstra"
        env.reset()
        assert env.benchmark == "benchmark://cbench-v1/dijkstra"
示例#2
0
def test_wrapped_env_custom_close(env: LlvmEnv):
    """Test that a custom close() method is called on wrapped environments."""
    class MyWrapper(CompilerEnvWrapper):
        def __init__(self, env: LlvmEnv):
            super().__init__(env)
            self.custom_close = False

        def close(self):
            self.custom_close = True
            self.env.close()

    env = MyWrapper(env)
    assert not env.custom_close

    env.close()
    assert env.custom_close
示例#3
0
def test_Counter_double_close(env: LlvmEnv):
    with Counter(env) as env:
        env.close()
        env.close()
        assert env.counters == {
            "close": 2,
            "fork": 0,
            "reset": 0,
            "step": 0,
        }

    # Implicit close in `with` statement.
    assert env.counters == {
        "close": 3,
        "fork": 0,
        "reset": 0,
        "step": 0,
    }
示例#4
0
def test_wrapped_close(env: LlvmEnv, wrapper_type):
    env = wrapper_type(env)
    env.close()
    assert env.service is None
def test_wrapped_close(env: LlvmEnv):
    env = TimeLimit(env, max_episode_steps=5)
    env.close()
    assert env.service is None
示例#6
0
def test_ForkOnStep_double_close(env: LlvmEnv):
    with ForkOnStep(env) as env:
        env.close()
        env.close()