unittests: Add SystemTests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120101 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael J. Spencer 2010-11-24 19:20:05 +00:00
parent bf8209daf8
commit f2ca4cb86d
6 changed files with 70 additions and 18 deletions

View 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
)

View 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

View File

@ -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);
}
}

15
unittests/System/Makefile Normal file
View File

@ -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

18
unittests/System/Path.cpp Normal file
View File

@ -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

View File

@ -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);
}
}