2018-02-05 16:05:59 -05:00
|
|
|
package signal // import "github.com/docker/docker/pkg/signal"
|
2017-05-31 12:40:41 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
"testing"
|
|
|
|
|
2018-03-13 15:28:34 -04:00
|
|
|
"github.com/gotestyourself/gotestyourself/assert"
|
|
|
|
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
2017-05-31 12:40:41 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseSignal(t *testing.T) {
|
|
|
|
_, checkAtoiError := ParseSignal("0")
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, is.Error(checkAtoiError, "Invalid signal: 0"))
|
2017-05-31 12:40:41 -04:00
|
|
|
|
|
|
|
_, error := ParseSignal("SIG")
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, is.Error(error, "Invalid signal: SIG"))
|
2017-05-31 12:40:41 -04:00
|
|
|
|
|
|
|
for sigStr := range SignalMap {
|
|
|
|
responseSignal, error := ParseSignal(sigStr)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, error)
|
2017-05-31 12:40:41 -04:00
|
|
|
signal := SignalMap[sigStr]
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, is.DeepEqual(signal, responseSignal))
|
2017-05-31 12:40:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestValidSignalForPlatform(t *testing.T) {
|
|
|
|
isValidSignal := ValidSignalForPlatform(syscall.Signal(0))
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, is.Equal(false, isValidSignal))
|
2017-05-31 12:40:41 -04:00
|
|
|
|
|
|
|
for _, sigN := range SignalMap {
|
|
|
|
isValidSignal = ValidSignalForPlatform(syscall.Signal(sigN))
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, is.Equal(true, isValidSignal))
|
2017-05-31 12:40:41 -04:00
|
|
|
}
|
|
|
|
}
|