waf: sanitize and fix added cross answer
authorUri Simchoni <urisimchoni@gmail.com>
Mon, 18 May 2015 18:12:06 +0000 (21:12 +0300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 20 May 2015 09:19:11 +0000 (11:19 +0200)
When configuring samba for cross-compilation using the cross-answers
method, the function add_answer receives the standard output and exit code
of a configuration test and updates the cross-answers file accordingly.

This patch sanitizes the standard output to conform to the cross-answers
file format - one line of output. It also adds a missing newline.

(Note - at this point add_answer is only ever called with empty output
but this change is significant for the reminder of this patchset)

Signed-off-by: Uri Simchoni <urisimchoni@gmail.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
buildtools/wafsamba/samba_cross.py

index 877ead8581528695aa1062296186156121eb8151..b48155336d8d75ee50a3c1cc3ffa6f5c9a70ab39 100644 (file)
@@ -19,6 +19,16 @@ def add_answer(ca_file, msg, answer):
     except:
         Logs.error("Unable to open cross-answers file %s" % ca_file)
         sys.exit(1)
+    (retcode, retstring) = answer
+    # if retstring is more than one line then we probably
+    # don't care about its actual content (the tests should
+    # yield one-line output in order to comply with the cross-answer
+    # format)
+    retstring = retstring.strip()
+    if len(retstring.split('\n')) > 1:
+        retstring = ''
+    answer = (retcode, retstring)
+
     if answer == ANSWER_OK:
         f.write('%s: OK\n' % msg)
     elif answer == ANSWER_UNKNOWN:
@@ -26,8 +36,7 @@ def add_answer(ca_file, msg, answer):
     elif answer == ANSWER_FAIL:
         f.write('%s: FAIL\n' % msg)
     else:
-        (retcode, retstring) = answer
-        f.write('%s: (%d, "%s")' % (msg, retcode, retstring))
+        f.write('%s: (%d, "%s")\n' % (msg, retcode, retstring))
     f.close()