summaryrefslogtreecommitdiffstats
path: root/jail_test.go
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2019-02-26 01:56:30 +0100
committerMarius Halden <marius.h@lden.org>2019-02-26 01:56:30 +0100
commitca0043ccc98a575daade3197b22e321a7d3ad945 (patch)
treef18e91852081a7daea3a3f3de28e4675fb2b444b /jail_test.go
downloadgojail-ca0043ccc98a575daade3197b22e321a7d3ad945.tar.gz
gojail-ca0043ccc98a575daade3197b22e321a7d3ad945.tar.bz2
gojail-ca0043ccc98a575daade3197b22e321a7d3ad945.tar.xz
Initial
Diffstat (limited to 'jail_test.go')
-rw-r--r--jail_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/jail_test.go b/jail_test.go
new file mode 100644
index 0000000..1967175
--- /dev/null
+++ b/jail_test.go
@@ -0,0 +1,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())
+ }
+}