aboutsummaryrefslogtreecommitdiff
path: root/pkg/signal/signal_common_test.go
diff options
context:
space:
mode:
authorBoaz Shuster <boaz.shuster.github@gmail.com>2022-09-20 12:11:39 +0300
committerBoaz Shuster <boaz.shuster.github@gmail.com>2022-09-20 22:52:45 +0300
commit7cfe0328f1c231ed318c38938479f7dec7fc97fa (patch)
tree8b0bfcfe8fbc9e7af30cfcb84b567293b03f40f6 /pkg/signal/signal_common_test.go
parent30231d0da7e6dcf3d6d1f45b10150baae35aaf28 (diff)
downloadpodman-7cfe0328f1c231ed318c38938479f7dec7fc97fa.tar.gz
podman-7cfe0328f1c231ed318c38938479f7dec7fc97fa.tar.bz2
podman-7cfe0328f1c231ed318c38938479f7dec7fc97fa.zip
Add support to sig-proxy for podman-remote
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
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)
+ }
+ })
+ }
+}