Skip to contentSkip to conversation

scripts: introduce a script for build test

PATCH Superseded Wei Liu 2 participants 2 messages Oct 30, 2017 – Nov 1, 2017

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH v4 1/1 scripts: introduce a script for build test

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Anthony PERARD <[email protected]>

v4:
1. Check, save/restore $?.
2. Don't use trap, check exit code directly.
3. More error messages.

v3:
1. Use git-clean in default rune.
2. Print more friendly message.
3. Restore HEAD automatically.

---
 scripts/build-test.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100755 scripts/build-test.sh
scripts/build-test.sh new file +71 -0
new file mode 100755
index 0000000000..413540c13b
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+# Run command on every commit within the range specified. If no command is
+# provided, use the default one to clean and build the whole tree.
+#
+# The default rune is rather simple. To do a cross-build, please put your usual
+# build rune in a shell script and invoke it with this script.
+
+if ! test -f xen/common/kernel.c; then
+    echo "Please run this script from top-level directory"
+    exit 1
+fi
+
+if test $# -lt 2 ; then
+    echo "Usage: $0 <BASE> <TIP> [CMD]"
+    exit 1
+fi
+
+status=`git status -s`
+if test -n "$status"; then
+    echo "Tree is dirty, aborted"
+    exit 1
+fi
+
+BASE=$1; shift
+TIP=$1; shift
+
+ORIG_BRANCH=`git symbolic-ref -q --short HEAD`
+if test $? -ne 0; then
+    echo "Detached HEAD, aborted"
+    exit 1
+fi
+
+git rev-list $BASE..$TIP | nl -ba | tac | \
+while read num rev; do
+    echo "Testing $num $rev"
+
+    git checkout $rev
+    ret=$?
+    if test $ret -ne 0; then
+        echo "Failed to checkout $num $rev with $ret"
+        exit $ret
+    fi
+
+    if test $# -eq 0 ; then
+        git clean -fdx && ./configure && make -j4
+    else
+        "$@"
+    fi
+    ret=$?
+    if test $ret -ne 0; then
+        echo "Failed at $num $rev with $ret"
+        exit $ret
+    fi
+    echo
+done
+
+ret=$?
+
+echo "Restoring original HEAD"
+git checkout $ORIG_BRANCH
+gco_ret=$?
+if test $gco_ret -ne 0; then
+    echo "Failed to restore orignal HEAD. Check tree status before doing anything else!"
+    exit $gco_ret
+fi
+
+if test $ret -eq 0; then
+    echo "ok."
+fi
+exit $ret
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v4 1/1
#1 lore raw

scripts/build-test.sh line 41

Quoted 8 lines · Wei Liu
scripts/build-test.sh new file +8 -0
+git rev-list $BASE..$TIP | nl -ba | tac | \
+while read num rev; do
+    echo "Testing $num $rev"
+
+    git checkout $rev
+    ret=$?
+    if test $ret -ne 0; then
+        echo "Failed to checkout $num $rev with $ret"

I don't think printing the return value of git-checkout is usefull, it is just too much information. git-checkout man page have nothing about the meaning of it.

Beside that, and the fact that I don't like this style of while loop where exit doesn't exit the script, but only the loop ...

FIY: One would write the loop like this:
while read num rev; do
:
done < <(git rev-list $BASE..$TIP | nl -ba | tac)

And then you could ret=$?;break; inside the loop, and have the correct $ret value after the loop.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel