]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
check: allow tests to record arbitrary metrics
authorOmar Sandoval <osandov@fb.com>
Thu, 4 May 2017 20:39:29 +0000 (13:39 -0700)
committerOmar Sandoval <osandov@fb.com>
Thu, 4 May 2017 20:39:29 +0000 (13:39 -0700)
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 <osandov@fb.com>
check
tests/meta/012 [new file with mode: 0755]
tests/meta/012.out [new file with mode: 0644]

diff --git a/check b/check
index 8bd18b112f8c3d0eb10833dadc27f6dda545a0fc..c63b9c44b84952aa882cef5de553d358c5b815e3 100755 (executable)
--- 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 (executable)
index 0000000..61cc4e9
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+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 (file)
index 0000000..d327baa
--- /dev/null
@@ -0,0 +1,2 @@
+Running meta/012
+Test complete