[clang-tools-extra] r178661 - Unit test support for Clang extra tools

Edwin Vane edwin.vane at intel.com
Wed Apr 3 08:11:08 PDT 2013


Author: revane
Date: Wed Apr  3 10:11:08 2013
New Revision: 178661

URL: http://llvm.org/viewvc/llvm-project?rev=178661&view=rev
Log:
Unit test support for Clang extra tools

Added support to CMake and autoconf for unit tests in clang-tools-extra. A
dummy test exists for now until more meaningful tests can be written.


Added:
    clang-tools-extra/trunk/test/Unit/
    clang-tools-extra/trunk/test/Unit/lit.cfg
    clang-tools-extra/trunk/test/Unit/lit.site.cfg.in
    clang-tools-extra/trunk/unittests/
    clang-tools-extra/trunk/unittests/CMakeLists.txt
    clang-tools-extra/trunk/unittests/Makefile
    clang-tools-extra/trunk/unittests/cpp11-migrate/
    clang-tools-extra/trunk/unittests/cpp11-migrate/CMakeLists.txt
    clang-tools-extra/trunk/unittests/cpp11-migrate/Makefile
    clang-tools-extra/trunk/unittests/cpp11-migrate/dummy.cpp
Modified:
    clang-tools-extra/trunk/CMakeLists.txt
    clang-tools-extra/trunk/Makefile
    clang-tools-extra/trunk/test/CMakeLists.txt
    clang-tools-extra/trunk/test/Makefile

Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=178661&r1=178660&r2=178661&view=diff
==============================================================================
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Wed Apr  3 10:11:08 2013
@@ -5,3 +5,4 @@ add_subdirectory(modularize)
 
 # Add the common testsuite after all the tools.
 add_subdirectory(test)
+add_subdirectory(unittests)

Modified: clang-tools-extra/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/Makefile?rev=178661&r1=178660&r2=178661&view=diff
==============================================================================
--- clang-tools-extra/trunk/Makefile (original)
+++ clang-tools-extra/trunk/Makefile Wed Apr  3 10:11:08 2013
@@ -11,7 +11,7 @@ CLANG_LEVEL := ../..
 
 include $(CLANG_LEVEL)/../../Makefile.config
 
-PARALLEL_DIRS := remove-cstr-calls tool-template cpp11-migrate modularize
+PARALLEL_DIRS := remove-cstr-calls tool-template cpp11-migrate modularize unittests
 
 include $(CLANG_LEVEL)/Makefile
 

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=178661&r1=178660&r2=178661&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Wed Apr  3 10:11:08 2013
@@ -12,6 +12,11 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
   )
 
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
+  )
+
 option(CLANG_TOOLS_TEST_USE_VG "Run Clang tools' tests under Valgrind" OFF)
 if(CLANG_TOOLS_TEST_USE_VG)
   set(CLANG_TOOLS_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
@@ -23,6 +28,9 @@ set(CLANG_TOOLS_TEST_DEPS
 
   # Individual tools we test.
   remove-cstr-calls cpp11-migrate modularize
+
+  # Unit tests
+  ExtraToolsUnitTests
   )
 
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"

Modified: clang-tools-extra/trunk/test/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/Makefile?rev=178661&r1=178660&r2=178661&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/Makefile (original)
+++ clang-tools-extra/trunk/test/Makefile Wed Apr  3 10:11:08 2013
@@ -38,7 +38,7 @@ ifdef VG
   LIT_ARGS += "--vg"
 endif
 
-all:: lit.site.cfg
+all:: lit.site.cfg Unit/lit.site.cfg
 	@ echo '--- Running the Clang extra tools tests for $(TARGET_TRIPLE) ---'
 	@ $(PYTHON) $(LLVM_SRC_ROOT)/utils/lit/lit.py \
 	  $(LIT_ARGS) $(TESTARGS) $(TESTDIRS)
@@ -46,7 +46,7 @@ all:: lit.site.cfg
 FORCE:
 
 lit.site.cfg: FORCE
-	@echo "Making Clang extra tools' 'lit.site.cfg' file..."
+	@echo "Making lit.site.cfg for Clang extra tools..."
 	@$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g > lit.tmp
 	@$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> lit.tmp
 	@$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp
@@ -57,6 +57,15 @@ lit.site.cfg: FORCE
 	@sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@
 	@-rm -f lit.tmp
 
+Unit/lit.site.cfg: FORCE
+	@echo "Making Unit/lit.site.cfg for Clang extra tools..."
+	@$(MKDIR) $(dir $@)
+	@$(ECHOPATH) s=@CLANG_TOOLS_BINARY_DIR@=$(PROJ_OBJ_DIR)/..=g >> lit.tmp
+	@$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> lit.tmp
+	@$(ECHOPATH) s=@CLANG_TOOLS_SOURCE_DIR@=$(PROJ_SRC_DIR)/..=g >> lit.tmp
+	@sed -f lit.tmp $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@
+	@-rm -f lit.tmp
+
 clean::
 	@ find . -name Output | xargs rm -fr
 

Added: clang-tools-extra/trunk/test/Unit/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/Unit/lit.cfg?rev=178661&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/Unit/lit.cfg (added)
+++ clang-tools-extra/trunk/test/Unit/lit.cfg Wed Apr  3 10:11:08 2013
@@ -0,0 +1,29 @@
+# -*- Python -*-
+
+config.name = "Extra Tools Unit Tests"
+config.suffixes = [] # Seems not to matter for google tests?
+
+# Test Source and Exec root dirs both point to the same directory where google
+# test binaries are built.
+extra_tools_obj_dir = getattr(config, 'extra_tools_obj_dir', None)
+if extra_tools_obj_dir is not None:
+  config.test_source_root = os.path.join(extra_tools_obj_dir, 'unittests')
+  config.test_exec_root = config.test_source_root
+
+# All GoogleTests are named to have 'Tests' as their suffix. The '.' option is
+# a special value for GoogleTest indicating that it should look through the
+# entire testsuite recursively for tests (alternatively, one could provide a
+# ;-separated list of subdirectories).
+config.test_format = lit.formats.GoogleTest('.', 'Tests')
+
+# If the site-specific configuration wasn't loaded (e.g. the build system failed
+# to create it or the user is running a test file directly) try to come up with
+# sane config options.
+if config.test_exec_root is None:
+  # Look for a --param=extra_tools_unit_site_config option.
+  site_cfg = lit.params.get('extra_tools_unit_site_config', None)
+  if site_cfg and os.path.exists(site_cfg):
+      lit.load_config(config, site_cfg)
+      raise SystemExit
+
+  # FIXME: Support out-of-tree builds? See clang/test/Unit/lit.cfg if we care.

Added: clang-tools-extra/trunk/test/Unit/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/Unit/lit.site.cfg.in?rev=178661&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/Unit/lit.site.cfg.in (added)
+++ clang-tools-extra/trunk/test/Unit/lit.site.cfg.in Wed Apr  3 10:11:08 2013
@@ -0,0 +1,6 @@
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+config.extra_tools_obj_dir = "@CLANG_TOOLS_BINARY_DIR@"
+config.target_triple = "@TARGET_TRIPLE@"
+
+lit.load_config(config, "@CLANG_TOOLS_SOURCE_DIR@/test/Unit/lit.cfg")

Added: clang-tools-extra/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/CMakeLists.txt?rev=178661&view=auto
==============================================================================
--- clang-tools-extra/trunk/unittests/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/unittests/CMakeLists.txt Wed Apr  3 10:11:08 2013
@@ -0,0 +1,8 @@
+add_custom_target(ExtraToolsUnitTests)
+set_target_properties(ExtraToolsUnitTests PROPERTIES FOLDER "Extra Tools Unit Tests")
+
+function(add_extra_unittest test_dirname)
+  add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN})
+endfunction()
+
+add_subdirectory(cpp11-migrate)

