pkg/eval: Fix test on BSD.

This commit is contained in:
Qi Xiao 2020-03-30 23:48:07 +01:00
parent 4f26803226
commit e098617c28

View File

@ -4,6 +4,7 @@ package eval
import ( import (
"fmt" "fmt"
"runtime"
"syscall" "syscall"
"testing" "testing"
@ -21,6 +22,9 @@ func TestExternalCmdExit_Error(t *testing.T) {
tt.Args(ExternalCmdExit{0x82, "ls", 1}).Rets("ls killed by signal interrupt (core dumped)"), tt.Args(ExternalCmdExit{0x82, "ls", 1}).Rets("ls killed by signal interrupt (core dumped)"),
// 0x7f + signal<<8 for stopped // 0x7f + signal<<8 for stopped
tt.Args(ExternalCmdExit{0x27f, "ls", 1}).Rets("ls stopped by signal interrupt (pid=1)"), tt.Args(ExternalCmdExit{0x27f, "ls", 1}).Rets("ls stopped by signal interrupt (pid=1)"),
})
if runtime.GOOS == "linux" {
tt.Test(t, tt.Fn("Error", error.Error), tt.Table{
// 0x057f + cause<<16 for trapped. SIGTRAP is 5 on all Unix'es but have // 0x057f + cause<<16 for trapped. SIGTRAP is 5 on all Unix'es but have
// different string representations on different OSes. // different string representations on different OSes.
tt.Args(ExternalCmdExit{0x1057f, "ls", 1}).Rets(fmt.Sprintf( tt.Args(ExternalCmdExit{0x1057f, "ls", 1}).Rets(fmt.Sprintf(
@ -28,4 +32,5 @@ func TestExternalCmdExit_Error(t *testing.T) {
// 0xff is the only exit code that is not exited, signaled or stopped. // 0xff is the only exit code that is not exited, signaled or stopped.
tt.Args(ExternalCmdExit{0xff, "ls", 1}).Rets("ls has unknown WaitStatus 255"), tt.Args(ExternalCmdExit{0xff, "ls", 1}).Rets("ls has unknown WaitStatus 255"),
}) })
}
} }