-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patharelo_unix_test.go
34 lines (31 loc) · 1.13 KB
/
arelo_unix_test.go
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
30
31
32
33
34
//go:build !windows
package main
import (
"os"
"syscall"
"testing"
)
func TestParseSignalOption(t *testing.T) {
tests := []struct {
inputs []string
sig os.Signal
out string
}{
{[]string{"1", "HUP", "SIGHUP", "SIG_HUP", "hup", "SigHup"}, syscall.SIGHUP, "SIGHUP"},
{[]string{"2", "INT", "SIGINT", "SIG_INT", "int", "SigInt"}, syscall.SIGINT, "SIGINT"},
{[]string{"3", "QUIT", "SIGQUIT", "SIG_QUIT", "SigQuit"}, syscall.SIGQUIT, "SIGQUIT"},
{[]string{"9", "KILL", "SIGKILL", "SIG_KILL", "SIgKill"}, syscall.SIGKILL, "SIGKILL"},
{[]string{"10", "USR1", "SIGUSR1", "SIG_USR1", "SIgUsr1"}, syscall.SIGUSR1, "SIGUSR1"},
{[]string{"12", "USR2", "SIGUSR2", "SIG_USR2", "SIgUsr2"}, syscall.SIGUSR2, "SIGUSR2"},
{[]string{"15", "TERM", "SIGTERM", "SIG_TERM", "SIgTerm", ""}, syscall.SIGTERM, "SIGTERM"},
{[]string{"28", "WINCH", "SIGWINCH", "SIG_WINCH", "SigWinch"}, syscall.SIGWINCH, "SIGWINCH"},
}
for _, test := range tests {
for _, in := range test.inputs {
s, o := parseSignalOption(in)
if s != test.sig || o != test.out {
t.Fatalf("%q: got %q, %q, wants %q, %q", in, s, o, test.sig, test.out)
}
}
}
}