From 98f806b9ece50c61820df67d317378f5222f4a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 20 Jan 2023 13:46:36 +0100 Subject: [PATCH] Use text instead of integers for stop_timer argument --- lib/common.sh | 7 ++++--- lib/lxc.sh | 13 ++++++------- lib/tests_coordination.sh | 5 ++--- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 867e209..5863fcf 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -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" diff --git a/lib/lxc.sh b/lib/lxc.sh index f52ab43..5869067 100644 --- a/lib/lxc.sh +++ b/lib/lxc.sh @@ -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 -- "$@" } - diff --git a/lib/tests_coordination.sh b/lib/tests_coordination.sh index eaa63a6..7fefd3a 100644 --- a/lib/tests_coordination.sh +++ b/lib/tests_coordination.sh @@ -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" } -