unittests: Add SystemTests.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Wed, 24 Nov 2010 19:20:05 +0000 (19:20 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Wed, 24 Nov 2010 19:20:05 +0000 (19:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120101 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/CMakeLists.txt
unittests/Makefile
unittests/Support/System.cpp [deleted file]
unittests/System/Makefile [new file with mode: 0644]
unittests/System/Path.cpp [new file with mode: 0644]
unittests/System/TimeValue.cpp [new file with mode: 0644]

index 76b76f2b88f0856fbd9075e80f9d80080017bece..41e20cfc902df7bfedbe785d9c7cde2ba8199a17 100644 (file)
@@ -17,6 +17,9 @@ add_custom_target(UnitTests)
 
 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
 add_definitions(-DGTEST_HAS_RTTI=0)
+if (NOT LLVM_ENABLE_THREADS)
+  add_definitions(-DGTEST_HAS_PTHREAD=0)
+endif()
 
 set(LLVM_LINK_COMPONENTS
   jit
@@ -33,6 +36,7 @@ set(LLVM_LINK_COMPONENTS
 set(LLVM_USED_LIBS
   gtest
   gtest_main
+  LLVMSupport # gtest needs it for raw_ostream.
   )
 
 add_llvm_unittest(ADT
@@ -117,7 +121,15 @@ add_llvm_unittest(Support
   Support/raw_ostream_test.cpp
   Support/RegexTest.cpp
   Support/SwapByteOrderTest.cpp
-  Support/System.cpp
   Support/TypeBuilderTest.cpp
   Support/ValueHandleTest.cpp
   )
+
+set(LLVM_LINK_COMPONENTS
+  System
+  )
+
+add_llvm_unittest(System
+  System/Path.cpp
+  System/TimeValue.cpp
+  )
index 0401cd1c673a2100da6ce9ef2048e0cd05f9d1c6..71ba552326678919f4ad2ca63d05f10d17c57a5c 100644 (file)
@@ -9,7 +9,7 @@
 
 LEVEL = ..
 
-PARALLEL_DIRS = ADT ExecutionEngine Support Transforms VMCore Analysis
+PARALLEL_DIRS = ADT ExecutionEngine Support System Transforms VMCore Analysis
 
 include $(LEVEL)/Makefile.common
 
diff --git a/unittests/Support/System.cpp b/unittests/Support/System.cpp
deleted file mode 100644 (file)
index 5fa7b39..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-//===- llvm/unittest/Support/System.cpp - System tests --===//
-#include "gtest/gtest.h"
-#include "llvm/System/TimeValue.h"
-#include <time.h>
-
-using namespace llvm;
-namespace {
-class SystemTest : public ::testing::Test {
-};
-
-TEST_F(SystemTest, TimeValue) {
-  sys::TimeValue now = sys::TimeValue::now();
-  time_t now_t = time(NULL);
-  EXPECT_TRUE(abs(static_cast<long>(now_t - now.toEpochTime())) < 2);
-}
-}
diff --git a/unittests/System/Makefile b/unittests/System/Makefile
new file mode 100644 (file)
index 0000000..336ac30
--- /dev/null
@@ -0,0 +1,15 @@
+##===- unittests/System/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 = System
+LINK_COMPONENTS := system
+
+include $(LEVEL)/Makefile.config
+include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/unittests/System/Path.cpp b/unittests/System/Path.cpp
new file mode 100644 (file)
index 0000000..85fbb61
--- /dev/null
@@ -0,0 +1,18 @@
+//===- llvm/unittest/System/Path.cpp - Path tests -------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+
+namespace {
+
+TEST(System, Path) {
+  // TODO: Add tests!
+}
+
+} // anonymous namespace
diff --git a/unittests/System/TimeValue.cpp b/unittests/System/TimeValue.cpp
new file mode 100644 (file)
index 0000000..d1da5c1
--- /dev/null
@@ -0,0 +1,23 @@
+//===- llvm/unittest/System/TimeValue.cpp - Time Vlaue tests --------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+#include "llvm/System/TimeValue.h"
+#include <time.h>
+
+using namespace llvm;
+namespace {
+
+TEST(System, TimeValue) {
+  sys::TimeValue now = sys::TimeValue::now();
+  time_t now_t = time(NULL);
+  EXPECT_TRUE(abs(static_cast<long>(now_t - now.toEpochTime())) < 2);
+}
+
+}