summaryrefslogtreecommitdiff
path: root/tools/replay_log
diff options
context:
space:
mode:
authorJoseph Hwang <josephsih@chromium.org>2012-06-06 15:24:49 +0800
committerGerrit <chrome-bot@google.com>2012-06-19 03:49:10 -0700
commit499ed29547424de402d898327226d77ed9d125cd (patch)
tree35d7671647968d74c8f013adda3492f22feb1734 /tools/replay_log
parentbc249fe34b4390359c651f29029899cf146b178f (diff)
downloadlibchrome-gestures-499ed29547424de402d898327226d77ed9d125cd.tar.gz
replay_log: test all logs in a given directory
If the input argument to the replay_log is a directory, test all the logs in the directory and list the test results. BUG=chromium-os:31533 TEST=Perform the following tests inside chroot. $ cd ~/trunk/src/platform/gestures $ tools/replay_log --only_honor "" tools/logs/cr48 It would test all of the logs in the given direcotry, and list the test result. Change-Id: I6b00c9f3d173ce8573faef7b42dd6dba7bb6984f Reviewed-on: https://gerrit.chromium.org/gerrit/24680 Commit-Ready: Joseph Shyh-In Hwang <josephsih@chromium.org> Reviewed-by: Joseph Shyh-In Hwang <josephsih@chromium.org> Tested-by: Joseph Shyh-In Hwang <josephsih@chromium.org>
Diffstat (limited to 'tools/replay_log')
-rwxr-xr-xtools/replay_log96
1 files changed, 70 insertions, 26 deletions
diff --git a/tools/replay_log b/tools/replay_log
index 27298ca..0b4f37f 100755
--- a/tools/replay_log
+++ b/tools/replay_log
@@ -94,39 +94,83 @@ binarydata/${LOG_FILE}?id=${LOG_IDNUM}&logIndex=0"
fi
fi
+# Convert the infile from a relative path to the realpath since we will
+# change directory below.
+original_infile="$infile"
+infile="$(realpath $infile)"
+
# Go to the Gestures source root
cd $(dirname "$0")/..
make -j $(fgrep processor /proc/cpuinfo | wc -l) test
-# Get input filetype
-intype="$(file -b "${infile}" | cut -d ' ' -f 1)"
-# Extra check in case file gets ASCII wrong
-if [ "$(head -n 1 "${infile}")" = "{" ]; then
- intype="ASCII"
-fi
+expand_input_file() {
+ # Get input filetype
+ intype="$(file -b "${infile}" | cut -d ' ' -f 1)"
+ # Extra check in case file gets ASCII wrong
+ if [ "$(head -n 1 "${infile}")" = "{" ]; then
+ intype="ASCII"
+ fi
-if [ "$intype" = "bzip2" ]; then
- # Expand to the bzip2ed file within
- zlogs="$(bzcat "$infile" | uudecode -o - | tar xvf -)"
- # take newest log and reduce to next case
- mv "$(ls -t $zlogs | grep touchpad_activity | head -n 1)" log.gz
- rm -f $zlogs
- infile="log.gz"
- intype="gzip"
-fi
+ if [ "$intype" = "bzip2" ]; then
+ # Expand to the bzip2ed file within
+ zlogs="$(bzcat "$infile" | uudecode -o - | tar xvf -)"
+ # take newest log and reduce to next case
+ mv "$(ls -t $zlogs | grep touchpad_activity | head -n 1)" log.gz
+ rm -f $zlogs
+ infile="log.gz"
+ intype="gzip"
+ fi
-if [ "$intype" = "gzip" ]; then
- zcat "$infile" > log.txt
- infile="log.txt"
- intype="ASCII"
-fi
+ if [ "$intype" = "gzip" ]; then
+ zcat "$infile" > log.txt
+ infile="log.txt"
+ intype="ASCII"
+ fi
-if [ "$intype" != "ASCII" ]; then
- echo "Unable to read input file"
- exit 1
-fi
+ if [ "$intype" != "ASCII" ]; then
+ echo "Unable to read input file"
+ exit 1
+ fi
+}
-./test --gtest_also_run_disabled_tests \
+run_test() {
+ expand_input_file
+ # We would like the shell to survive no matter whether ./test succeeds or not.
+ result=0
+ ./test --gtest_also_run_disabled_tests \
--gtest_filter="ActivityReplayTest.DISABLED_SimpleTest" \
- --outfile="$FLAGS_out" --only_honor="$FLAGS_only_honor" --in="$infile"
+ --outfile="$FLAGS_out" --only_honor="$FLAGS_only_honor" --in="$infile" ||
+ result=$?
+}
+
+# If infile is a file, test this log as before and there is no redirection.
+# If infile is a directory, test all logs in the directory, and output
+# the test statistics at the end.
+if [ -f "$infile" ]; then
+ echo "$original_infile is a file."
+ run_test
+elif [ -d "$infile" ]; then
+ statistics_result="$(mktemp)"
+ echo -e "\nInput directory: $original_infile\n" > $statistics_result
+ indir="$infile"
+ files=$(ls "$indir")
+ count=0
+ passed=0
+ for file in $files; do
+ infile="$indir/$file"
+ if [ -f "$infile" ]; then
+ run_test
+ if [ $result -eq 0 ]; then
+ echo "[ PASSED ] $original_infile/$file" >> $statistics_result
+ passed=$(($passed + 1))
+ else
+ echo "[ FAILED ] $original_infile/$file" >> $statistics_result
+ fi
+ count=$(($count + 1))
+ fi
+ done
+ cat $statistics_result
+ rm -fr $statistics_result
+ echo -e "\n$passed out of $count tests passed.\n"
+fi