[orc] Add a trivial unit test to get the ball rolling
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 23 Feb 2015 00:36:25 +0000 (00:36 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 23 Feb 2015 00:36:25 +0000 (00:36 +0000)
I made my best guess at the Makefile, since I don't have a make build.

I'm not sure if it should be valid to add an empty list of things, but
it seemed the sort of degenerate case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230196 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
unittests/ExecutionEngine/CMakeLists.txt
unittests/ExecutionEngine/Makefile
unittests/ExecutionEngine/Orc/CMakeLists.txt [new file with mode: 0644]
unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp [new file with mode: 0644]
unittests/ExecutionEngine/Orc/Makefile [new file with mode: 0644]

index 734b7dd74c0209ea439da40cc61890de70665424..2a94abe33fc9913bee4c5f806e92ff4d0b6a1285 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
 #include "llvm/IR/GlobalValue.h"
 #include "llvm/IR/Mangler.h"
+#include "llvm/IR/Module.h"
 #include "llvm/ADT/StringMap.h"
 #include <list>
 
index 05e093e0c0b4001c14cebea58772a86eb485176f..302de9943ffe4c3e3e4095e1aab940503e57332e 100644 (file)
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   ExecutionEngine
   Interpreter
   MC
+  OrcJIT
   RuntimeDyld
   Support
   )
@@ -11,6 +12,8 @@ add_llvm_unittest(ExecutionEngineTests
   ExecutionEngineTest.cpp
   )
 
+add_subdirectory(Orc)
+
 # Include MCJIT tests only if native arch is a built JIT target.
 list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" build_idx)
 list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" jit_idx)
index 8ecb883ba9d7d2949af045e0b4ce1c640030b9da..1c7a125af280414c82c803854206270479eba9c1 100644 (file)
@@ -13,8 +13,10 @@ LINK_COMPONENTS :=interpreter
 
 include $(LEVEL)/Makefile.config
 
+PARALLEL_DIRS = Orc
+
 ifeq ($(TARGET_HAS_JIT),1)
-  PARALLEL_DIRS = MCJIT
+  PARALLEL_DIRS = $(PARALLEL_DIRS) MCJIT
 endif
 
 include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/unittests/ExecutionEngine/Orc/CMakeLists.txt b/unittests/ExecutionEngine/Orc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7bc13a1
--- /dev/null
@@ -0,0 +1,8 @@
+set(LLVM_LINK_COMPONENTS
+  Core
+  Support
+  )
+
+add_llvm_unittest(OrcJITTests
+  LazyEmittingLayerTest.cpp
+  )
diff --git a/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp b/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp
new file mode 100644 (file)
index 0000000..b0ff127
--- /dev/null
@@ -0,0 +1,30 @@
+//===- LazyEmittingLayerTest.cpp - Unit tests for the lazy emitting layer -===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
+#include "gtest/gtest.h"
+
+namespace {
+
+struct MockBaseLayer {
+  typedef int ModuleSetHandleT;
+  ModuleSetHandleT addModuleSet(std::list<std::unique_ptr<llvm::Module>>,
+                                std::unique_ptr<llvm::RTDyldMemoryManager> x) {
+    EXPECT_FALSE(x);
+    return 42;
+  }
+};
+
+TEST(LazyEmittingLayerTest, Empty) {
+  MockBaseLayer M;
+  llvm::orc::LazyEmittingLayer<MockBaseLayer> L(M);
+  L.addModuleSet(std::list<std::unique_ptr<llvm::Module>>(), nullptr);
+}
+
+}
diff --git a/unittests/ExecutionEngine/Orc/Makefile b/unittests/ExecutionEngine/Orc/Makefile
new file mode 100644 (file)
index 0000000..c899728
--- /dev/null
@@ -0,0 +1,16 @@
+##===- unittests/ExecutionEngine/Orc/Makefile --------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../../..
+TESTNAME = OrcJIT
+LINK_COMPONENTS := core ipo mcjit orcjit native support
+
+include $(LEVEL)/Makefile.config
+include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
+