compare_jobs.sh: Handle list of targets to compare, if provided.
We currently compare the results of the targets we could find in the
logs. But if both ref and new failed to build for a given target, it
will be silently absent from the report. This patch adds support of a
user-provided list of targets, and if some are missing, a proper error
message is reported.
Change-Id: I7505c28209a10c924de35be1049349ee41eda4a0
diff --git a/compare_jobs.sh b/compare_jobs.sh
index ea92656..8d0047c 100755
--- a/compare_jobs.sh
+++ b/compare_jobs.sh
@@ -5,14 +5,16 @@
[ x"$1" = x"-pass-thresh" ] && pass_thresh=$2 && shift 2
-if [ $# != 2 ]
+if [ $# -lt 2 ]
then
- echo "Usage: $0 [-pass-thresh pass-ratio-threshold] ref_logs new_logs"
+ echo "Usage: $0 [-pass-thresh pass-ratio-threshold] ref_logs new_logs [target ...]"
+ echo " If no target name is provided, detect which targets have been built and compare their results"
exit 1
fi
ref_logs=$1
new_logs=$2
+shift 2
tmptargets=/tmp/targets.$$
trap "rm -f ${tmptargets}" 0 1 2 3 5 9 13 15
@@ -92,8 +94,15 @@
basename ${dir} >> ${tmptargets}
done
-if [ -s ${tmptargets} ]; then
- buildtargets=`sort -u ${tmptargets}`
+buildtargets=
+if [ $# -eq 0 ]; then
+ # If the user provided no target name, use what we detected
+ if [ -s ${tmptargets} ]; then
+ buildtargets=`sort -u ${tmptargets}`
+ fi
+else
+ # Otherwise, use what the user provided
+ buildtargets="$@"
fi
rm -f ${tmptargets}