tests clarifications

This commit is contained in:
Jérémy Lecour 2020-04-05 11:53:44 +02:00 committed by Jérémy Lecour
parent 2ef20df5ca
commit 86111acfea
2 changed files with 12 additions and 15 deletions

View file

@ -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}"

View file

@ -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() {