[test-suite] r264617 - cmake/lit: Make lit aware of SingleSource tests.

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 28 11:54:49 PDT 2016


Author: matze
Date: Mon Mar 28 13:54:49 2016
New Revision: 264617

URL: http://llvm.org/viewvc/llvm-project?rev=264617&view=rev
Log:
cmake/lit: Make lit aware of SingleSource tests.

This reverts most of the cmake hackery from r264499, instead
communicate to lit which tests are singlesource tests so it can narrow
down the compiletime search to files starting with the benchmark name.

Added:
    test-suite/trunk/SingleSource/lit.local.cfg
Modified:
    test-suite/trunk/SingleSource/CMakeLists.txt
    test-suite/trunk/cmake/modules/SingleMultiSource.cmake
    test-suite/trunk/lit.cfg
    test-suite/trunk/litsupport/compiletime.py

Modified: test-suite/trunk/SingleSource/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/CMakeLists.txt?rev=264617&r1=264616&r2=264617&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/CMakeLists.txt (original)
+++ test-suite/trunk/SingleSource/CMakeLists.txt Mon Mar 28 13:54:49 2016
@@ -2,3 +2,5 @@ llvm_add_subdirectories(Benchmarks)
 if(NOT TEST_SUITE_BENCHMARKING_ONLY)
   llvm_add_subdirectories(UnitTests Regression)
 endif()
+
+file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")

Added: test-suite/trunk/SingleSource/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/lit.local.cfg?rev=264617&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/lit.local.cfg (added)
+++ test-suite/trunk/SingleSource/lit.local.cfg Mon Mar 28 13:54:49 2016
@@ -0,0 +1 @@
+config.single_source = True

Modified: test-suite/trunk/cmake/modules/SingleMultiSource.cmake
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/modules/SingleMultiSource.cmake?rev=264617&r1=264616&r2=264617&view=diff
==============================================================================
--- test-suite/trunk/cmake/modules/SingleMultiSource.cmake (original)
+++ test-suite/trunk/cmake/modules/SingleMultiSource.cmake Mon Mar 28 13:54:49 2016
@@ -144,11 +144,7 @@ macro(test_suite_add_executable name mai
     # Note that we cannot use target_link_libraries() here because that one
     # only interprets inputs starting with '-' as flags.
     append_link_flags(${executable} ${LDFLAGS})
-    set(executable_path ${CMAKE_CURRENT_BINARY_DIR})
-    if(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
-      set(executable_path ${executable_path}/${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-    endif()
-    set(executable_path ${executable_path}/${executable})
+    set(executable_path ${CMAKE_CURRENT_BINARY_DIR}/${executable})
     if (TEST_SUITE_PROFILE_USE)
       append_compile_flags(${executable} -fprofile-instr-use=${executable_path}.profdata)
       append_link_flags(${executable} -fprofile-instr-use=${executable_path}.profdata)
@@ -177,14 +173,8 @@ macro(llvm_singlesource)
     string(REGEX REPLACE ".[cp]+$" "" path ${source})
     string(REGEX REPLACE ".*/" "" name ${path})
 
-    # Setting CMAKE_RUNTIME_OUTPUT_DIRECTORY lets cmake put the files into a
-    # different subdirectory for each benchmark. This is usefull for
-    # differentiating which statistics like *.o.time files belongs to which
-    # benchmark.
-    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${name})
     test_suite_add_executable(${name} ${source} ${source})
   endforeach()
-  unset(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
 endmacro()
 
 # Configure the current directory as a MultiSource subdirectory - i.e. there is

Modified: test-suite/trunk/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/lit.cfg?rev=264617&r1=264616&r2=264617&view=diff
==============================================================================
--- test-suite/trunk/lit.cfg (original)
+++ test-suite/trunk/lit.cfg Mon Mar 28 13:54:49 2016
@@ -11,6 +11,7 @@ config.suffixes = ['.test']
 config.excludes = ['ABI-Testsuite']
 config.remote_flags = ""
 config.traditional_output = True
+config.single_source = False
 if 'SSH_AUTH_SOCK' in os.environ:
     config.environment['SSH_AUTH_SOCK'] = os.environ['SSH_AUTH_SOCK']
 

Modified: test-suite/trunk/litsupport/compiletime.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/compiletime.py?rev=264617&r1=264616&r2=264617&view=diff
==============================================================================
--- test-suite/trunk/litsupport/compiletime.py (original)
+++ test-suite/trunk/litsupport/compiletime.py Mon Mar 28 13:54:49 2016
@@ -4,26 +4,23 @@ import timeit
 
 
 def _getCompileTime(context):
-    basepath = os.path.dirname(context.test.getFilePath())
-    dirs = [basepath]
-    # Single source .o/.o.time files are placed in a different directory.
-    name = os.path.basename(basepath)
-    alternate_dir = "%s/../CMakeFiles/%s.dir" % (basepath, name)
-    dirs.append(alternate_dir)
+    # We compile multiple benchmarks in the same directory in SingleSource
+    # mode. Only look at compiletime files starting with the name of our test.
+    prefix = ""
+    if context.config.single_source:
+        prefix = "%s." % os.path.basename(context.executable)
 
-    # TODO: This is not correct yet as the directory may contain .o.time files
-    # of multiple benchmarks in the case of SingleSource tests.
     compile_time = 0.0
     link_time = 0.0
-    for dir in dirs:
-        for path, subdirs, files in os.walk(dir):
-            for file in files:
-                if file.endswith('.o.time'):
-                    fullpath = os.path.join(path, file)
-                    compile_time += timeit.getUserTime(fullpath)
-                if file.endswith('.link.time'):
-                    fullpath = os.path.join(path, file)
-                    link_time += timeit.getUserTime(fullpath)
+    dir = os.path.dirname(context.test.getFilePath())
+    for path, subdirs, files in os.walk(dir):
+        for file in files:
+            if file.endswith('.o.time') and file.startswith(prefix):
+                fullpath = os.path.join(path, file)
+                compile_time += timeit.getUserTime(fullpath)
+            if file.endswith('.link.time') and file.startswith(prefix):
+                fullpath = os.path.join(path, file)
+                link_time += timeit.getUserTime(fullpath)
     return {
         'compile_time': lit.Test.toMetricValue(compile_time),
         'link_time': lit.Test.toMetricValue(link_time),




More information about the llvm-commits mailing list