Log random seed for llvm-stress test.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Fuzz test LLVM backend using llvm-stress."""
+import random
import subprocess
from compiler_gym.envs import LlvmEnv
@@ -23,8 +24,9 @@ def test_fuzz(env: LlvmEnv, observation_space: str, reward_space: str):
"""This test produces a random trajectory using a program generated using
llvm-stress.
"""
- llvm_ir = subprocess.check_output([str(LLVM_STRESS)])
- print(llvm_ir.decode("utf-8"))
+ seed = random.randint(0, 2 << 31)
+ llvm_ir = subprocess.check_output([str(LLVM_STRESS), f"--seed={seed}"])
+ print(f"llvm-stress --seed={seed}") # For debugging in case of failure.
env.benchamrk = Benchmark(uri="stress", program=File(contents=llvm_ir))
env.observation_space = observation_space
