riscv-software-src / riscv-ctg

BSD 3-Clause "New" or "Revised" License
40 stars 52 forks source link

Randomised tests are not reproducible #115

Open Timmmm opened 4 months ago

Timmmm commented 4 months ago

With the -r / --randomize flag, riscv-ctg uses python-constraint's MinConflictsSolver. This is not reproducible. It seems like this was noticed at least:

A obvious down-side of using random solvers is the fact that the same test cannot be reproduced again. However, the typical intent of users of CTG would be to generates tests satisfying the cover-points defined in the CGF. Since that is guaranteed by CTG, the reproducibility issue can be set aside.

I guess this was really set aside because unfortunately MinConflictsSolver uses global random and doesn't let you provide a seed. This can be easily worked around by seeding the global random before solving, or by copying & fixing MinConflictsSolver. But I think I will just fix it in that project.

I also noticed some other uses of the global random in riscv-ctg which should not be there: several uses of random.choice in cross_comb.py.

Timmmm commented 4 months ago

See https://github.com/python-constraint/python-constraint/pull/81