From: Omar Sandoval Date: Thu, 4 May 2017 20:39:29 +0000 (-0700) Subject: check: allow tests to record arbitrary metrics X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d1bd327f57baf31f6845b60f27b0743f46af3d57;p=users%2Fsagi%2Fblktests.git check: allow tests to record arbitrary metrics Don't run the test function in a subshell so tests can set TEST_RUN[foo]=bar and it will be shown along with the runtime. Signed-off-by: Omar Sandoval --- diff --git a/check b/check index 8bd18b1..c63b9c4 100755 --- a/check +++ b/check @@ -235,8 +235,10 @@ _call_test() { fi TIMEFORMAT="%Rs" - TEST_RUN[runtime]="$(time ( "$test_func" >"${seqres}.out" 2>&1 ) 2>&1)" + { time "$test_func" >"${seqres}.out" 2>&1; } 2>"${seqres}.runtime" TEST_RUN[exit_status]=$? + TEST_RUN[runtime]="$(cat "${seqres}.runtime")" + rm -f "${seqres}.runtime" rm -rf "$TMPDIR" diff --git a/tests/meta/012 b/tests/meta/012 new file mode 100755 index 0000000..61cc4e9 --- /dev/null +++ b/tests/meta/012 @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Test recording arbitrary test metrics. +# +# Copyright (C) 2017 Omar Sandoval +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +TEST_GROUPS=(meta) + +test() { + echo "Running ${TEST_NAME}" + TEST_RUN[pid]=$$ + echo "Test complete" +} diff --git a/tests/meta/012.out b/tests/meta/012.out new file mode 100644 index 0000000..d327baa --- /dev/null +++ b/tests/meta/012.out @@ -0,0 +1,2 @@ +Running meta/012 +Test complete