Skip to content

Commit

Permalink
Add observation entries to test and implement one test for each
Browse files Browse the repository at this point in the history
  • Loading branch information
fivosts committed Aug 5, 2022
1 parent fb3138b commit cff3254
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions tests/llvm/observation_spaces_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""Integrations tests for the LLVM CompilerGym environments."""
import os
import sys
from typing import Any, Dict, List
from typing import Any, Dict, List, NamedTuple

import gym
import networkx as nx
Expand Down Expand Up @@ -62,7 +62,8 @@ def test_observation_spaces(env: LlvmEnv):
"IrSha1",
"IsBuildable",
"IsRunnable",
"ObjectTextSizeBytes",
"LexedIr",
"LexedIrTuple" "ObjectTextSizeBytes",
"ObjectTextSizeO0",
"ObjectTextSizeO3",
"ObjectTextSizeOz",
Expand Down Expand Up @@ -410,6 +411,31 @@ def test_autophase_dict_observation_space(env: LlvmEnv):
assert not space.platform_dependent


def test_lexed_ir_observation_space(env: LlvmEnv):
env.reset("cbench-v1/crc32")
key = "LexedIr"
space = env.observation.spaces[key]
assert isinstance(space.space, DictSpace)
value: Dict[str, np.array] = env.observation[key]
print(value) # For debugging in case of error
assert len(value) == 4

assert space.deterministic
assert not space.platform_dependent


def test_lexed_ir_tuple_observation_space(env: LlvmEnv):
env.reset("cbench-v1/crc32")
key = "LexedIrTuple"
space = env.observation.spaces[key]
assert isinstance(space.space, Sequence)
value: List[NamedTuple] = env.observation[key]
print(value) # For debugging in case of error

assert space.deterministic
assert not space.platform_dependent


def test_programl_observation_space(env: LlvmEnv):
env.reset("cbench-v1/crc32")
key = "Programl"
Expand Down

0 comments on commit cff3254

Please sign in to comment.