Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make testsuite emu/plugins/tdl pass on Go 1.20+ #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bjosv
Copy link

@bjosv bjosv commented Jan 22, 2024

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

@bdollma-te
Copy link

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.

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" op 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,
as previously done by Go itself, we get the same result in all Go version.

- Testcase
  "params":
  {
    "size": 6,
    "offset": 0,
    "op": "rand",
    "list": ["TRex", "Cisco", "Golang"]
  }

- Go doc:
  https://pkg.go.dev/math/rand@master#Seed

Signed-off-by: Björn Svensson <[email protected]>
@bjosv
Copy link
Author

bjosv commented Jan 23, 2024

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
Copy link
Author

bjosv commented Jan 24, 2024

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

@bdollma
Copy link
Contributor

bdollma commented Jan 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants