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 <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato 2021-02-03 10:00:45 -08:00
parent f07e1811ef
commit 310e59073c

View File

@ -139,9 +139,9 @@ func TestMain(m *testing.M) {
// pull a seed image // pull a seed image
log.G(ctx).WithField("image", testImage).Info("start to pull seed image") log.G(ctx).WithField("image", testImage).Info("start to pull seed image")
if _, err = client.Pull(ctx, testImage, WithPullUnpack); err != nil { if _, err = client.Pull(ctx, testImage, WithPullUnpack); err != nil {
fmt.Fprintf(os.Stderr, "%s: %s\n", err, buf.String())
ctrd.Kill() ctrd.Kill()
ctrd.Wait() ctrd.Wait()
fmt.Fprintf(os.Stderr, "%s: %s\n", err, buf.String())
os.Exit(1) os.Exit(1)
} }