Skip to content

Commit

Permalink
test: Log execution time
Browse files Browse the repository at this point in the history
To start optymalizing test suite, we need to know which tests are the
most time consuming. Log execution time after every test.

Signed-off-by: Mariusz Tkaczyk <[email protected]>
  • Loading branch information
mtkaczyk committed Nov 27, 2024
1 parent 8032700 commit 3fbdda4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,22 @@ mdadm() {
return $rv
}

print_time_elapsed() {
local start_sec=$1
local end_sec=$(date +%s)

local execution_time=$((end_sec - start_sec))

echo -ne "Execution time (seconds): ${execution_time} "
}

do_test() {
_script=$1
_basename=`basename $_script`
_broken=0

local start_sec=$(date +%s)

if [ -f "$_script" ]
then
if [ -f "${_script}.broken" ]; then
Expand All @@ -121,6 +132,7 @@ do_test() {
echo -ne "$_script... "
if ( set -ex ; . $_script ) &> $targetdir/log
then
print_time_elapsed $start_sec
if [ -f "${_script}.inject_error" ]; then
echo "dmesg checking is skipped because test inject error"
else
Expand All @@ -130,6 +142,7 @@ do_test() {
succeed "succeeded\n"
_fail=0
else
print_time_elapsed $start_sec
save_log fail
_fail=1
if [ "$_broken" == "1" ]; then
Expand Down

0 comments on commit 3fbdda4

Please sign in to comment.