trex-emu
trex-emu copied to clipboard
Make testsuite `emu/plugins/tdl` pass on Go 1.20+
Prior to Go 1.20 the pseudo-random number generator was seeded like Seed(1) at program startup, but in later releases the generator is seeded randomly.
Since the testcase typeDef1
uses the rand
operation the testcase output does not always match the expected file:
unit-test/exp/typeDef1.json
.
This is due to the different random order in Go 1.20+.
By setting seed=1 via its TdlTestBase
, as previously done by Go itself, we get the same result in all Go version.
References:
Testcase: "params": { "size": 6, "offset": 0, "op": "rand", "list": ["TRex", "Cisco", "Golang"] }
Go doc: https://pkg.go.dev/math/rand@master#Seed
I thought newer versions of Go weren't supposed to break existing code due to the backward compatibility promise. Well... I don't see any problems with your change.
I thought newer versions of Go weren't supposed to break existing code due to the backward compatibility promise. Well... I don't see any problems with your change.
Yes, me too. I had to dig deep to find the reason as well.. I updated the commit message with a sign-off now as according to instructions .. sorry missed that.
I see that you changed organisation and user @bdollma-te, are you still a maintainer for trex-emu?
Yes yes same person, simply multiple accounts and I commented with the other one. @hhaim will probably merge this when he is available.