From 310e59073c3f02737bec1cbc11b6a96fbe01b02e Mon Sep 17 00:00:00 2001 From: Kazuyoshi Kato Date: Wed, 3 Feb 2021 10:00:45 -0800 Subject: [PATCH] test: stop containerd before accessing the stdout The variable `buf` is connected to containerd's stdout. So, accessing the variable before killing containerd can cause a race condition. Signed-off-by: Kazuyoshi Kato --- client_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client_test.go b/client_test.go index 3cc726120..f8ded57f4 100644 --- a/client_test.go +++ b/client_test.go @@ -139,9 +139,9 @@ func TestMain(m *testing.M) { // pull a seed image log.G(ctx).WithField("image", testImage).Info("start to pull seed image") if _, err = client.Pull(ctx, testImage, WithPullUnpack); err != nil { - fmt.Fprintf(os.Stderr, "%s: %s\n", err, buf.String()) ctrd.Kill() ctrd.Wait() + fmt.Fprintf(os.Stderr, "%s: %s\n", err, buf.String()) os.Exit(1) }