summaryrefslogtreecommitdiffstats
path: root/jail_test.go
blob: 1967175fbe7920f9ce7c520596b8a4ca0358e684 (plain)
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
package jail

import "testing"

func TestIov(t *testing.T) {
	params := make(map[string]interface{})
	params["name"] = "test"
	params["path"] = "/"

	_, niov, fl := mapToIov(params)

	defer freeIov(fl)

	if niov != 4 {
		t.Error("mapToIov return wrong number of pairs ", niov)
	}
}

func TestRemove(t *testing.T) {
	params := make(map[string]interface{})
	params["name"] = "test_remove"
	params["path"] = "/"
	params["persist"] = true

	jid, err := Set(params, JAIL_CREATE)
	if err != nil {
		t.Error("Failed to create jail: ", err.Error())
	}

	err = Remove(jid)
	if err != nil {
		t.Error("Failed to remove jail: ", err.Error())
	}
}

func TestCreate(t *testing.T) {
	params := make(map[string]interface{})
	params["name"] = "test_create"
	params["path"] = "/"

	_, err := Set(params, JAIL_CREATE | JAIL_ATTACH)
	if err != nil {
		t.Error("Failed to create jail: ", err.Error())
	}
}