From 3220b2ddc5968f494088a3a83ba0b69f449abab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20K=C3=A1lm=C3=A1n?= Date: Fri, 3 Nov 2023 10:41:44 +0100 Subject: [PATCH] getAttrInfo race test --- ibmmq/ibmmq_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ibmmq/ibmmq_test.go b/ibmmq/ibmmq_test.go index 7e5f68e..16722e9 100644 --- a/ibmmq/ibmmq_test.go +++ b/ibmmq/ibmmq_test.go @@ -319,3 +319,22 @@ func TestNewMQDLHWithMQMD(t *testing.T) { t.Fail() } } + +func TestGetAttrInfoConcurrentCalls(t *testing.T) { + // NOTE: This test should be run with `go test -race`. + attrs := []int32{ + MQCA_BACKOUT_REQ_Q_NAME, + MQIA_BACKOUT_THRESHOLD, + } + count := 1_000 + doneCh := make(chan struct{}, count) + for i := 0; i < count; i++ { + go func() { + getAttrInfo(attrs) + doneCh <- struct{}{} + }() + } + for i := 0; i < count; i++ { + <-doneCh + } +}