From 3d25d4319afbbc485c0f194f394dbe25ce079d2e Mon Sep 17 00:00:00 2001 From: Nicolas Dechesne Date: Thu, 19 Jan 2017 15:47:09 +0100 Subject: automated: add support for measurements with no unit It is possible to report measurements with no specific units, however the helper functions currently require the unit to be specified. This patch allows test case to provide only the measurement in add_metric() , effectively making the last arg (unit) optional. When processing the output , we then need to ensure whether or not the unit was specified in the first place. I needed this when porting sysbench test case onto 'automated' method (e.g. sysbench reports 'count of events'). With this change I can get the following test results from sysbench: 2017-01-19 15:45:57,557 - RUNNER.ResultParser: INFO: Result files saved to: /home/ndec/output/sysbench_9ce36643-e7e9-481e-a45a-464cd07d8cd9 --- Printing result.csv --- name,test_case_id,result,measurement,units,test_params sysbench,total-time-2-threads,pass,4.0010,s,DURATION=4;MAX_REQUESTS=50000;SKIP_INSTALL=False;TEST=cpu;FILE_TEST_MODE=seqrewr;TIMES=1 sysbench,total-number-of-events-2-threads,pass,8827,,DURATION=4;MAX_REQUESTS=50000;SKIP_INSTALL=False;TEST=cpu;FILE_TEST_MODE=seqrewr;TIMES=1 sysbench,total-time-taken-by-event-execution-2-threads,pass,7.9996,,DURATION=4;MAX_REQUESTS=50000;SKIP_INSTALL=False;TEST=cpu;FILE_TEST_MODE=seqrewr;TIMES=1 sysbench,min-2-threads,pass,0.90,ms,DURATION=4;MAX_REQUESTS=50000;SKIP_INSTALL=False;TEST=cpu;FILE_TEST_MODE=seqrewr;TIMES=1 sysbench,avg-2-threads,pass,0.91,ms,DURATION=4;MAX_REQUESTS=50000;SKIP_INSTALL=False;TEST=cpu;FILE_TEST_MODE=seqrewr;TIMES=1 sysbench,max-2-threads,pass,3.38,ms,DURATION=4;MAX_REQUESTS=50000;SKIP_INSTALL=False;TEST=cpu;FILE_TEST_MODE=seqrewr;TIMES=1 sysbench,approx.-95-percentile-2-threads,pass,0.93,ms,DURATION=4;MAX_REQUESTS=50000;SKIP_INSTALL=False;TEST=cpu;FILE_TEST_MODE=seqrewr;TIMES=1 Change-Id: Id41207c3237f597bc3db83a5d7d54ee35f6974e3 Signed-off-by: Nicolas Dechesne --- automated/lib/sh-test-lib | 6 +++--- automated/utils/send-to-lava.sh | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'automated') diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib index b02c121..3b2ab43 100755 --- a/automated/lib/sh-test-lib +++ b/automated/lib/sh-test-lib @@ -129,9 +129,9 @@ report_fail() { } add_metric() { - if [ "$#" -ne 4 ]; then - warn_msg "The number of parameters less then 4" - error_msg "Usage: add_metric test_case result measurement units" + if [ "$#" -lt 3 ]; then + warn_msg "The number of parameters less then 3" + error_msg "Usage: add_metric test_case result measurement [units]" fi test_case="$1" result="$2" diff --git a/automated/utils/send-to-lava.sh b/automated/utils/send-to-lava.sh index 9660b97..ace3de9 100755 --- a/automated/utils/send-to-lava.sh +++ b/automated/utils/send-to-lava.sh @@ -16,14 +16,18 @@ if [ -f "${RESULT_FILE}" ]; then else echo "" fi - elif echo "${line}" | egrep -iq ".*+ (pass|fail|skip)+ .*+ .*"; then + elif echo "${line}" | egrep -iq ".*+ (pass|fail|skip)+ .*+"; then test="$(echo "${line}" | awk '{print $1}')" result="$(echo "${line}" | awk '{print $2}')" measurement="$(echo "${line}" | awk '{print $3}')" units="$(echo "${line}" | awk '{print $4}')" if [ "${lava_test_case}" -eq 0 ]; then - lava-test-case "${test}" --result "${result}" --measurement "${measurement}" --units "${units}" + if [ -n "${units}" ]; then + lava-test-case "${test}" --result "${result}" --measurement "${measurement}" --units "${units}" + else + lava-test-case "${test}" --result "${result}" --measurement "${measurement}" + fi else echo "" fi -- cgit v1.2.3