trex-emu icon indicating copy to clipboard operation
trex-emu copied to clipboard

Make testsuite `emu/plugins/tdl` pass on Go 1.20+

Open bjosv opened this issue 1 year ago • 4 comments

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

bjosv avatar Jan 22 '24 23:01 bjosv

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.

bdollma-te avatar Jan 23 '24 08:01 bdollma-te

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.

bjosv avatar Jan 23 '24 08:01 bjosv

I see that you changed organisation and user @bdollma-te, are you still a maintainer for trex-emu?

bjosv avatar Jan 24 '24 10:01 bjosv

Yes yes same person, simply multiple accounts and I commented with the other one. @hhaim will probably merge this when he is available.

bdollma avatar Jan 24 '24 12:01 bdollma