[Armadeus-commitlog] armadeus branch, master, updated. armadeus-5.2-226-g9ddf377
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2013-04-19 20:49:48
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via 9ddf377bceb513f575c0b6f2cd44d0bc0d006ab2 (commit)
from 108bf417b34f2057a61aa9d156fc94f066f8cb77 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 9ddf377bceb513f575c0b6f2cd44d0bc0d006ab2
Author: Julien Boibessot <jul...@ar...>
Date: Fri Apr 19 22:48:48 2013 +0200
[TEST] Improve media_perf.sh to be called by non-root user and generate a report file
-----------------------------------------------------------------------
Summary of changes:
target/test/mmc/media_perf.sh | 123 ++++++++++++++++++++++++++++++++++-------
1 files changed, 102 insertions(+), 21 deletions(-)
diff --git a/target/test/mmc/media_perf.sh b/target/test/mmc/media_perf.sh
index bc80b65..6d88acb 100755
--- a/target/test/mmc/media_perf.sh
+++ b/target/test/mmc/media_perf.sh
@@ -3,7 +3,7 @@
#
# Script to test Armadeus boards performances to handle removable storage media
#
-# Copyright (C) 2007 The Armadeus Project
+# Copyright (C) 2007-2013 The Armadeus Project
#
# 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
@@ -20,7 +20,11 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-source ./test_helpers.sh
+if [ -f ./test_helpers.sh ]; then
+ source ./test_helpers.sh
+else
+ source /usr/bin/testsuite/test_helpers.sh
+fi
# Script parameters
BOARD=`cat /etc/machine`
@@ -38,10 +42,12 @@ USB_MOUNT_DIR="/media/usbdisk"
TEMP_DIR="/tmp/perf_mmc/"
TEMP_FILE="/tmp/data.bin"
WRITE_BENCH="/tmp/test_mmc.sh"
+REPORT_FILE="/tmp/media_perf.report"
WTIME=0
RTIME=0
#DEBUG=True
+UID=`id -u`
debug()
{
@@ -72,6 +78,38 @@ get_time_in_ms_from_file()
fi
}
+clean_report()
+{
+ echo "# Report" > $REPORT_FILE
+}
+
+log_report()
+{
+ echo "$1" >> $REPORT_FILE
+}
+
+remount()
+{
+ if [ "$UID" == "0" ]; then # root
+ umount $MOUNT_DIR && mount $REM_DEVICE $MOUNT_DIR
+ else
+ # /etc/fstab & /etc/sudoers should have been configured
+ sudo /bin/umount $MOUNT_DIR && mount $REM_DEVICE
+ fi
+}
+
+special_umount()
+{
+ if [ "$WAS_MOUNTED" != "1" ]; then
+ if [ "$UID" == "0" ]; then # root
+ umount $MOUNT_DIR
+ else
+ # /etc/fstab & /etc/sudoers should have been configured
+ sudo /bin/umount $MOUNT_DIR
+ fi
+ fi
+}
+
test_speed()
{
# Create temp bench file
@@ -83,10 +121,10 @@ test_speed()
echo "exit 0" >> $WRITE_BENCH
for it in `seq $NB_ITER`; do
- echo "--- Test iteration n°$it ---"
+ echo "--- Test iteration No$it ---"
echo " Writing"
time sh $WRITE_BENCH 2>/tmp/writetime
- umount $MOUNT_DIR && mount $REM_DEVICE $MOUNT_DIR
+ remount
echo " Reading"
time mv $MOUNT_DIR/data.bin /tmp/ 2>/tmp/readtime
# Update writing mean time
@@ -112,13 +150,21 @@ test_speed()
WSPEED=`expr $TEMP_FILE_SIZE \* 1000 / $WTOTIME`
RSPEED=`expr $TEMP_FILE_SIZE \* 1000 / $RTOTIME`
echo "--- Test result (mean values): read -> $RSPEED kBytes/sec write -> $WSPEED kBytes/sec"
- umount $MOUNT_DIR
+ log_report "RESULT=OK"
+ log_report "READ_SPEED=$RSPEED"
+ log_report "WRITE_SPEED=$WSPEED"
+ special_umount
}
usage()
{
- echo -e "\n Usage: $0 <speed|integrity> [device]\n"
- echo "device: default to $MMC_DEVICE"
+ echo -e "\n Usage: $0 options\n"
+ echo "-m|--mode=<speed|integrity> : mandatory, test mode to use"
+ echo "-d|--mode=<device> : device to use for test (default to $MMC_DEVICE)"
+ echo "-n|--nb=<iteration> : number of test iterations (default to $NB_ITER)"
+ echo "-h|--help: this help"
+# echo "-q|--quiet: don't output anything on stdout"
+
exit 1
}
@@ -129,15 +175,44 @@ usage()
# Process parameters
if [ "$#" == 0 ]; then
usage
-elif [ "$1" != "speed" ] && [ "$1" != "integrity" ]; then
+fi
+GETOPT=`getopt -o hm:n:d:q --long help,mode:,nb:,device:,quiet -- "$@"`
+if [ $? != 0 ] ; then
usage
fi
+eval set -- "$GETOPT"
+while true ; do
+ case $1 in
+ -q|--quiet)
+ QUIET=1
+ shift ;;
+ -h|--help)
+ usage ;;
+ -m|--mode)
+ [ "$2" == "" ] && usage
+ MODE="$2"
+ shift 2 ;;
+ -n|--nb)
+ [ "$2" == "" ] && usage
+ NB_ITER="$2"
+ shift 2 ;;
+ -d|--device)
+ [ "$2" == "" ] && usage
+ MMC_DEVICE="$2"
+ shift 2 ;;
+ --)
+ shift ; break ;;
+ *)
+ usage ;;
+ esac
+done
-if [ "$2" != "" ]; then
- MMC_DEVICE="$2"
+if [ "$MODE" != "speed" ] && [ "$MODE" != "integrity" ]; then
+ usage
fi
show_test_banner "Storage medium performances"
+clean_report
if [ ! -b $MMC_DEVICE ] && [ ! -b $USB_DEVICE ]; then
echo -n "Please insert your storage device: MMC/SD/microSD or USB key"
@@ -175,9 +250,14 @@ if [ ! -d $MOUNT_DIR ]; then
fi
# If not mounted, mount it:
-IS_MOUNTED=`mount | grep -c $MOUNT_DIR`
-if [ "$IS_MOUNTED" != "1" ]; then
- mount $REM_DEVICE $MOUNT_DIR
+WAS_MOUNTED=`mount | grep -c $MOUNT_DIR`
+if [ "$WAS_MOUNTED" != "1" ]; then
+ if [ "$UID" == "0" ]; then # root
+ mount $REM_DEVICE $MOUNT_DIR
+ else
+ # /etc/fstab should have been configured
+ mount $REM_DEVICE
+ fi
if [ "$?" != 0 ]; then
echo "Failed to mount device $REM_DEVICE"
exit 1
@@ -185,16 +265,18 @@ if [ "$IS_MOUNTED" != "1" ]; then
fi
# Here we go:
-if [ "$1" == "speed" ]; then
+MEDIUM_SIZE=`df -h | grep mmc | awk '{ print $2 }'`
+echo "Medium size: $MEDIUM_SIZE"
+log_report "SIZE=$MEDIUM_SIZE"
+
+if [ "$MODE" == "speed" ]; then
test_speed
exit 0
fi
# or integrity test:
-SIZE=`df -hm | grep /media/mmc | awk '{$1=$1;print}' | cut -d " " -f 4`
-
-SIZE=40
+if [ "$NB_ITER" == "" ]; then NB_ITER=40; fi
it=0
mkdir -p $TEMP_DIR
@@ -204,7 +286,7 @@ MD5=$TEMP_DIR/test.rnd.md5
dd if=/dev/urandom of=$FILE bs=1024 count=1024 2>/dev/null
md5sum $FILE > $MD5
-while [ $it -le $SIZE ]; do
+while [ $it -le $NB_ITER ]; do
FILEMMC=$MOUNT_DIR/test_$it.rnd
# MD5=$TEMP_DIR/test_$it.rnd.md5
echo -en "\r Copying: $FILEMMC"
@@ -215,8 +297,7 @@ done
echo ""
-umount $MOUNT_DIR
-mount $REM_DEVICE $MOUNT_DIR
+remount
date
FILES=`ls $MOUNT_DIR/*.rnd`
@@ -236,6 +317,6 @@ echo "Integrity test successful !"
rm -rf $TEMP_DIR
rm $MOUNT_DIR/*.rnd
-umount $MOUNT_DIR
+special_umount
exit 0
hooks/post-receive
--
armadeus
|