Use text instead of integers for stop_timer argument

This commit is contained in:
Salamandar 2023-01-20 13:46:36 +01:00
parent 7aa254d9fb
commit 98f806b9ec
3 changed files with 12 additions and 13 deletions

View file

@ -142,7 +142,8 @@ start_timer () {
stop_timer () {
# Ending the timer
# $1 = Type of querying
# $1 = Type of message
msg_type="${1:-}"
local finishtime=$(date +%s)
# Calculate the gap between the starting and the ending of the timer
@ -170,9 +171,9 @@ stop_timer () {
[ $seconds -gt 1 ] && pseconds="${pseconds}s" || pseconds="0s"
local time="${phours}${pminutes}${pseconds} ($(date '+%T'))"
if [ $1 -eq 2 ]; then
if [ "$msg_type" = "one_test" ]; then
log_info "Working time for this test: $time"
elif [ $1 -eq 3 ]; then
elif [ "$msg_type" = "all_tests" ]; then
log_info "Global working time for all tests: $time"
else
log_debug "Working time: $time"

View file

@ -25,7 +25,7 @@ LXC_CREATE () {
else
log_critical "Can't find base image $LXC_BASE, run ./package_check.sh --rebuild"
fi
pipestatus="${PIPESTATUS[0]}"
location=$(lxc list --format json | jq -e --arg LXC_NAME $LXC_NAME '.[] | select(.name==$LXC_NAME) | .location' | tr -d '"')
[[ "$location" != "none" ]] && log_info "... on $location"
@ -57,7 +57,7 @@ CREATE_LXC_SNAPSHOT () {
# Remove swap files to avoid killing the CI with huge snapshots.
CLEAN_SWAPFILES
LXC_STOP $LXC_NAME
# Check if the snapshot already exist
@ -69,7 +69,7 @@ CREATE_LXC_SNAPSHOT () {
_LXC_START_AND_WAIT $LXC_NAME
stop_timer 1
stop_timer
}
LOAD_LXC_SNAPSHOT () {
@ -104,7 +104,7 @@ LXC_EXEC () {
log_debug "Return code: $returncode"
stop_timer 1
stop_timer
# Return the exit code of the ssh command
return $returncode
}
@ -127,14 +127,14 @@ LXC_RESET () {
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
# Remove swap files before deletting the continer
CLEAN_SWAPFILES
fi
fi
LXC_STOP $LXC_NAME
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq '.[].expanded_devices.root.pool')
swapoff "$(lxc storage get $current_storage source)/containers/$LXC_NAME/rootfs/swap" 2>/dev/null
fi
fi
lxc delete $LXC_NAME --force 2>/dev/null
}
@ -220,4 +220,3 @@ CLEAN_SWAPFILES() {
RUN_INSIDE_LXC() {
lxc exec $LXC_NAME -- "$@"
}

View file

@ -90,7 +90,7 @@ run_all_tests() {
# Restore the started time for the timer
starttime=$complete_start_timer
# End the timer for the test
stop_timer 3
stop_timer all_tests
echo "You can find the complete log of these tests in $(realpath $complete_log)"
@ -151,7 +151,7 @@ TEST_LAUNCHER () {
# Restore the started time for the timer
starttime=$global_start_timer
# End the timer for the test
stop_timer 2
stop_timer one_test
LXC_STOP $LXC_NAME
@ -256,4 +256,3 @@ path_to_install_type() {
[ "$check_path" == "/" ] && { echo "root"; return; }
echo "subdir"
}