summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorYongqin Liu <yongqin.liu@linaro.org>2015-03-09 23:52:06 +0800
committerYongqin Liu <yongqin.liu@linaro.org>2015-03-16 01:11:30 +0800
commit11b3ba6ed690e07e3a3b9da5e9cddde58e48719d (patch)
tree0c2b6f473e4ea1f59fd5c6870dd5756e1d62a4a2 /common
parent57f691897dfaff13c54cda6e21dfe91e25d86c13 (diff)
Add support to run multiple benchmarks together
Change-Id: I38500396f976630a80b011d73c0bed62b6a7d7bd Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Diffstat (limited to 'common')
-rwxr-xr-xcommon/common.sh3
-rw-r--r--common/common2.sh24
-rwxr-xr-xcommon/output-test-result.sh7
-rw-r--r--common/statistic_average.sh75
4 files changed, 85 insertions, 24 deletions
diff --git a/common/common.sh b/common/common.sh
index 059ee62..4fd5ed8 100755
--- a/common/common.sh
+++ b/common/common.sh
@@ -24,8 +24,7 @@ func_install_start_RotationAPK(){
if [ -f "${apk_path}" ]; then
echo "The file(${apk_path}) already exists."
else
- local apk_base_url="http://testdata.validation.linaro.org/apks/"
- get_file_with_base_url "${apk_name}" "${apk_base_url}" "${D_APKS}"
+ get_file_with_base_url "${apk_name}" "${base_url}" "${D_APKS}"
fi
adb shell pm list packages | grep rotation.off
if [ $? -ne 0 ]; then
diff --git a/common/common2.sh b/common/common2.sh
index 57962c7..a11de4f 100644
--- a/common/common2.sh
+++ b/common/common2.sh
@@ -22,15 +22,16 @@ BASE_URL=""
## Description:
## get specified the apk file from remote
## Usage:
-## get_file_with_base_url $file_name $base_url $target_dir
+## get_file_with_base_url $remote_relative_path $base_url $target_dir
## Example:
## get_file_with_base_url "${apk_apk}" "${BASE_URL}" "${D_APKS}"
get_file_with_base_url(){
- local file_name=$1 && shift
+ local remote_rel_path=$1 && shift
+ base_name=$(basename ${remote_rel_path})
local base_url=$1 && shift
local target_dir=$1 && shift
- if [ -z "${file_name}" ]; then
+ if [ -z "${remote_rel_path}" ]; then
echo "The file name must be specified."
return 1
fi
@@ -45,19 +46,19 @@ get_file_with_base_url(){
return 1
fi
- if [ -f "${target_dir}/${file_name}" ]; then
- echo "The file($file_name) already exists."
+ if [ -f "${target_dir}/${base_name}" ]; then
+ echo "The file(${remote_rel_path}) already exists."
return 0
fi
mkdir -p "${target_dir}"
case "X${base_url}" in
"Xscp://"*)
# like scp://yongqin.liu@testdata.validation.linaro.org/home/yongqin.liu
- apk_url="${base_url}/${file_name}"
+ apk_url="${base_url}/${remote_rel_path}"
url_no_scp=`echo ${apk_url}|sed 's/^\s*scp\:\/\///'|sed 's/\//\:\//'`
- scp "${url_no_scp}" "${target_dir}/${file_name}"
+ scp "${url_no_scp}" "${target_dir}/${base_name}"
if [ $? -ne 0 ]; then
- echo "Failed to get the apk(${file_name}) with ${base_url}"
+ echo "Failed to get the apk(${remote_rel_path}) with ${base_url}"
return 1
fi
;;
@@ -69,14 +70,14 @@ get_file_with_base_url(){
fi
;;
"Xhttp://"*)
- wget "${base_url}/${file_name}" -O "${target_dir}/${file_name}"
+ wget "${base_url}/${remote_rel_path}" -O "${target_dir}/${base_name}"
if [ $? -ne 0 ]; then
echo "Failed to get the apks with ${base_url}"
return 1
fi
;;
"X"*)
- echo "Failed to get the file($file_name)."
+ echo "Failed to get the file($remote_rel_path)."
echo "The schema of the ${base_url} is not supported now!"
return 1
;;
@@ -281,6 +282,7 @@ func_loop_apps_for_times(){
for apk in ${loop_apps_list}; do
local loop_app_apk=$(echo $apk|cut -d, -f1)
+ loop_app_apk=$(basename ${loop_app_apk})
local loop_app_start_activity=$(echo $apk|cut -d, -f2)
local loop_app_package=$(echo ${loop_app_start_activity}|cut -d\/ -f1)
local loop_app_name=$(echo $apk|cut -d, -f3)
@@ -383,6 +385,8 @@ func_prepare_environment(){
func_get_all_apks "$G_APPS"|| exit 1
adb shell svc power stayon true
+ adb shell input keyevent MENU
+ adb shell input keyevent BACK
}
func_print_usage_common(){
diff --git a/common/output-test-result.sh b/common/output-test-result.sh
new file mode 100755
index 0000000..b54349a
--- /dev/null
+++ b/common/output-test-result.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+local_common_file_path="$0"
+local_common_parent_dir=$(cd $(dirname ${local_common_file_path}); pwd)
+source "${local_common_parent_dir}/statistic_average.sh"
+
+output_test_result "$@"
diff --git a/common/statistic_average.sh b/common/statistic_average.sh
index 31ec3d9..8f91395 100644
--- a/common/statistic_average.sh
+++ b/common/statistic_average.sh
@@ -1,5 +1,9 @@
#!/bin/bash
+local_common_file_path="${BASH_SOURCE[0]}"
+local_common_parent_dir=$(cd $(dirname ${local_common_file_path}); pwd)
+f_result_csv="${local_common_parent_dir}/../rawdata/final_result.csv"
+
## Description:
## output the max value of the passed 2 parameters
## Usage:
@@ -7,10 +11,10 @@
## Example:
## max=$(f_max "1.5" "2.0")
f_max(){
- local val1=$1 && shift
- local val2=$1 && shift
- [ -z "$val1" ] && return $val2
- [ -z "$val2" ] && return $val1
+ local val1=$1
+ local val2=$2
+ [ -z "$val1" ] && echo $val2
+ [ -z "$val2" ] && echo $val1
local compare=$(echo "$val1>$val2"|bc)
if [ "X$compare" = "X1" ];then
@@ -27,10 +31,10 @@ f_max(){
## Example:
## min=$(f_min "1.5" "2.0")
f_min(){
- local val1=$1 && shift
- local val2=$1 && shift
- [ -z "$val1" ] && return $val1
- [ -z "$val2" ] && return $val2
+ local val1=$1
+ local val2=$2
+ [ -z "$val1" ] && echo $val1
+ [ -z "$val2" ] && echo $val2
local compare=$(echo "$val1<$val2"|bc)
if [ "X$compare" = "X1" ];then
@@ -49,14 +53,14 @@ f_min(){
## Example:
## statistic "$f_res_starttime" 2
## Note:
-## if less than 4 samples for that key/item there, average will be calculated as total/count
-## if 4 or more samples for that key/item there, average will be calculated with max and min excluded
+## if less than 4 samples for that key/item there, average will be calculated as total/count
+## if 4 or more samples for that key/item there, average will be calculated with max and min excluded
statistic(){
- local f_data=$1 && shift
+ local f_data=$1
if ! [ -f "$f_data" ]; then
return
fi
- local field_no=$1 && shift
+ local field_no=$2
if [ -z "$field_no" ]; then
field_no=2
fi
@@ -102,3 +106,50 @@ statistic(){
echo "$new_key=$average"
fi
}
+
+## Description:
+## output the test result to console and add for lava-test-shell,
+## also write into one csv file for comparing manually
+## Usage:
+## output_test_result $test_name $result [ $measurement [ $units ] ]
+output_test_result(){
+ local test_name=$1
+ local result=$2
+ local measurement=$3
+ local units=$4
+
+ if [ -z "${test_name}" ] || [ -z "$result" ]; then
+ return
+ fi
+ local output=""
+ local lava_paras=""
+ local output_csv=""
+ test_name=$(echo ${test_name}|tr ' ' '_')
+ if [ -z "${measurement}" ]; then
+ output="${test_name}=${result}"
+ lava_paras="${test_name} --result ${result}"
+ else
+ output="${test_name}=${measurement}"
+ lava_paras="${test_name} --result ${result} --measurement ${measurement}"
+ output_csv="${test_name},${measurement}"
+ fi
+
+ if [ -z "$units" ]; then
+ units="points"
+ fi
+ output="${output} ${units}"
+ lava_paras="${lava_paras} --units ${units}"
+
+ echo "${output}"
+
+ local cmd="lava-test-case"
+ if [ -n "$(which $cmd)" ];then
+ $cmd ${lava_paras}
+ else
+ echo "$cmd ${lava_paras}"
+ fi
+ if [ -n "${output_csv}" ];then
+ mkdir -p $(dirname ${f_result_csv})
+ echo "${output_csv}">>${f_result_csv}
+ fi
+}