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"
|
|
|
|
|
2020-02-07 08:39:24 -05:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
is "gotest.tools/v3/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 {
|
2019-08-06 13:59:23 -04:00
|
|
|
isValidSignal = ValidSignalForPlatform(sigN)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, is.Equal(true, isValidSignal))
|
2017-05-31 12:40:41 -04:00
|
|
|
}
|
|
|
|
}
|