github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/pkg/signal/signal_test.go (about)

     1  package signal // import "github.com/demonoid81/moby/pkg/signal"
     2  
     3  import (
     4  	"syscall"
     5  	"testing"
     6  
     7  	"gotest.tools/v3/assert"
     8  	is "gotest.tools/v3/assert/cmp"
     9  )
    10  
    11  func TestParseSignal(t *testing.T) {
    12  	_, checkAtoiError := ParseSignal("0")
    13  	assert.Check(t, is.Error(checkAtoiError, "Invalid signal: 0"))
    14  
    15  	_, error := ParseSignal("SIG")
    16  	assert.Check(t, is.Error(error, "Invalid signal: SIG"))
    17  
    18  	for sigStr := range SignalMap {
    19  		responseSignal, error := ParseSignal(sigStr)
    20  		assert.Check(t, error)
    21  		signal := SignalMap[sigStr]
    22  		assert.Check(t, is.DeepEqual(signal, responseSignal))
    23  	}
    24  }
    25  
    26  func TestValidSignalForPlatform(t *testing.T) {
    27  	isValidSignal := ValidSignalForPlatform(syscall.Signal(0))
    28  	assert.Check(t, is.Equal(false, isValidSignal))
    29  
    30  	for _, sigN := range SignalMap {
    31  		isValidSignal = ValidSignalForPlatform(sigN)
    32  		assert.Check(t, is.Equal(true, isValidSignal))
    33  	}
    34  }