[LNT] r258055 - [test-suite-cmake] Add cflags support

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 18 09:03:50 PST 2016


Author: jamesm
Date: Mon Jan 18 11:03:50 2016
New Revision: 258055

URL: http://llvm.org/viewvc/llvm-project?rev=258055&view=rev
Log:
[test-suite-cmake] Add cflags support

Modified:
    lnt/trunk/lnt/tests/test_suite.py
    lnt/trunk/tests/runtest/test_suite.py

Modified: lnt/trunk/lnt/tests/test_suite.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/test_suite.py?rev=258055&r1=258054&r2=258055&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/test_suite.py (original)
+++ lnt/trunk/lnt/tests/test_suite.py Mon Jan 18 11:03:50 2016
@@ -1,4 +1,4 @@
-import subprocess, tempfile, json, os, shlex, platform
+import subprocess, tempfile, json, os, shlex, platform, pipes
 
 from optparse import OptionParser, OptionGroup
 
@@ -326,11 +326,19 @@ class TestSuiteTest(BuiltinTest):
             # FIXME: Support ARCH, SMALL/LARGE etc
             'CMAKE_C_COMPILER': self.opts.cc,
             'CMAKE_CXX_COMPILER': self.opts.cxx,
-            'CMAKE_C_FLAGS': ' '.join([self.opts.cppflags, self.opts.cflags]),
-            'CMAKE_CXX_FLAGS': ' '.join([self.opts.cppflags, self.opts.cxxflags])
+            'CMAKE_C_FLAGS': self._unix_quote_args(' '.join([self.opts.cppflags,
+                                                             self.opts.cflags])),
+            'CMAKE_CXX_FLAGS': self._unix_quote_args(' '.join([self.opts.cppflags,
+                                                               self.opts.cxxflags]))
         }
 
-        note('Configuring...')
+        lines = ['Configuring with {']
+        for k,v in defs.items():
+            lines.append("  %s: '%s'" % (k,v))
+        lines.append('}')
+
+        for l in lines:
+            note(l)
         subprocess.check_call([cmake_cmd, self._test_suite_dir()] +
                               ['-D%s=%s' % (k,v) for k,v in defs.items()],
                               cwd=path)
@@ -457,7 +465,11 @@ class TestSuiteTest(BuiltinTest):
         run = lnt.testing.Run(self.start_time, timestamp(), info=run_info)
         report = lnt.testing.Report(machine, run, test_samples)
         return report
-        
+
+    def _unix_quote_args(self, s):
+        return ' '.join(map(pipes.quote, shlex.split(s)))
+
+    
 def create_instance():
     return TestSuiteTest()
 

Modified: lnt/trunk/tests/runtest/test_suite.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/runtest/test_suite.py?rev=258055&r1=258054&r2=258055&view=diff
==============================================================================
--- lnt/trunk/tests/runtest/test_suite.py (original)
+++ lnt/trunk/tests/runtest/test_suite.py Mon Jan 18 11:03:50 2016
@@ -1,6 +1,6 @@
 # Testing for the 'lnt runtest test-suite' module.
 #
-# RUN: rm -r  %t.SANDBOX  %t.SANDBOX2 || true
+# RUN: rm -rf  %t.SANDBOX  %t.SANDBOX2 || true
 #
 # Check a basic nt run.
 # RUN: lnt runtest test-suite \
@@ -74,7 +74,7 @@
 # RUN: FileCheck --check-prefix CHECK-RESULTS < %t.SANDBOX/build/report.json %s
 # CHECK-RESULTS: "run_order": "123"
 
-# Change the machine name. Don't use LLVM.
+# Change the machine name.
 # RUN: lnt runtest test-suite \
 # RUN:     --sandbox %t.SANDBOX \
 # RUN:     --no-timestamp \
@@ -88,3 +88,84 @@
 # RUN:     > %t.log 2> %t.err
 # RUN: FileCheck --check-prefix CHECK-AUTONAME < %t.err %s
 # CHECK-AUTONAME: Using nickname: 'foo'
