[PATCH] D61597: [test-suite] Fix support for user mode emulation when using cmake/lit.

Kristof Beyls via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 00:43:33 PDT 2019


kristof.beyls updated this revision to Diff 208884.
kristof.beyls added a comment.

Thanks for the feedback Sam!

I've followed your suggestion to set the value of TEST_SUITE_USER_MODE_EMULATION in a similar way as TEST_SUITE_PROFILE_GENERATE. I agree that's a bit cleaner.

I also looked further into creating a test in the test-suite's regression tests (in litsupport-tests) for this new functionality. However, the framework that exists there is really only for the lit-part of the running tests, not the cmake part of configuring.
Since this patch is fully on the cmake side, I don't think there is any way to add a test in litsupport-tests for this. A testing framework would need to be added to test the cmake logic of the test-suite if we'd want to test this. I've decided not to try and do that for now.

I wonder what the other issues are you're seeing after applying this patch?
I also wonder if you've also tried the corresponding lnt patch at D61598 <https://reviews.llvm.org/D61598> that makes it possible to use this new functionality from `lnt runtest test-suite`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61597/new/

https://reviews.llvm.org/D61597

Files:
  CMakeLists.txt
  cmake/modules/TestSuite.cmake
  lit.site.cfg.in
  litsupport/modules/timeit.py
  tools/CMakeLists.txt


Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -7,7 +7,9 @@
 
 include(Host)
 
-add_executable(fpcmp fpcmp.c)
+add_executable(fpcmp-target ${CMAKE_CURRENT_SOURCE_DIR}/fpcmp.c)
+add_executable(build-fpcmp-target ALIAS fpcmp-target)
+llvm_add_host_executable(build-fpcmp fpcmp fpcmp.c)
 
 add_custom_command(
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/HashProgramOutput.sh
Index: litsupport/modules/timeit.py
===================================================================
--- litsupport/modules/timeit.py
+++ litsupport/modules/timeit.py
@@ -9,7 +9,14 @@
     config = context.config
     cmd = shellcommand.parse(commandline)
 
-    timeit = "%s/tools/timeit-target" % config.test_source_root
+    if config.user_mode_emulation:
+        # user_mode_emulation should be true if tests are being run via
+        # user-mode emulation (e.g. Qemu) and thus the host version of timeit
+        # should be used.
+        timeit_name = "timeit"
+    else:
+        timeit_name = "timeit-target"
+    timeit = "%s/tools/%s" % (config.test_source_root, timeit_name)
     args = ["--limit-core", "0"]
     args += ["--limit-cpu", "7200"]
     args += ["--timeout", "7200"]
Index: lit.site.cfg.in
===================================================================
--- lit.site.cfg.in
+++ lit.site.cfg.in
@@ -5,6 +5,7 @@
 config.remote_client = "@TEST_SUITE_REMOTE_CLIENT@"
 config.remote_host = "@TEST_SUITE_REMOTE_HOST@"
 config.run_under = "@TEST_SUITE_RUN_UNDER@"
+config.user_mode_emulation = @TEST_SUITE_USER_MODE_EMULATION@
 config.strip_tool = "@CMAKE_STRIP@"
 config.profile_generate = @TEST_SUITE_PROFILE_GENERATE@
 config.llvm_profdata = "@TEST_SUITE_LLVM_PROFDATA@"
Index: cmake/modules/TestSuite.cmake
===================================================================
--- cmake/modules/TestSuite.cmake
+++ cmake/modules/TestSuite.cmake
@@ -99,7 +99,8 @@
     build-HashProgramOutput.sh
     build-timeit
     build-timeit-target
-    fpcmp
+    build-fpcmp
+    build-fpcmp-target
   )
 endfunction()
 
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -77,6 +77,18 @@
 # Run Under configuration for RunSafely.sh (will be set in lit.site.cfg)
 set(TEST_SUITE_RUN_UNDER "" CACHE STRING "RunSafely.sh run-under (-u) parameter")
 
+# User mode emulation configuration (e.g. running under qemu)
+# (will be set in lit.site.cfg)
+set(TEST_SUITE_USER_MODE_EMULATION NO CACHE BOOL
+    "RUN_UNDER is used to run tests under emulation.")
+# Set value to python style True/False
+if (TEST_SUITE_USER_MODE_EMULATION)
+  set(TEST_SUITE_USER_MODE_EMULATION "True")
+else()
+  set(TEST_SUITE_USER_MODE_EMULATION "False")
+endif()
+
+
 # run type/benchmark size configuration (mostly for SPEC at the moment)
 set(TEST_SUITE_RUN_TYPE "train" CACHE STRING
     "Type of benchmark inputs (may be test,train or ref)")
@@ -220,7 +232,10 @@
 
 add_subdirectory(tools)
 # Shortcut for the path to the fpcmp executable
-set(FPCMP ${CMAKE_BINARY_DIR}/tools/fpcmp)
+set(FPCMP ${CMAKE_BINARY_DIR}/tools/fpcmp-target)
+if (TEST_SUITE_USER_MODE_EMULATION)
+  set(FPCMP ${CMAKE_BINARY_DIR}/tools/fpcmp)
+endif()
 
 option(TEST_SUITE_COLLECT_COMPILE_TIME
        "Measure compile time by wrapping compiler invocations in timeit" ON)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61597.208884.patch
Type: text/x-patch
Size: 3392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190710/f5e07917/attachment.bin>


More information about the llvm-commits mailing list