1717package libaudit
1818
1919import (
20+ "encoding/base64"
2021 "encoding/hex"
2122 "flag"
2223 "fmt"
@@ -26,8 +27,7 @@ import (
2627 "testing"
2728 "time"
2829
29- "encoding/base64"
30-
30+ "github.com/pkg/errors"
3131 "github.com/stretchr/testify/assert"
3232)
3333
@@ -483,12 +483,13 @@ func TestAuditClientReceive(t *testing.T) {
483483 // Depending on the kernel version, it will reply with an AUDIT_REPLACE (1329)
484484 // message, followed by an AUDIT_CONFIG_CHANGE (1305) message, followed
485485 // by an ACK. Older kernels seem to not send the AUDIT_CONFIG_CHANGE message.
486- err = client .SetPID (NoWait )
487- if err != nil {
486+ if err = client .SetPID (WaitForReply ); err == nil {
488487 t .Fatal ("set pid failed:" , err )
488+ } else if errors .Cause (err ) != syscall .EEXIST {
489+ t .Fatal ("expected second SetPID call to result in EEXISTS but got" , err )
489490 }
490491
491- // Expect at least 2 messages caused by our previous call.
492+ // Expect at least 1 message caused by our previous call (CONFIG_CHANGE) .
492493 var msgCount int
493494 for i := 0 ; i < 10 ; i ++ {
494495 msg , err := client .Receive (true )
@@ -502,7 +503,7 @@ func TestAuditClientReceive(t *testing.T) {
502503 msgCount ++
503504 }
504505 }
505- assert .True (t , msgCount >= 2 , "expected at least two messages" )
506+ assert .True (t , msgCount >= 1 , "expected at least one messages" )
506507}
507508
508509func TestAuditStatusMask (t * testing.T ) {
0 commit comments