mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
fix: Suppress non-PMG error from Critical UI Error (#311)
* fix: Suppress non-PMG error from Critical UI Error * fix: Code review fixes --------- Co-authored-by: Sahil Bansal <bansalsahil315@gmail.com>
This commit is contained in:
co-authored by
Sahil Bansal
parent
db1a5e58b3
commit
5018f8e2ff
@@ -0,0 +1,58 @@
|
||||
//go:build !windows
|
||||
|
||||
package proc
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestSignalInfo(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
sys any
|
||||
wantSignum int
|
||||
wantSignaled bool
|
||||
}{
|
||||
{
|
||||
name: "SIGINT terminated process",
|
||||
sys: syscall.WaitStatus(int(syscall.SIGINT)),
|
||||
wantSignum: int(syscall.SIGINT),
|
||||
wantSignaled: true,
|
||||
},
|
||||
{
|
||||
name: "SIGTERM terminated process",
|
||||
sys: syscall.WaitStatus(int(syscall.SIGTERM)),
|
||||
wantSignum: int(syscall.SIGTERM),
|
||||
wantSignaled: true,
|
||||
},
|
||||
{
|
||||
name: "normal exit code 2 is not signaled",
|
||||
sys: syscall.WaitStatus(2 << 8),
|
||||
wantSignum: 0,
|
||||
wantSignaled: false,
|
||||
},
|
||||
{
|
||||
name: "nil status is not signaled",
|
||||
sys: nil,
|
||||
wantSignum: 0,
|
||||
wantSignaled: false,
|
||||
},
|
||||
{
|
||||
name: "non-WaitStatus value is not signaled",
|
||||
sys: "not a wait status",
|
||||
wantSignum: 0,
|
||||
wantSignaled: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
signum, signaled := SignalInfo(tt.sys)
|
||||
assert.Equal(t, tt.wantSignaled, signaled)
|
||||
assert.Equal(t, tt.wantSignum, signum)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user