Skip to content

Commit

Permalink
Add comment regarding the global startup mutex in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardGomezEscandell committed Dec 5, 2023
1 parent a96ddf0 commit ab70575
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions windows-agent/internal/distros/distro/distro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func TestMain(m *testing.M) {
// globalStartupMu protects against multiple distros starting at the same time.
var globalStartupMu sync.Mutex

// startupMutex exists so that all distro tests share the same startup mutex.
// This mutex prevents multiple distros from starting at the same time, which
// could freeze the machine.
//
// When a mock WSL is used, this concern does not exist so we provide a new
// mutex for every test so they can run in parallel without interference.
func startupMutex() *sync.Mutex {
if wsl.MockAvailable() {
// No real distros: use a different mutex every test
Expand Down

0 comments on commit ab70575

Please sign in to comment.