+
+# Check cflag handling
+
+## With a lone cflag
+# RUN: lnt runtest test-suite \
+# RUN:     --sandbox %t.SANDBOX \
+# RUN:     --no-timestamp \
+# RUN:     --test-suite %S/Inputs/test-suite-cmake \
+# RUN:     --cc %{shared_inputs}/FakeCompilers/clang-r154331 \
+# RUN:     --use-cmake %S/Inputs/test-suite-cmake/fake-cmake \
+# RUN:     --use-make %S/Inputs/test-suite-cmake/fake-make \
+# RUN:     --use-lit %S/Inputs/test-suite-cmake/fake-lit \
+# RUN:     --cflag '-Wall' \
+# RUN:     > %t.log 2> %t.err
+# RUN: FileCheck --check-prefix CHECK-CFLAG1 < %t.err %s
+# CHECK-CFLAG1: Inferred C++ compiler under test
+# CHECK-CFLAG1: CMAKE_C_FLAGS: '-Wall
+
+## With a couple of cflags
+# RUN: lnt runtest test-suite \
+# RUN:     --sandbox %t.SANDBOX \
+# RUN:     --no-timestamp \
+# RUN:     --test-suite %S/Inputs/test-suite-cmake \
+# RUN:     --cc %{shared_inputs}/FakeCompilers/clang-r154331 \
+# RUN:     --use-cmake %S/Inputs/test-suite-cmake/fake-cmake \
+# RUN:     --use-make %S/Inputs/test-suite-cmake/fake-make \
+# RUN:     --use-lit %S/Inputs/test-suite-cmake/fake-lit \
+# RUN:     --cflag '-Wall' \
+# RUN:     --cflag '-mfloat-abi=hard' \
+# RUN:     --cflag '-O3' \
+# RUN:     > %t.log 2> %t.err
+# RUN: FileCheck --check-prefix CHECK-CFLAG2 < %t.err %s
+# CHECK-CFLAG2: Inferred C++ compiler under test
+# CHECK-CFLAG2: CMAKE_C_FLAGS: '-Wall -mfloat-abi=hard -O3
+
+## With a cflags
+# RUN: lnt runtest test-suite \
+# RUN:     --sandbox %t.SANDBOX \
+# RUN:     --no-timestamp \
+# RUN:     --test-suite %S/Inputs/test-suite-cmake \
+# RUN:     --cc %{shared_inputs}/FakeCompilers/clang-r154331 \
+# RUN:     --use-cmake %S/Inputs/test-suite-cmake/fake-cmake \
+# RUN:     --use-make %S/Inputs/test-suite-cmake/fake-make \
+# RUN:     --use-lit %S/Inputs/test-suite-cmake/fake-lit \
+# RUN:     --cflags '-Wall -mfloat-abi=hard -O3' \
+# RUN:     > %t.log 2> %t.err
+# RUN: FileCheck --check-prefix CHECK-CFLAG3 < %t.err %s
+# CHECK-CFLAG3: Inferred C++ compiler under test
+# CHECK-CFLAG3: CMAKE_C_FLAGS: '-Wall -mfloat-abi=hard -O3
+
+## With a cflags with a quoted space and escaped spaces
+# RUN: lnt runtest test-suite \
+# RUN:     --sandbox %t.SANDBOX \
+# RUN:     --no-timestamp \
+# RUN:     --test-suite %S/Inputs/test-suite-cmake \
+# RUN:     --cc %{shared_inputs}/FakeCompilers/clang-r154331 \
+# RUN:     --use-cmake %S/Inputs/test-suite-cmake/fake-cmake \
+# RUN:     --use-make %S/Inputs/test-suite-cmake/fake-make \
+# RUN:     --use-lit %S/Inputs/test-suite-cmake/fake-lit \
+# RUN:     --cflags "-Wall -test=escaped\ space -some-option='stay with me' -O3" \
+# RUN:     > %t.log 2> %t.err
+# RUN: FileCheck --check-prefix CHECK-CFLAG4 < %t.err %s
+# CHECK-CFLAG4: Inferred C++ compiler under test
+# CHECK-CFLAG4: CMAKE_C_FLAGS: '-Wall '-test=escaped space' '-some-option=stay with me' -O3
+
+## With cflag and cflags
+# RUN: lnt runtest test-suite \
+# RUN:     --sandbox %t.SANDBOX \
+# RUN:     --no-timestamp \
+# RUN:     --test-suite %S/Inputs/test-suite-cmake \
+# RUN:     --cc %{shared_inputs}/FakeCompilers/clang-r154331 \
+# RUN:     --use-cmake %S/Inputs/test-suite-cmake/fake-cmake \
+# RUN:     --use-make %S/Inputs/test-suite-cmake/fake-make \
+# RUN:     --use-lit %S/Inputs/test-suite-cmake/fake-lit \
+# RUN:   --cflag '--target=armv7a-none-eabi' \
+# RUN:   --cflag '-Weverything' \
+# RUN:   --cflags '-Wall -test=escaped\ space -some-option="stay with me" -O3' \
+# RUN:     > %t.log 2> %t.err
+# RUN: FileCheck --check-prefix CHECK-CFLAG5 < %t.err %s
+# CHECK-CFLAG5: Inferred C++ compiler under test
+# CHECK-CFLAG5: CMAKE_C_FLAGS: '--target=armv7a-none-eabi -Weverything -Wall '-test=escaped space' '-some-option=stay with me' -O3




More information about the llvm-commits mailing list