2023-01-27 13:37:20 -08:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2021-11-01 09:38:42 -07:00
|
|
|
|
|
|
|
package archtest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
"testing"
|
|
|
|
|
2022-01-25 20:06:00 -08:00
|
|
|
"gvisor.dev/gvisor/pkg/atomicbitops"
|
2021-11-01 09:38:42 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// tests netstack's AlignedAtomicInt64.
|
|
|
|
func TestAlignedAtomicInt64(t *testing.T) {
|
|
|
|
type T struct {
|
2022-07-21 16:26:02 -07:00
|
|
|
A atomicbitops.Int64
|
2023-12-20 16:50:30 -06:00
|
|
|
_ int32
|
2022-07-21 16:26:02 -07:00
|
|
|
B atomicbitops.Int64
|
2021-11-01 09:38:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("I am %v/%v\n", runtime.GOOS, runtime.GOARCH)
|
|
|
|
var x T
|
|
|
|
x.A.Store(1)
|
|
|
|
x.B.Store(2)
|
|
|
|
if got, want := x.A.Load(), int64(1); got != want {
|
|
|
|
t.Errorf("A = %v; want %v", got, want)
|
|
|
|
}
|
|
|
|
if got, want := x.B.Load(), int64(2); got != want {
|
|
|
|
t.Errorf("A = %v; want %v", got, want)
|
|
|
|
}
|
|
|
|
}
|