diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-06-29 11:46:16 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-06-29 11:46:16 +0200 |
| commit | ac5f183dc06d92746de65883b4e06677dfbfd812 (patch) | |
| tree | 3c85217a4eb04b8f6aadfe8abc882ec9a935f25e /pkg/ipc | |
| parent | 346edcb763a5aa4b82dd5ec59e214a801897c586 (diff) | |
pkg/ipc: fix cleanup in test
Currently we first send on errs and then close env.
As the result process can exit before env.Close finishes,
which will leave garbage behind.
Close env before sending on errs.
Diffstat (limited to 'pkg/ipc')
| -rw-r--r-- | pkg/ipc/ipc_test.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/pkg/ipc/ipc_test.go b/pkg/ipc/ipc_test.go index e8783ccef..cebf587d9 100644 --- a/pkg/ipc/ipc_test.go +++ b/pkg/ipc/ipc_test.go @@ -114,35 +114,37 @@ func TestParallel(t *testing.T) { errs <- fmt.Errorf("failed to create env: %v", err) return } - defer env.Close() + defer func() { + env.Close() + errs <- err + }() p := target.GenerateSimpleProg() opts := &ExecOpts{} output, info, failed, hanged, err := env.Exec(opts, p) if err != nil { - errs <- fmt.Errorf("failed to run executor: %v", err) + err = fmt.Errorf("failed to run executor: %v", err) return } if hanged { - errs <- fmt.Errorf("program hanged:\n%s", output) + err = fmt.Errorf("program hanged:\n%s", output) return } if failed { - errs <- fmt.Errorf("program failed:\n%s", output) + err = fmt.Errorf("program failed:\n%s", output) return } if len(info) == 0 { - errs <- fmt.Errorf("no calls executed:\n%s", output) + err = fmt.Errorf("no calls executed:\n%s", output) return } if info[0].Errno != 0 { - errs <- fmt.Errorf("simple call failed: %v\n%s", info[0].Errno, output) + err = fmt.Errorf("simple call failed: %v\n%s", info[0].Errno, output) return } if len(output) != 0 { - errs <- fmt.Errorf("output on empty program") + err = fmt.Errorf("output on empty program") return } - errs <- nil }() } for p := 0; p < P; p++ { |
