-
Notifications
You must be signed in to change notification settings - Fork 0
/
bdb_test.go
39 lines (36 loc) · 1.02 KB
/
bdb_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
package berkeleydb
import "testing"
import "time"
import "sync"
import "os/exec"
func Test(t *testing.T) {
var wg sync.WaitGroup
db := Open("test-data/test.db")
for i := 0; i < 3; i++ {
go func ()() {
for {
println(db.Get("toto"))
println(db.Get("toyto"))
time.Sleep(100 * time.Millisecond)
}
}()
}
wg.Add(1)
go func ()() {
/* manipulate files */
exec.Command("rm", "-f", "test-data/test.db").Run()
time.Sleep(1100 * time.Millisecond)
exec.Command("cp", "test-data/test_string.db", "test-data/test.db").Run()
time.Sleep(1100 * time.Millisecond)
exec.Command("cp", "test-data/test_string2.db", "test-data/test.db").Run()
time.Sleep(1100 * time.Millisecond)
exec.Command("cp", "test-data/test_string", "test-data/test").Run()
exec.Command("postmap", "test-data/test").Run()
time.Sleep(1100 * time.Millisecond)
exec.Command("cp", "test-data/test_string2", "test-data/test").Run()
exec.Command("postmap", "test-data/test").Run()
time.Sleep(1100 * time.Millisecond)
wg.Done()
} ()
wg.Wait()
}