-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathentropychecker_test.go
56 lines (48 loc) · 1014 Bytes
/
entropychecker_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package entropychecker
import (
"testing"
"time"
)
func TestEntropyChecker(t *testing.T) {
err := WaitForEntropy()
if err != nil {
t.Error(err)
return
}
entropy, err := GetEntropy()
if err != nil {
t.Error(err)
return
}
if entropy < MinimumEntropy {
t.Error("Insufficient entropy not properly detected")
return
}
Timeout = 0
err = WaitForEntropy()
if err != nil {
t.Error(err)
return
}
}
func TestFailure(t *testing.T) {
// Make sure we get a an error if we time out
Timeout = 200 * time.Millisecond
MinimumEntropy = 100000
err := WaitForEntropy()
if err == nil {
t.Error("Should get error when timeout waited too long")
}
// Make sure an unspported OS returns an error (instead of unkown behavior)
supportedOS = "unknown"
Timeout = 10 * time.Second
MinimumEntropy = 128
_, err = GetEntropy()
if err == nil {
t.Error("Should get error when using unknown OS")
}
err = WaitForEntropy()
if err == nil {
t.Error("Should get error when using unknown OS")
}
}