test: use typed atomics in test files (#25071)

Use typed atomics (atomic.Int64, atomic.Int32, etc.) in test files to prevent
mixing atomic and non-atomic access on the same value, guarantee 64-bit
alignment on 32-bit platforms, and provide a cleaner API.
This commit is contained in:
Zach
2026-05-11 08:41:17 -06:00
committed by GitHub
parent a1dbd758bc
commit 81e2be69e9
21 changed files with 115 additions and 116 deletions
+3 -3
View File
@@ -118,10 +118,10 @@ func TestGitSSH(t *testing.T) {
setupCtx := testutil.Context(t, testutil.WaitLong)
client, token, pubkey := prepareTestGitSSH(setupCtx, t)
var inc int64
var inc atomic.Int64
errC := make(chan error, 1)
addr := serveSSHForGitSSH(t, func(s ssh.Session) {
atomic.AddInt64(&inc, 1)
inc.Add(1)
t.Log("got authenticated session")
select {
case errC <- s.Exit(0):
@@ -146,7 +146,7 @@ func TestGitSSH(t *testing.T) {
ctx := testutil.Context(t, testutil.WaitSuperLong)
err := inv.WithContext(ctx).Run()
require.NoError(t, err)
require.EqualValues(t, 1, inc)
require.EqualValues(t, 1, inc.Load())
err = <-errC
require.NoError(t, err, "error in agent execute")