Added: clang-tools-extra/trunk/unittests/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/Makefile?rev=178661&view=auto
==============================================================================
--- clang-tools-extra/trunk/unittests/Makefile (added)
+++ clang-tools-extra/trunk/unittests/Makefile Wed Apr  3 10:11:08 2013
@@ -0,0 +1,15 @@
+##===- tools/extra/test/Unit/Makefile ----------------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+CLANG_LEVEL := ../../..
+include $(CLANG_LEVEL)/../../Makefile.config
+
+PARALLEL_DIRS := cpp11-migrate
+
+include $(CLANG_LEVEL)/Makefile

Added: clang-tools-extra/trunk/unittests/cpp11-migrate/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/cpp11-migrate/CMakeLists.txt?rev=178661&view=auto
==============================================================================
--- clang-tools-extra/trunk/unittests/cpp11-migrate/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/unittests/cpp11-migrate/CMakeLists.txt Wed Apr  3 10:11:08 2013
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS
+  support
+  )
+
+add_extra_unittest(Cpp11MigrateTests
+  dummy.cpp)
+
+target_link_libraries(Cpp11MigrateTests
+  clangTooling
+  clangBasic
+  clangASTMatchers
+  )
+

Added: clang-tools-extra/trunk/unittests/cpp11-migrate/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/cpp11-migrate/Makefile?rev=178661&view=auto
==============================================================================
--- clang-tools-extra/trunk/unittests/cpp11-migrate/Makefile (added)
+++ clang-tools-extra/trunk/unittests/cpp11-migrate/Makefile Wed Apr  3 10:11:08 2013
@@ -0,0 +1,22 @@
+##===- unittests/cpp11-migrate/Makefile --------------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+CLANG_LEVEL = ../../../..
+include $(CLANG_LEVEL)/../../Makefile.config
+
+TESTNAME = Cpp11MigrateTests
+LINK_COMPONENTS := asmparser bitreader support mc
+USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \
+		   clangRewriteFrontend.a clangRewriteCore.a clangParse.a \
+		   clangSema.a clangAnalysis.a \
+		   clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a
+
+include $(CLANG_LEVEL)/Makefile
+MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1
+include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest

Added: clang-tools-extra/trunk/unittests/cpp11-migrate/dummy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/cpp11-migrate/dummy.cpp?rev=178661&view=auto
==============================================================================
--- clang-tools-extra/trunk/unittests/cpp11-migrate/dummy.cpp (added)
+++ clang-tools-extra/trunk/unittests/cpp11-migrate/dummy.cpp Wed Apr  3 10:11:08 2013
@@ -0,0 +1,6 @@
+#include "gtest/gtest.h"
+
+// FIXME: Replace this test with something more meaningful.
+TEST(SimpleTest, Test) {
+  ASSERT_TRUE(true);
+}





More information about the cfe-commits mailing list