summaryrefslogtreecommitdiff
path: root/automated/lib
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2016-08-26 14:47:16 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2016-08-30 10:52:12 +0000
commit3d1bc8474e38b17ae4ee1660c2a2fc0edf023961 (patch)
tree95770a02fe983c4f7852ad0d0fb6c848e269dbe0 /automated/lib
parente015c4e850666f84fb3ddecd09cca706aa0432e8 (diff)
v2: linux: add dd write/read speed test
- Added Linux dd write/read speed test - Optimized sh-test-lib Change-Id: I3bccfda212535e9a36b8e231b69c0dd2367a88f6 Signed-off-by: Chase Qi <chase.qi@linaro.org>
Diffstat (limited to 'automated/lib')
-rwxr-xr-xautomated/lib/sh-test-lib51
1 files changed, 23 insertions, 28 deletions
diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib
index 15ef4e0..fca1153 100755
--- a/automated/lib/sh-test-lib
+++ b/automated/lib/sh-test-lib
@@ -5,55 +5,47 @@ export LANG
error_msg() {
local msg="$1"
- test -z "${msg}" && msg="Unknown error"
+ [ -z "${msg}" ] && msg="Unknown error"
printf "ERROR: %s\n" "${msg}" >&2
exit 1
}
warn_msg() {
local msg="$1"
- test -z "${msg}" && msg="Unknown error"
+ [ -z "${msg}" ] && msg="Unknown error"
printf "WARNING: %s\n" "${msg}" >&2
}
info_msg() {
local msg="$1"
- test -z "${msg}" && msg="Unknown info"
+ [ -z "${msg}" ] && msg="Unknown info"
printf "INFO: %s\n" "${msg}" >&1
}
-check_return_fail() {
- if [ $? -ne 0 ]; then
- fail_test "$1"
+check_root() {
+ if [ "$(id -ru)" -eq 0 ]; then
return 0
else
return 1
fi
}
-fail_test() {
- local reason="$1"
- echo "${test}: fail - ${reason}"
-}
-
-pass_test() {
- echo "${test}: pass"
-}
+exit_on_fail() {
+ local exit_code="$?"
+ [ "$#" -ne 1 ] && error_msg "Usage: exit_on_fail test"
+ local test="$1"
-check_root() {
- if [ "$(id -ru)" -eq 0 ]; then
- return 0
- else
- return 1
+ if [ "${exit_code}" -ne 0 ]; then
+ echo "${test} fail" | tee -a "${RESULT_FILE}"
+ exit 1
fi
}
check_return() {
local exit_code="$?"
+ [ "$#" -ne 1 ] && error_msg "Usage: check_return test"
local test="$1"
- test -z "${test}" && warn_msg "Test name is empty"
-
if [ "${exit_code}" -ne 0 ]; then
echo "${test} fail" | tee -a "${RESULT_FILE}"
return "${exit_code}"
@@ -64,15 +56,16 @@ check_return() {
}
add_metric() {
+ if [ "$#" -ne 4 ]; then
+ warn_msg "The number of parameters less then 4"
+ error_msg "Usage: add_metric test result measurement units"
+ fi
local test="$1"
- local measurement="$2"
- local units="$3"
-
- test -z "${test}" && warn_msg "Test name is empty"
- test -z "${measurement}" && warn_msg "Test measurement is empty"
- test -z "${units}" && warn_msg "Test units is empty"
+ local result="$2"
+ local measurement="$3"
+ local units="$4"
- echo "${test} pass ${measurement} ${units}" | tee -a "${RESULT_FILE}"
+ echo "${test} ${result} ${measurement} ${units}" | tee -a "${RESULT_FILE}"
}
dist_name() {
@@ -95,6 +88,8 @@ dist_name() {
install_deps() {
local pkgs="$1"
+ [ -z "${pkgs}" ] && error_msg "Usage: install_deps pkgs"
+ # skip_install parmater is optional.
local skip_install="$2"
if [ "${skip_install}" = "True" ] || [ "${skip_install}" = "true" ]; then