From f9d29e67d5a78a78be85fa35ff972ac4f732ab42 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 18 May 2017 00:23:55 +0200 Subject: [PATCH] More working time infos --- package_check.sh | 16 ++++++++++++++++ sub_scripts/launcher.sh | 21 +++++++++++++++------ sub_scripts/testing_process.sh | 10 ++++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/package_check.sh b/package_check.sh index 3025909..6ead0c8 100755 --- a/package_check.sh +++ b/package_check.sh @@ -726,6 +726,15 @@ then check_file=0 fi +#================================================= +# Set the timer for all tests +#================================================= + +# Start the timer for this test +start_timer +# And keep this value separately +complete_start_timer=$starttime + #================================================= # Initialize tests #================================================= @@ -1117,7 +1126,14 @@ fi echo "You can find the complete log of these tests in $complete_log" +#================================================= +# Ending the timer +#================================================= +# Restore the started time for the timer +starttime=$complete_start_timer +# End the timer for the test +stop_timer 3 #================================================= # Notification grade diff --git a/sub_scripts/launcher.sh b/sub_scripts/launcher.sh index 43c5b61..4bab495 100755 --- a/sub_scripts/launcher.sh +++ b/sub_scripts/launcher.sh @@ -21,6 +21,8 @@ start_timer () { stop_timer () { # Ending the timer + # $1 = Type of querying + local finishtime=$(date +%s) # Calculate the gap between the starting and the ending of the timer local elapsedtime=$(echo $(( $finishtime - $starttime ))) @@ -46,7 +48,14 @@ stop_timer () { [ $minutes -eq 1 ] && pminutes="${pminutes}, " || test -z "$pminutes" || pminutes="${pminutes}s, " [ $seconds -gt 1 ] && pseconds="${pseconds}s" - ECHO_FORMAT "Working time: ${phours}${pminutes}${pseconds}.\n" "blue" + if [ $1 -eq 2 ]; then + ECHO_FORMAT "Working time for this test: " "blue" + elif [ $1 -eq 3 ]; then + ECHO_FORMAT "Global working time for all tests: " "blue" + else + ECHO_FORMAT "Working time: " "blue" + fi + ECHO_FORMAT "${phours}${pminutes}${pseconds}.\n" "blue" } #================================================= @@ -70,7 +79,7 @@ create_temp_backup () { current_snapshot=$(sudo lxc-snapshot --name $lxc_name --list | sort | tail --lines=1 | cut --delimiter=' ' --fields=1) # And return it echo "$current_snapshot" - stop_timer >&2 + stop_timer 1 >&2 # Restart the container, after the snapshot LXC_START "true" >&2 @@ -88,7 +97,7 @@ use_temp_snapshot () { # Restore this snapshot. sudo rsync --acls --archive --delete --executability --itemize-changes --xattrs "$snapshot_path/$current_snapshot/rootfs/" "/var/lib/lxc/$lxc_name/rootfs/" > /dev/null 2>> "$test_result" - stop_timer + stop_timer 1 # Fake the yunohost_result return code of the installation yunohost_result=0 } @@ -201,7 +210,7 @@ LXC_START () { ECHO_FORMAT "The container failed to start $max_try times...\nIf this problem is persistent, try to fix it with lxc_check.sh.\n" "red" "bold" ECHO_FORMAT "Boot log:\n" clog cat "$script_dir/lxc_boot.log" | tee --append "$test_result" - stop_timer + stop_timer 1 return 1 fi done @@ -220,7 +229,7 @@ LXC_START () { # Retrieve the log of the previous command and copy its content in the temporary log sudo cat "/var/lib/lxc/$lxc_name/rootfs/home/pchecker/temp_yunohost-cli.log" >> "$temp_log" - stop_timer + stop_timer 1 # Return the exit code of the ssh command return $returncode } @@ -253,7 +262,7 @@ LXC_STOP () { # Restore the snapshot. echo "Restore the previous snapshot." | tee --append "$test_result" sudo rsync --acls --archive --delete --executability --itemize-changes --xattrs "$snapshot_path/$current_snapshot/rootfs/" "/var/lib/lxc/$lxc_name/rootfs/" > /dev/null 2>> "$test_result" - stop_timer + stop_timer 1 } LXC_TURNOFF () { diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 935d0b0..677d3e3 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -1255,6 +1255,11 @@ TEST_LAUNCHER () { yunohost_result=-1 yunohost_remove=-1 + # Start the timer for this test + start_timer + # And keep this value separately + local global_start_timer=$starttime + # Execute the test $1 $2 @@ -1263,6 +1268,11 @@ TEST_LAUNCHER () { # Stop and restore the LXC container LXC_STOP + + # Restore the started time for the timer + starttime=$global_start_timer + # End the timer for the test + stop_timer 2 } set_witness_files () {