From 86111acfeaf56312e581e0c9e16479a00f0921fa Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sun, 5 Apr 2020 11:53:44 +0200 Subject: [PATCH] tests clarifications --- test/main.bats | 23 +++++++++++------------ test/test_helper.bash | 4 +--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/test/main.bats b/test/main.bats index 4871c25..2f0d7c3 100755 --- a/test/main.bats +++ b/test/main.bats @@ -2,20 +2,19 @@ load test_helper -@test "init-filesystem" { - inode=$(stat --format=%i /backup) - if [ "${inode}" -eq 256 ]; then +@test "Filesystem type" { + if is_btrfs "/backup"; then # On a btrfs filesystem, the jail should be a btrfs volume - run stat --format=%i "${JAILPATH}" - [ "${output}" -eq 256 ] + run is_btrfs "${JAILPATH}" + assert_success else # On an ext4 filesystem, the jail should be a regular directory run test -d "${JAILPATH}" - [ "${status}" -eq 0 ] + assert_success fi } -@test "start" { +@test "A jail should be able to be started" { /usr/lib/bkctld/bkctld-start "${JAILNAME}" pid=$(cat "${JAILPATH}/${SSHD_PID}") # A started jail should have an SSH pid file @@ -23,7 +22,7 @@ load test_helper assert_success } -@test "stop" { +@test "A jail should be able to be stopped" { /usr/lib/bkctld/bkctld-start "${JAILNAME}" pid=$(cat "${JAILPATH}/${SSHD_PID}") /usr/lib/bkctld/bkctld-stop "${JAILNAME}" @@ -32,7 +31,7 @@ load test_helper assert_failure } -@test "reload" { +@test "A jail should be able to be reloaded" { /usr/lib/bkctld/bkctld-start "${JAILNAME}" /usr/lib/bkctld/bkctld-reload "${JAILNAME}" # A reloaded jail should mention the restart in the authlog @@ -40,7 +39,7 @@ load test_helper assert_success } -@test "restart" { +@test "A jail should be able to be restarted" { /usr/lib/bkctld/bkctld-start "${JAILNAME}" pid_before=$(cat "${JAILPATH}/${SSHD_PID}") @@ -51,12 +50,12 @@ load test_helper refute_equal "${pid_before}" "${pid_after}" } -@test "status" { +@test "Status should return information" { run /usr/lib/bkctld/bkctld-status "${JAILNAME}" assert_success } -@test "is-on" { +@test "ON/OFF status can be retrived with 'is-on'" { /usr/lib/bkctld/bkctld-start "${JAILNAME}" # A started jail should report to be ON run /usr/lib/bkctld/bkctld-is-on "${JAILNAME}" diff --git a/test/test_helper.bash b/test/test_helper.bash index 0413b1b..a640339 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -13,8 +13,6 @@ setup() { PORT=$(awk -v min=2222 -v max=2999 'BEGIN{srand(); print int(min+rand()*(max-min+1))}') INC_NAME=$(date +"%Y-%m-%d-%H") - inode=$(stat --format=%i /backup) - /usr/lib/bkctld/bkctld-init "${JAILNAME}" } @@ -27,7 +25,7 @@ is_btrfs() { inode=$(stat --format=%i "${path}") - test $inode -eq 256 + test ${inode} -eq 256 } flunk() {