[OE-core] [PATCH v3] parallel-oe-selftest.sh: runs oe-selftest in parallel

leonardo.sandoval.gonzalez at linux.intel.com leonardo.sandoval.gonzalez at linux.intel.com
Tue Dec 19 15:10:33 UTC 2017


From: Leonardo Sandoval <leonardo.sandoval.gonzalez at linux.intel.com>

Run in parallel the (oe)selftests using GNU/Parallel: for each test
defined, a job will be launched and at any time at maximum of jobs
will be executing (defaults to 4).

1. Run all modules

    parallel-oe-selftest.sh

2. Run certain modules and print results in order (see parallel man
page for more info)

    parallel-oe-selftest.sh wic bblayers

Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez at linux.intel.com>
---

Changes from v3 (both suggested by Andre McCurdy):
* fix typos in commit message and comments on code
* fix if condition on all-tests execution

 scripts/contrib/parallel-oe-selftest.sh | 72 +++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100755 scripts/contrib/parallel-oe-selftest.sh

diff --git a/scripts/contrib/parallel-oe-selftest.sh b/scripts/contrib/parallel-oe-selftest.sh
new file mode 100755
index 0000000000..4dfda02454
--- /dev/null
+++ b/scripts/contrib/parallel-oe-selftest.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+# paralell-oe-selftest: executes oe-selftest in 'parallel'.
+#
+# Copyright (c) 2013-2017 Intel Corporation
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Before anything else, check oe-core environment
+if [ -z "$BUILDDIR" ]; then
+    echo "Please initialize the OE-Core environment through oe-init-build-env script"
+    exit 1
+fi
+
+usage() {
+CMD=$(basename $0)
+cat <<EOM
+Usage: $CMD [-h] [-j jobs] [test1 test2 ..]
+  -j jobs             Number of jobs to be running concurrently
+  -h                  Display this help message
+
+ Examples:
+   # run all found testcases
+   $CMD
+
+   # just run wic and bblayers
+   $CMD wic bblayers
+
+EOM
+}
+
+JOBS=4
+# Parse and validate arguments
+while getopts "hj:" OPT; do
+	case $OPT in
+	j)
+	        JOBS="$OPTARG"
+	        ;;
+	h)
+		usage
+		exit 0
+		;;
+	--)
+		shift
+		break
+		;;
+	esac
+done
+
+
+shift "$((OPTIND - 1))"
+TESTCASES="$@"
+
+which parallel 2>&1 >/dev/null || { echo "Please install GNU/Parallel"; exit 1; }
+
+if [ -z "$TESTCASES" ]; then
+    TESTCASES="$(oe-selftest -m | awk '{ print $NF } ' | grep -v ':')"
+    echo $TESTCASES | time parallel --keep-order --progress --jobs $JOBS oe-selftest -r
+else
+    time parallel -d ' ' --keep-order --progress --jobs $JOBS oe-selftest -r ::: $TESTCASES
+fi
-- 
2.12.3




More information about the Openembedded-core mailing list