aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorelly <elly@leptoquark.net>2013-07-08 10:21:15 -0400
committerelly <elly@leptoquark.net>2013-07-08 10:21:15 -0400
commit234454e5faadda2094e7e454563bcd538984b403 (patch)
treec16b9749c101b8a9c157f31fe5decae6df6b2210 /tests
parentce042c6f3e561ddef111119692c0307380ac886b (diff)
downloadtlsdate-234454e5faadda2094e7e454563bcd538984b403.tar.gz
Add integration testing.
These new integration tests mostly focus on tlsdated's subprocess code. Signed-off-by: Elly Fong-Jones <elly@leptoquark.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/README1
-rw-r--r--tests/common.sh32
-rw-r--r--tests/run-idle/input0
-rw-r--r--tests/run-idle/output1
-rw-r--r--tests/run-idle/runs1
-rwxr-xr-xtests/run-idle/setup4
-rwxr-xr-xtests/run-idle/subproc.sh6
-rw-r--r--tests/run-idle/teardown4
-rw-r--r--tests/run-idle/test.conf2
-rw-r--r--tests/run-once/input0
-rw-r--r--tests/run-once/output1
-rw-r--r--tests/run-once/run-error1
-rwxr-xr-xtests/run-once/subproc.sh5
-rw-r--r--tests/run-routeup/input1
-rw-r--r--tests/run-routeup/output1
-rw-r--r--tests/run-routeup/runs1
-rwxr-xr-xtests/run-routeup/setup4
-rwxr-xr-xtests/run-routeup/subproc.sh6
-rw-r--r--tests/run-routeup/teardown4
-rw-r--r--tests/subproc-retry/input1
-rw-r--r--tests/subproc-retry/output3
-rw-r--r--tests/subproc-retry/runs1
-rwxr-xr-xtests/subproc-retry/setup4
-rwxr-xr-xtests/subproc-retry/subproc.sh10
-rw-r--r--tests/subproc-retry/teardown4
-rw-r--r--tests/wait-idle/input0
-rw-r--r--tests/wait-idle/output0
-rw-r--r--tests/wait-idle/subproc.sh7
28 files changed, 105 insertions, 0 deletions
diff --git a/tests/README b/tests/README
new file mode 100644
index 0000000..e0c0e00
--- /dev/null
+++ b/tests/README
@@ -0,0 +1 @@
+Integration tests for tlsdate/tlsdated.
diff --git a/tests/common.sh b/tests/common.sh
new file mode 100644
index 0000000..96ba238
--- /dev/null
+++ b/tests/common.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+kill_tlsdated() {
+ kill -9 $PPID
+}
+
+passed() {
+ kill_tlsdated
+ echo "ok"
+}
+
+failed() {
+ kill_tlsdated
+ echo "failed"
+}
+
+mydir() {
+ echo "$(dirname "$0")"
+}
+
+counter() {
+ cat "$(mydir)"/"$1"
+}
+
+inc_counter() {
+ c=$(counter "$1")
+ echo $((c + 1)) >"$(mydir)"/"$1"
+}
+
+reset_counter() {
+ echo 0 > "$(mydir)"/"$1"
+}
diff --git a/tests/run-idle/input b/tests/run-idle/input
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/run-idle/input
diff --git a/tests/run-idle/output b/tests/run-idle/output
new file mode 100644
index 0000000..9766475
--- /dev/null
+++ b/tests/run-idle/output
@@ -0,0 +1 @@
+ok
diff --git a/tests/run-idle/runs b/tests/run-idle/runs
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/tests/run-idle/runs
@@ -0,0 +1 @@
+2
diff --git a/tests/run-idle/setup b/tests/run-idle/setup
new file mode 100755
index 0000000..c4afd68
--- /dev/null
+++ b/tests/run-idle/setup
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")"/../common.sh
+
+reset_counter "runs"
diff --git a/tests/run-idle/subproc.sh b/tests/run-idle/subproc.sh
new file mode 100755
index 0000000..649a18e
--- /dev/null
+++ b/tests/run-idle/subproc.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+. "$(dirname $0)"/../common.sh
+
+inc_counter "runs"
+c=$(counter "runs")
+[ $c -eq 2 ] && passed
diff --git a/tests/run-idle/teardown b/tests/run-idle/teardown
new file mode 100644
index 0000000..c4afd68
--- /dev/null
+++ b/tests/run-idle/teardown
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")"/../common.sh
+
+reset_counter "runs"
diff --git a/tests/run-idle/test.conf b/tests/run-idle/test.conf
new file mode 100644
index 0000000..713e8f7
--- /dev/null
+++ b/tests/run-idle/test.conf
@@ -0,0 +1,2 @@
+min-steady-state-interval 0
+steady-state-interval 2
diff --git a/tests/run-once/input b/tests/run-once/input
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/run-once/input
diff --git a/tests/run-once/output b/tests/run-once/output
new file mode 100644
index 0000000..9766475
--- /dev/null
+++ b/tests/run-once/output
@@ -0,0 +1 @@
+ok
diff --git a/tests/run-once/run-error b/tests/run-once/run-error
new file mode 100644
index 0000000..f84e1cf
--- /dev/null
+++ b/tests/run-once/run-error
@@ -0,0 +1 @@
+Killed
diff --git a/tests/run-once/subproc.sh b/tests/run-once/subproc.sh
new file mode 100755
index 0000000..7ccb759
--- /dev/null
+++ b/tests/run-once/subproc.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+. "$(dirname $0)"/../common.sh
+
+echo "ok"
+kill_tlsdated
diff --git a/tests/run-routeup/input b/tests/run-routeup/input
new file mode 100644
index 0000000..4ae8ef0
--- /dev/null
+++ b/tests/run-routeup/input
@@ -0,0 +1 @@
+u
diff --git a/tests/run-routeup/output b/tests/run-routeup/output
new file mode 100644
index 0000000..9766475
--- /dev/null
+++ b/tests/run-routeup/output
@@ -0,0 +1 @@
+ok
diff --git a/tests/run-routeup/runs b/tests/run-routeup/runs
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/tests/run-routeup/runs
@@ -0,0 +1 @@
+2
diff --git a/tests/run-routeup/setup b/tests/run-routeup/setup
new file mode 100755
index 0000000..c4afd68
--- /dev/null
+++ b/tests/run-routeup/setup
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")"/../common.sh
+
+reset_counter "runs"
diff --git a/tests/run-routeup/subproc.sh b/tests/run-routeup/subproc.sh
new file mode 100755
index 0000000..649a18e
--- /dev/null
+++ b/tests/run-routeup/subproc.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+. "$(dirname $0)"/../common.sh
+
+inc_counter "runs"
+c=$(counter "runs")
+[ $c -eq 2 ] && passed
diff --git a/tests/run-routeup/teardown b/tests/run-routeup/teardown
new file mode 100644
index 0000000..c4afd68
--- /dev/null
+++ b/tests/run-routeup/teardown
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")"/../common.sh
+
+reset_counter "runs"
diff --git a/tests/subproc-retry/input b/tests/subproc-retry/input
new file mode 100644
index 0000000..7898192
--- /dev/null
+++ b/tests/subproc-retry/input
@@ -0,0 +1 @@
+a
diff --git a/tests/subproc-retry/output b/tests/subproc-retry/output
new file mode 100644
index 0000000..0dae225
--- /dev/null
+++ b/tests/subproc-retry/output
@@ -0,0 +1,3 @@
+dying
+dying
+ok
diff --git a/tests/subproc-retry/runs b/tests/subproc-retry/runs
new file mode 100644
index 0000000..00750ed
--- /dev/null
+++ b/tests/subproc-retry/runs
@@ -0,0 +1 @@
+3
diff --git a/tests/subproc-retry/setup b/tests/subproc-retry/setup
new file mode 100755
index 0000000..c4afd68
--- /dev/null
+++ b/tests/subproc-retry/setup
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")"/../common.sh
+
+reset_counter "runs"
diff --git a/tests/subproc-retry/subproc.sh b/tests/subproc-retry/subproc.sh
new file mode 100755
index 0000000..c725aa1
--- /dev/null
+++ b/tests/subproc-retry/subproc.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+. "$(dirname $0)"/../common.sh
+
+inc_counter "runs"
+if [ $(counter "runs") -lt 3 ]; then
+ echo "dying"
+ echo "$$" >> /tmp/pidz
+ exit 1
+fi
+passed
diff --git a/tests/subproc-retry/teardown b/tests/subproc-retry/teardown
new file mode 100644
index 0000000..c4afd68
--- /dev/null
+++ b/tests/subproc-retry/teardown
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")"/../common.sh
+
+reset_counter "runs"
diff --git a/tests/wait-idle/input b/tests/wait-idle/input
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/wait-idle/input
diff --git a/tests/wait-idle/output b/tests/wait-idle/output
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/wait-idle/output
diff --git a/tests/wait-idle/subproc.sh b/tests/wait-idle/subproc.sh
new file mode 100644
index 0000000..21f5871
--- /dev/null
+++ b/tests/wait-idle/subproc.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+. "$(dirname $0)"/../common.sh
+
+inc_counter "runs"
+c=$(counter "runs")
+[ $c -eq 2 ] && failed
+