[LNT] r263185 - Allow the user to specificy a test-suite cmake cache

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 14 11:29:57 PDT 2016


> On Mar 10, 2016, at 6:15 PM, Chris Matthews via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> Author: cmatthews
> Date: Thu Mar 10 20:15:07 2016
> New Revision: 263185
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=263185&view=rev
> Log:
> Allow the user to specificy a test-suite cmake cache
> 
> I think cmake caches are a good way to represent common configurations.
> This change allow the user to give a cmake cache on the command line,
> and LNT will change the cmake command accordingly.
> 
> Modified:
>    lnt/trunk/lnt/tests/test_suite.py
>    lnt/trunk/tests/runtest/Inputs/test-suite-cmake/fake-cmake
>    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=263185&r1=263184&r2=263185&view=diff
> ==============================================================================
> --- lnt/trunk/lnt/tests/test_suite.py (original)
> +++ lnt/trunk/lnt/tests/test_suite.py Thu Mar 10 20:15:07 2016
> @@ -55,8 +55,11 @@ class TestSuiteTest(BuiltinTest):
>                          help=("Defines to pass to cmake. These do not require the "
>                                "-D prefix and can be given multiple times. e.g.: "
>                                "--cmake-define A=B => -DA=B"))
> +        group.add_option("-C", "--cmake-cache", dest="cmake_cache",
> +                         help=("Use one of the test-suite's cmake configurations."
> +                               " Ex: Release, Debug"))
>         parser.add_option_group(group)
> -                         
> +
>         group = OptionGroup(parser, "Test compiler")
>         group.add_option("", "--cc", dest="cc", metavar="CC",
>                          type=str, default=None,
> @@ -365,10 +368,21 @@ class TestSuiteTest(BuiltinTest):
>         for k,v in sorted(defs.items()):
>             lines.append("  %s: '%s'" % (k,v))
>         lines.append('}')
> +        
> +        # Prepare cmake cache if requested:
> +        cache = []
> +        if self.opts.cmake_cache:
> +            cache_path = os.path.join(self._test_suite_dir(), 
> +                                      "cmake/caches/", self.opts.cmake_cache + ".cmake")
> +            if os.path.exists(cache_path):
> +                cache = ['-C', cache_path]
> +            else:
> +                fatal("Could not find CMake cache file: " + 
> +                      self.opts.cmake_cache + " in " + cache_path)
While I can understand the convenience of not having to type "cmake/caches" and ".cmake", this also makes it needlessly inflexible (you cannot load caches outside that particular directory) and makes it less obvious to people unfamiliar with the inner workings of LNT how that commandline ends up with the final path. Maybe it would be a better idea to take a path and interpret it relative to _test_suite_dir() if its a relative path or just take it as is if its an absolute one.

- Matthias

> 
>         for l in lines:
>             note(l)
> -        self._check_call([cmake_cmd, self._test_suite_dir()] +
> +        self._check_call([cmake_cmd] + cache + [self._test_suite_dir()] +
>                          ['-D%s=%s' % (k,v) for k,v in defs.items()],
>                          cwd=path)
> 
> 
> Modified: lnt/trunk/tests/runtest/Inputs/test-suite-cmake/fake-cmake
> URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/runtest/Inputs/test-suite-cmake/fake-cmake?rev=263185&r1=263184&r2=263185&view=diff
> ==============================================================================
> --- lnt/trunk/tests/runtest/Inputs/test-suite-cmake/fake-cmake (original)
> +++ lnt/trunk/tests/runtest/Inputs/test-suite-cmake/fake-cmake Thu Mar 10 20:15:07 2016
> @@ -1,5 +1,11 @@
> #!/bin/bash
> 
> +# If we passed a cache, just drop it and look like cmake.
> +if [[ $1 == "-C" ]]; then
> +    echo "Cmake Cache $2"
> +    shift
> +    shift    
> +fi    
> if [[ ! -f $1/CMakeLists.txt ]]; then
>   exit 1
> else
> 
> Modified: lnt/trunk/tests/runtest/test_suite.py
> URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/runtest/test_suite.py?rev=263185&r1=263184&r2=263185&view=diff
> ==============================================================================
> --- lnt/trunk/tests/runtest/test_suite.py (original)
> +++ lnt/trunk/tests/runtest/test_suite.py Thu Mar 10 20:15:07 2016
> @@ -300,3 +300,33 @@
> # RUN:     --run-order=123 > %t.log 2> %t.err
> # RUN: FileCheck --check-prefix CHECK-RESULTS-FAIL < %t.SANDBOX/build/report.json %s
> # CHECK-RESULTS-FAIL: "run_order": "123"
> +
> +# Check a run of test-suite using a cmake cache
> +# 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:     --cmake-cache Release \
> +# RUN:     &> %t.cmake-cache.log
> +# RUN: FileCheck  --check-prefix CHECK-CACHE < %t.cmake-cache.log %s
> +# CHECK-CACHE: Cmake Cache
> +# CHECK-CACHE: Release
> +
> +
> +# Check a run of test-suite using a invalid cmake cache
> +# 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:     --cmake-cache Debug \
> +# RUN:     &> %t.cmake-cache2.err || true
> +# RUN: FileCheck  --check-prefix CHECK-CACHE2 < %t.cmake-cache2.err %s
> +# CHECK-CACHE2: Could not find CMake cache file
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list