Skip to contentSkip to conversation

scripts: introduce a script for build test

PATCH Superseded Wei Liu 2 participants 4 messages Oct 25, 2017 – Oct 30, 2017

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH v3 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]>

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

---
 scripts/build-test.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100755 scripts/build-test.sh
scripts/build-test.sh new file +50 -0
new file mode 100755
index 0000000000..f55ec5d4fa
@@ -0,0 +1,50 @@
+#!/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
+
+trap "echo Restoring original HEAD ; git checkout $ORIG_BRANCH" EXIT
+
+git rev-list $BASE..$TIP | nl -ba | tac | \
+while read num rev; do
+    echo "Testing $num $rev"
+    git checkout $rev
+    if test $# -eq 0 ; then
+        git clean -fdx && ./configure && make -j4
+    else
+        "$@"
+    fi
+    if test $? -ne 0; then
+        echo "Failed at $num $rev"
+        exit 1
+    fi
+    echo
+done
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#1 lore raw
Quoted 14 lines · Wei Liu

---
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]>

Quoted 4 lines

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

Ping?

Quoted 64 lines
---
 scripts/build-test.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100755 scripts/build-test.sh
scripts/build-test.sh new file +50 -0
new file mode 100755
index 0000000000..f55ec5d4fa
@@ -0,0 +1,50 @@
+#!/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
+
+trap "echo Restoring original HEAD ; git checkout $ORIG_BRANCH" EXIT
+
+git rev-list $BASE..$TIP | nl -ba | tac | \
+while read num rev; do
+    echo "Testing $num $rev"
+    git checkout $rev
+    if test $# -eq 0 ; then
+        git clean -fdx && ./configure && make -j4
+    else
+        "$@"
+    fi
+    if test $? -ne 0; then
+        echo "Failed at $num $rev"
+        exit 1
+    fi
+    echo
+done
Signature · 1 line
2.11.0

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

#2 lore raw
In reply to Wei Liu

Wei Liu writes ("[PATCH v3 for-4.10] scripts: introduce a script for build test"):

Quoted 2 lines

...
...

Quoted 1 line

+trap "echo Restoring original HEAD ; git checkout $ORIG_BRANCH" EXIT

This will smash the whole script's exit status. I think you need to save/restore $?. Be careful with your quoting. Normally it is better for the argument to trap to be ''-quoted rather than "", to avoid it being expanded twice (and, the first time, too soon).

Also, if this fails, it leaves the failure message buried in a scrool of make -j4 output, where the user probably won't see it. And it prints exactly the same message on success and failure. On failure you should print the failing commitid, and exit nonzero.

On success you should print some reassuring `ok' message.

Ian.

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

author
#3 lore raw
Quoted 12 lines · Ian Jackson

Wei Liu writes ("[PATCH v3 for-4.10] scripts: introduce a script for build test"):

Quoted 2 lines

...
...

Quoted 1 line

+trap "echo Restoring original HEAD ; git checkout $ORIG_BRANCH" EXIT

This will smash the whole script's exit status. I think you need to save/restore $?. Be careful with your quoting. Normally it is better for the argument to trap to be ''-quoted rather than "", to avoid it being expanded twice (and, the first time, too soon).

Quoted 7 lines

Also, if this fails, it leaves the failure message buried in a scrool of make -j4 output, where the user probably won't see it. And it prints exactly the same message on success and failure. On failure you should print the failing commitid, and exit nonzero.

On success you should print some reassuring `ok' message.

Right. I've addressed your comments and will send out a new version soon.

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