diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-11-24 19:20:05 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-11-24 19:20:05 +0000 |
commit | f2ca4cb86df1d38c439f35774210b16f36841531 (patch) | |
tree | 1e34e5b1f175a61d12fc3664b0aa889717c8dc00 | |
parent | bf8209daf875fa533a379290a91d01be5152597d (diff) |
unittests: Add SystemTests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120101 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | unittests/CMakeLists.txt | 14 | ||||
-rw-r--r-- | unittests/Makefile | 2 | ||||
-rw-r--r-- | unittests/Support/System.cpp | 16 | ||||
-rw-r--r-- | unittests/System/Makefile | 15 | ||||
-rw-r--r-- | unittests/System/Path.cpp | 18 | ||||
-rw-r--r-- | unittests/System/TimeValue.cpp | 23 |
6 files changed, 70 insertions, 18 deletions
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 76b76f2b88f..41e20cfc902 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -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 + ) diff --git a/unittests/Makefile b/unittests/Makefile index 0401cd1c673..71ba5523266 100644 --- a/unittests/Makefile +++ b/unittests/Makefile @@ -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 index 5fa7b391838..00000000000 --- a/unittests/Support/System.cpp +++ /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 index 00000000000..336ac30383d --- /dev/null +++ b/unittests/System/Makefile @@ -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 index 00000000000..85fbb6124bd --- /dev/null +++ b/unittests/System/Path.cpp @@ -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 index 00000000000..d1da5c14ee6 --- /dev/null +++ b/unittests/System/TimeValue.cpp @@ -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); +} + +} |