[PATCH v3 5/5] autobuild: Add test for cross-compilation infrastructure

Uri Simchoni urisimchoni at gmail.com
Tue May 5 16:02:19 MDT 2015


With added option to generate cross-answers by cross-execute script,
a test is added to verify that at least for tested build environments,
the infrastructure is self-consistent.

The test runs samba configuration in three modes:
1. Native
2. Cross compile with cross-execute, using the build machine as its own
   target
3. Cross compile with cross-answers, using the answers generated in
   step 2

The build environments created by the three processes are then tested to
be equal.

Signed-off-by: Uri Simchoni <urisimchoni at gmail.com>
---
 script/autobuild.py          | 18 +++++++++++++++---
 script/compare_cc_results.py | 33 +++++++++++++++++++++++++++++++++
 script/identity_cc.sh        | 10 ++++++++++
 3 files changed, 58 insertions(+), 3 deletions(-)
 create mode 100755 script/compare_cc_results.py
 create mode 100755 script/identity_cc.sh

diff --git a/script/autobuild.py b/script/autobuild.py
index b2303f7..c697aad 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -23,6 +23,7 @@ cleanup_list = []
 builddirs = {
     "ctdb"    : "ctdb",
     "samba"  : ".",
+    "samba-xc" : ".",
     "samba-ctdb" : ".",
     "samba-libs"  : ".",
     "ldb"     : "lib/ldb",
@@ -36,7 +37,9 @@ builddirs = {
     "retry"   : "."
     }
 
-defaulttasks = [ "ctdb", "samba", "samba-ctdb", "samba-libs", "ldb", "tdb", "talloc", "replace", "tevent", "pidl" ]
+defaulttasks = [ "ctdb", "samba", "samba-xc", "samba-ctdb", "samba-libs", "ldb", "tdb", "talloc", "replace", "tevent", "pidl" ]
+
+samba_configure_params = " --picky-developer ${PREFIX} --with-profiling-data"
 
 tasks = {
     "ctdb" : [ ("random-sleep", "../script/random-sleep.sh 60 600", "text/plain"),
@@ -48,13 +51,22 @@ tasks = {
                ("clean", "make clean", "text/plain") ],
 
     # We have 'test' before 'install' because, 'test' should work without 'install'
-    "samba" : [ ("configure", "./configure.developer --picky-developer ${PREFIX} --with-selftest-prefix=./bin/ab  --with-profiling-data", "text/plain"),
+    "samba" : [ ("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params, "text/plain"),
                 ("make", "make -j", "text/plain"),
                 ("test", "make test FAIL_IMMEDIATELY=1", "text/plain"),
                 ("install", "make install", "text/plain"),
                 ("check-clean-tree", "script/clean-source-tree.sh", "text/plain"),
                 ("clean", "make clean", "text/plain") ],
 
+    # Test cross-compile infrastructure
+    "samba-xc" : [ ("configure-native", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params, "text/plain"),
+                   ("configure-cross-execute", "./configure.developer -b ./bin-xe --cross-compile --cross-execute=script/identity_cc.sh" \
+                    " --cross-answers=./bin-xe/cross-answers.txt --with-selftest-prefix=./bin-xe/ab" + samba_configure_params, "text/plain"),
+                   ("configure-cross-answers", "./configure.developer -b ./bin-xa --cross-compile" \
+                    " --cross-answers=./bin-xe/cross-answers.txt --with-selftest-prefix=./bin-xa/ab" + samba_configure_params, "text/plain"),
+                   ("compare-results", "script/compare_cc_results.py ./bin/c4che/default.cache.py ./bin-xe/c4che/default.cache.py ./bin-xa/c4che/default.cache.py", "text/plain")],
+
+
     "samba-ctdb" : [ ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
 
                      # make sure we have tdb around:
@@ -519,7 +531,7 @@ A summary of the autobuild process is here:
 
   %s/autobuild.log
 ''' % (platform.node(), failed_task, errstr, log_base)
-    
+
     if failed_task != 'rebase':
         text += '''
 You can see logs of the failed task here:
diff --git a/script/compare_cc_results.py b/script/compare_cc_results.py
new file mode 100755
index 0000000..112eed1
--- /dev/null
+++ b/script/compare_cc_results.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+#
+# Compare the results of native and cross-compiled configure tests
+#
+
+import sys
+import hashlib
+
+exceptions = ['BUILD_DIRECTORY', 'CROSS_COMPILE', 'CROSS_ANSWERS',
+              'CROSS_EXECUTE', 'SELFTEST_PREFIX']
+
+base_hash = ''
+base_fname = ''
+
+for fname in sys.argv[1:]:
+    h = hashlib.new('sha1')
+    f = open(fname, 'r')
+    for line in f:
+        if len(line.split('=', 1)) == 2:
+            key = line.split('=', 1)[0].strip()
+            if key in exceptions:
+                continue
+        h.update(line)
+    f.close()
+    new_hash = h.hexdigest()
+    if base_fname:
+        if base_hash != new_hash:
+            print 'files %s and %s do not match' % (base_fname, fname)
+            sys.exit(1)
+    else:
+        base_fname = fname
+        base_hash = new_hash
diff --git a/script/identity_cc.sh b/script/identity_cc.sh
new file mode 100755
index 0000000..8b5118e
--- /dev/null
+++ b/script/identity_cc.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+#An "identity cross-execute" script
+#It can be used for testing the cross-build infrastructure
+#as follows:
+#./configure --cross-compile --cross-execute=./script/identity_cc.sh
+#If the build is actually a native build, then the configuration
+#result should be just like running ./configure without --cross-compile.
+
+eval "$@"
-- 
1.9.1



More information about the samba-technical mailing list