Skip to content

Commit

Permalink
Console test on z/OS
Browse files Browse the repository at this point in the history
The echo -n switch is not always available on z/OS, so 'echo -n' has
been changed to 'printf' so that the same test pattern can be
reliably produced across platforms.

Same goes for the seq program, so changed the sh loop to a go loop.

Signed-off-by: Neil Johnson <najohnsn@us.ibm.com>
  • Loading branch information
najohnsn committed Apr 9, 2021
1 parent c4672c3 commit 7097449
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions console_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build linux solaris freebsd
// +build linux solaris zos freebsd

/*
Copyright The containerd Authors.
Expand All @@ -20,7 +20,6 @@ package console

import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
Expand Down Expand Up @@ -69,11 +68,6 @@ func TestConsolePty(t *testing.T) {

iteration := 10

cmd := exec.Command("sh", "-c", fmt.Sprintf("for x in `seq 1 %d`; do echo -n test; done", iteration))
cmd.Stdin = slave
cmd.Stdout = slave
cmd.Stderr = slave

var (
b bytes.Buffer
wg sync.WaitGroup
Expand All @@ -84,8 +78,15 @@ func TestConsolePty(t *testing.T) {
wg.Done()
}()

if err := cmd.Run(); err != nil {
t.Fatal(err)
for i := 0; i < iteration; i++ {
cmd := exec.Command("sh", "-c", "printf test")
cmd.Stdin = slave
cmd.Stdout = slave
cmd.Stderr = slave

if err := cmd.Run(); err != nil {
t.Fatal(err)
}
}
slave.Close()
wg.Wait()
Expand Down

0 comments on commit 7097449

Please sign in to comment.