From a38eb5c690506df4fd3d61d013487a4639b4d0ac Mon Sep 17 00:00:00 2001 From: Romain Marcadier Date: Mon, 15 Jul 2024 10:49:59 +0200 Subject: [PATCH] Isolate signal test to UNIX only --- _integration-tests/gls/access_test.go | 35 ---------------- _integration-tests/gls/access_unix_test.go | 49 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 35 deletions(-) create mode 100644 _integration-tests/gls/access_unix_test.go diff --git a/_integration-tests/gls/access_test.go b/_integration-tests/gls/access_test.go index 412acde2..d263008a 100644 --- a/_integration-tests/gls/access_test.go +++ b/_integration-tests/gls/access_test.go @@ -6,11 +6,8 @@ package gls import ( - "os" - "os/signal" "runtime" "sync" - "syscall" "testing" "github.com/stretchr/testify/require" @@ -46,38 +43,6 @@ func TestCGO(t *testing.T) { require.Equal(t, expected, get()) } -// TestSignal tests that the GLS is correctly set even when the code comes from a signal handler. -func TestSignal(t *testing.T) { - if !orchestrionEnabled { - t.Skip("Orchestrion is not enabled") - } - - expected := "I am inside a signal handler" - - set(nil) - - doneSigChan := make(chan struct{}, 1) - checkChan := make(chan struct{}, 1) - doneCheckChan := make(chan struct{}, 1) - sigChan := make(chan os.Signal, 1) - signal.Notify(sigChan, syscall.SIGUSR1) - - go func() { - <-sigChan - set(expected) - doneSigChan <- struct{}{} - - <-checkChan - require.Equal(t, expected, get()) - doneCheckChan <- struct{}{} - }() - - syscall.Kill(syscall.Getpid(), syscall.SIGUSR1) - <-doneSigChan - checkChan <- struct{}{} - <-doneCheckChan -} - func TestConcurrency(t *testing.T) { if !orchestrionEnabled { t.Skip("Orchestrion is not enabled") diff --git a/_integration-tests/gls/access_unix_test.go b/_integration-tests/gls/access_unix_test.go new file mode 100644 index 00000000..2cc0054c --- /dev/null +++ b/_integration-tests/gls/access_unix_test.go @@ -0,0 +1,49 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +//go:build unix + +package gls + +import ( + "os" + "os/signal" + "syscall" + "testing" + + "github.com/stretchr/testify/require" +) + +// TestSignal tests that the GLS is correctly set even when the code comes from a signal handler. +func TestSignal(t *testing.T) { + if !orchestrionEnabled { + t.Skip("Orchestrion is not enabled") + } + + expected := "I am inside a signal handler" + + set(nil) + + doneSigChan := make(chan struct{}, 1) + checkChan := make(chan struct{}, 1) + doneCheckChan := make(chan struct{}, 1) + sigChan := make(chan os.Signal, 1) + signal.Notify(sigChan, syscall.SIGUSR1) + + go func() { + <-sigChan + set(expected) + doneSigChan <- struct{}{} + + <-checkChan + require.Equal(t, expected, get()) + doneCheckChan <- struct{}{} + }() + + syscall.Kill(syscall.Getpid(), syscall.SIGUSR1) + <-doneSigChan + checkChan <- struct{}{} + <-doneCheckChan +}