[flang-commits] [PATCH] D80377: [flang] Google test infrastructure support for unittests

sameeran joshi via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu May 21 07:31:21 PDT 2020


sameeranjoshi created this revision.
sameeranjoshi added reviewers: richard.barton.arm, kiranchandramohan, jeanPerier, schweitz, Andrzej.
sameeranjoshi added a project: Flang.
Herald added subscribers: llvm-commits, aartbik, mgorny.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: DavidTruby.
Herald added a reviewer: sscalpone.
Herald added a project: LLVM.
sameeranjoshi added a comment.

I can't see any gtests running after executing target `check-flang-unit`. As the tests is expected to throw error.
Furthermore I can see executable created in `tools/flang/unittests/Optimizer/FlangOptimizerTests` which on executing gives the expected results.

Am I missing some small change?


Added basic gtest for InternalNames.cpp(More rework will be done once the infrastructure is in)
Added target check-flang-unit given -DFLANG_INCLUDE_TESTS=ON.

This patch provides to some extent basic infrastructure support for https://github.com/flang-compiler/f18/issues/995


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80377

Files:
  flang/unittests/CMakeLists.txt
  flang/unittests/Optimizer/CMakeLists.txt
  flang/unittests/Optimizer/InternalNamesTest.cpp


Index: flang/unittests/Optimizer/InternalNamesTest.cpp
===================================================================
--- /dev/null
+++ flang/unittests/Optimizer/InternalNamesTest.cpp
@@ -0,0 +1,18 @@
+#include "flang/Optimizer/Support/InternalNames.h"
+#include <gtest/gtest.h>
+
+using namespace fir;
+using namespace llvm;
+
+TEST(genericName, MyTest) {
+        NameUniquer obj;
+        std::string val = obj.doCommonBlock("hello");
+	std::string val2 = "hello";
+	EXPECT_EQ(val, val2);
+}
+
+int main(int argc, char **argv) {
+  testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
+
Index: flang/unittests/Optimizer/CMakeLists.txt
===================================================================
--- /dev/null
+++ flang/unittests/Optimizer/CMakeLists.txt
@@ -0,0 +1,13 @@
+get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
+
+set(LIBS
+  FIRDialect
+  ${dialect_libs}
+)
+
+add_flang_unittest(FlangOptimizerTests
+  InternalNamesTest.cpp
+)
+target_link_libraries(FlangOptimizerTests
+  PRIVATE
+  ${LIBS})
Index: flang/unittests/CMakeLists.txt
===================================================================
--- flang/unittests/CMakeLists.txt
+++ flang/unittests/CMakeLists.txt
@@ -1,3 +1,12 @@
+add_custom_target(check-flang-unit)
+set_target_properties(check-flang-unit PROPERTIES FOLDER "Flang Unit Tests")
+
+function(add_flang_unittest test_dirname)
+  add_unittest(check-flang-unit ${test_dirname} ${ARGN})
+endfunction()
+
+add_subdirectory(Optimizer)
+
 add_subdirectory(Decimal)
 add_subdirectory(Evaluate)
 add_subdirectory(Runtime)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80377.265500.patch
Type: text/x-patch
Size: 1589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200521/b971aa0d/attachment.bin>


More information about the flang-commits mailing list