Skip to content

Commit c748bf4

Browse files
committed
transaction: Add test to check that the finalizer work
1 parent 2e94536 commit c748bf4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

transaction_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"os"
77
"os/user"
88
"path/filepath"
9+
"runtime"
910
"testing"
11+
"time"
1012
)
1113

1214
func TestPAM_001(t *testing.T) {
@@ -438,6 +440,19 @@ func TestEnv(t *testing.T) {
438440
}
439441
}
440442

443+
func Test_Finalizer(t *testing.T) {
444+
func() {
445+
_, err := StartFunc("", "", nil)
446+
if err != nil {
447+
t.Fatalf("start #error: %v", err)
448+
}
449+
}()
450+
451+
runtime.GC()
452+
// sleep to switch to finalizer goroutine
453+
time.Sleep(1 * time.Millisecond)
454+
}
455+
441456
func Test_Status(t *testing.T) {
442457
if !CheckPamHasStartConfdir() {
443458
t.Skip("this requires PAM with Conf dir support")

0 commit comments

Comments
 (0)