-
Notifications
You must be signed in to change notification settings - Fork 14
/
log_test.go
36 lines (27 loc) · 920 Bytes
/
log_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
35
36
package cryptsetup
import (
"testing"
)
func Test_Log(test *testing.T) {
testWrapper := TestWrapper{test}
messages := make([]string, 0)
levels := make([]int, 0)
SetDebugLevel(CRYPT_DEBUG_ALL)
SetLogCallback(func(level int, message string) {
levels = append(levels, level)
messages = append(messages, message)
})
device, err := Init(DevicePath)
testWrapper.AssertNoError(err)
for i := 0; i < 3; i++ {
levelsPreviousLength, messagesPreviousLength := len(levels), len(messages)
err = device.Deactivate(DevicePath)
testWrapper.AssertError(err)
if levelsPreviousLength >= len(levels) {
test.Errorf("'levels' should have increased its length. Previous: %d Current: %d", levelsPreviousLength, len(levels))
}
if messagesPreviousLength >= len(messages) {
test.Errorf("'messages' should have increased its length. Previous: %d Current: %d", messagesPreviousLength, len(messages))
}
}
}