Skip to content

Commit

Permalink
Fix race condition in test
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Koch <[email protected]>
  • Loading branch information
hugelgupf committed Jan 19, 2024
1 parent 85a5a44 commit 236c0bf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/mkuimage/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func TestUrootCmdline(t *testing.T) {
sum1, sum2 []byte
errs [2]error
wg = &sync.WaitGroup{}
removeMu sync.Mutex
remove []string
)

Expand All @@ -243,7 +244,9 @@ func TestUrootCmdline(t *testing.T) {
return
}

removeMu.Lock()
remove = append(remove, f1.Name())
removeMu.Unlock()
for _, v := range tt.validators {
if err := v.Validate(a); err != nil {
t.Errorf("validator failed: %v / archive:\n%s", err, a)
Expand All @@ -259,7 +262,9 @@ func TestUrootCmdline(t *testing.T) {
errs[1] = err
return
}
removeMu.Lock()
remove = append(remove, f2.Name())
removeMu.Unlock()
}()

wg.Wait()
Expand Down

0 comments on commit 236c0bf

Please sign in to comment.