aboutsummaryrefslogtreecommitdiff
path: root/pkg/signal/signal_common_test.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-09-22 17:06:45 +0200
committerGitHub <noreply@github.com>2022-09-22 17:06:45 +0200
commit8bf3535447fe9f482b329e962e173ade26456e6d (patch)
tree39375c55d8bda145631c4d739fdf3013945b8ad1 /pkg/signal/signal_common_test.go
parent828fae12971c5a7b9807c8c4f8e029fe5d0ddc2f (diff)
parent7cfe0328f1c231ed318c38938479f7dec7fc97fa (diff)
downloadpodman-8bf3535447fe9f482b329e962e173ade26456e6d.tar.gz
podman-8bf3535447fe9f482b329e962e173ade26456e6d.tar.bz2
podman-8bf3535447fe9f482b329e962e173ade26456e6d.zip
Merge pull request #15131 from boaz0/closes_14707
Add support to sig-proxy for podman-remote
Diffstat (limited to 'pkg/signal/signal_common_test.go')
-rw-r--r--pkg/signal/signal_common_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/pkg/signal/signal_common_test.go b/pkg/signal/signal_common_test.go
index c4ae6b389..bd9b230f7 100644
--- a/pkg/signal/signal_common_test.go
+++ b/pkg/signal/signal_common_test.go
@@ -118,3 +118,52 @@ func TestParseSignalNameOrNumber(t *testing.T) {
})
}
}
+
+func TestParseSysSignalToName(t *testing.T) {
+ type args struct {
+ signal syscall.Signal
+ }
+ tests := []struct {
+ name string
+ args args
+ want string
+ wantErr bool
+ }{
+ {
+ name: "Kill should work",
+ args: args{
+ signal: syscall.SIGKILL,
+ },
+ want: "KILL",
+ wantErr: false,
+ },
+ {
+ name: "Non-defined signal number should not work",
+ args: args{
+ signal: 923,
+ },
+ want: "",
+ wantErr: true,
+ },
+ {
+ name: "garbage should fail",
+ args: args{
+ signal: -1,
+ },
+ want: "",
+ wantErr: true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ got, err := ParseSysSignalToName(tt.args.signal)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("ParseSysSignalToName() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if got != tt.want {
+ t.Errorf("ParseSysSignalToName() got = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}