aboutsummaryrefslogtreecommitdiff
path: root/pkg/util/utils_linux_test.go
blob: 38e6dbef94856318d6a0918288e4b6c88e39ece7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package util

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestGetImageConfigStopSignal(t *testing.T) {
	// Linux-only beause parsing signal names is not supported on non-Linux systems by
	// pkg/signal.
	stopSignalValidInt, err := GetImageConfig([]string{"STOPSIGNAL 9"})
	require.Nil(t, err)
	assert.Equal(t, stopSignalValidInt.StopSignal, "9")

	stopSignalValidString, err := GetImageConfig([]string{"STOPSIGNAL SIGKILL"})
	require.Nil(t, err)
	assert.Equal(t, stopSignalValidString.StopSignal, "9")

	_, err = GetImageConfig([]string{"STOPSIGNAL 0"})
	assert.NotNil(t, err)

	_, err = GetImageConfig([]string{"STOPSIGNAL garbage"})
	assert.NotNil(t, err)

	_, err = GetImageConfig([]string{"STOPSIGNAL "})
	assert.NotNil(t, err)
}