From ac5f183dc06d92746de65883b4e06677dfbfd812 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 29 Jun 2018 11:46:16 +0200 Subject: 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. --- pkg/ipc/ipc_test.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'pkg/ipc') 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++ { -- cgit mrf-deployment