aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/SmallPtrSetTest.cpp55
-rw-r--r--unittests/ExecutionEngine/CMakeLists.txt8
-rw-r--r--unittests/ExecutionEngine/Makefile5
-rw-r--r--unittests/Support/ManagedStatic.cpp2
-rw-r--r--unittests/Support/Path.cpp13
5 files changed, 79 insertions, 4 deletions
diff --git a/unittests/ADT/SmallPtrSetTest.cpp b/unittests/ADT/SmallPtrSetTest.cpp
index 9114875e00..f85d7c941e 100644
--- a/unittests/ADT/SmallPtrSetTest.cpp
+++ b/unittests/ADT/SmallPtrSetTest.cpp
@@ -17,6 +17,61 @@
using namespace llvm;
// SmallPtrSet swapping test.
+TEST(SmallPtrSetTest, GrowthTest) {
+ int i;
+ int buf[8];
+ for(i=0; i<8; ++i) buf[i]=0;
+
+
+ SmallPtrSet<int *, 4> s;
+ typedef SmallPtrSet<int *, 4>::iterator iter;
+
+ s.insert(&buf[0]);
+ s.insert(&buf[1]);
+ s.insert(&buf[2]);
+ s.insert(&buf[3]);
+ EXPECT_EQ(4U, s.size());
+
+ i = 0;
+ for(iter I=s.begin(), E=s.end(); I!=E; ++I, ++i)
+ (**I)++;
+ EXPECT_EQ(4, i);
+ for(i=0; i<8; ++i)
+ EXPECT_EQ(i<4?1:0,buf[i]);
+
+ s.insert(&buf[4]);
+ s.insert(&buf[5]);
+ s.insert(&buf[6]);
+ s.insert(&buf[7]);
+
+ i = 0;
+ for(iter I=s.begin(), E=s.end(); I!=E; ++I, ++i)
+ (**I)++;
+ EXPECT_EQ(8, i);
+ s.erase(&buf[4]);
+ s.erase(&buf[5]);
+ s.erase(&buf[6]);
+ s.erase(&buf[7]);
+ EXPECT_EQ(4U, s.size());
+
+ i = 0;
+ for(iter I=s.begin(), E=s.end(); I!=E; ++I, ++i)
+ (**I)++;
+ EXPECT_EQ(4, i);
+ for(i=0; i<8; ++i)
+ EXPECT_EQ(i<4?3:1,buf[i]);
+
+ s.clear();
+ for(i=0; i<8; ++i) buf[i]=0;
+ for(i=0; i<128; ++i) s.insert(&buf[i%8]); // test repeated entires
+ EXPECT_EQ(8U, s.size());
+ for(iter I=s.begin(), E=s.end(); I!=E; ++I, ++i)
+ (**I)++;
+ for(i=0; i<8; ++i)
+ EXPECT_EQ(1,buf[i]);
+}
+
+
TEST(SmallPtrSetTest, SwapTest) {
int buf[10];
diff --git a/unittests/ExecutionEngine/CMakeLists.txt b/unittests/ExecutionEngine/CMakeLists.txt
index ed7f10a23c..4eefc1e3bb 100644
--- a/unittests/ExecutionEngine/CMakeLists.txt
+++ b/unittests/ExecutionEngine/CMakeLists.txt
@@ -6,5 +6,9 @@ add_llvm_unittest(ExecutionEngineTests
ExecutionEngineTest.cpp
)
-add_subdirectory(JIT)
-add_subdirectory(MCJIT)
+# Include JIT/MCJIT tests only if native arch is a JIT target.
+list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" have_jit)
+if (NOT have_jit EQUAL -1 )
+ add_subdirectory(JIT)
+ add_subdirectory(MCJIT)
+endif()
diff --git a/unittests/ExecutionEngine/Makefile b/unittests/ExecutionEngine/Makefile
index ca1195631a..c779a6a47c 100644
--- a/unittests/ExecutionEngine/Makefile
+++ b/unittests/ExecutionEngine/Makefile
@@ -10,7 +10,10 @@
LEVEL = ../..
TESTNAME = ExecutionEngine
LINK_COMPONENTS :=interpreter
-PARALLEL_DIRS = JIT MCJIT
+
+ifeq ($(TARGET_HAS_JIT),1)
+ PARALLEL_DIRS = JIT MCJIT
+endif
include $(LEVEL)/Makefile.config
include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/unittests/Support/ManagedStatic.cpp b/unittests/Support/ManagedStatic.cpp
index a4137619f4..8ddad38ecf 100644
--- a/unittests/Support/ManagedStatic.cpp
+++ b/unittests/Support/ManagedStatic.cpp
@@ -19,7 +19,7 @@ using namespace llvm;
namespace {
-#ifdef HAVE_PTHREAD_H
+#if defined(HAVE_PTHREAD_H) && !__has_feature(memory_sanitizer)
namespace test1 {
llvm::ManagedStatic<int> ms;
void *helper(void*) {
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index 878c22796a..4511259797 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -224,6 +224,18 @@ TEST_F(FileSystemTest, TempFiles) {
// Make sure Temp1 doesn't exist.
ASSERT_NO_ERROR(fs::exists(Twine(TempPath), TempFileExists));
EXPECT_FALSE(TempFileExists);
+
+#ifdef LLVM_ON_WIN32
+ // Path name > 260 chars should get an error.
+ const char *Path270 =
+ "abcdefghijklmnopqrstuvwxyz9abcdefghijklmnopqrstuvwxyz8"
+ "abcdefghijklmnopqrstuvwxyz7abcdefghijklmnopqrstuvwxyz6"
+ "abcdefghijklmnopqrstuvwxyz5abcdefghijklmnopqrstuvwxyz4"
+ "abcdefghijklmnopqrstuvwxyz3abcdefghijklmnopqrstuvwxyz2"
+ "abcdefghijklmnopqrstuvwxyz1abcdefghijklmnopqrstuvwxyz0";
+ EXPECT_EQ(fs::unique_file(Twine(Path270), FileDescriptor, TempPath),
+ windows_error::path_not_found);
+#endif
}
TEST_F(FileSystemTest, DirectoryIteration) {
@@ -350,6 +362,7 @@ TEST_F(FileSystemTest, FileMapping) {
StringRef Val("hello there");
{
fs::mapped_file_region mfr(FileDescriptor,
+ true,
fs::mapped_file_region::readwrite,
4096,
0,