diff options
author | Torok Edwin <edwintorok@gmail.com> | 2010-01-22 15:51:31 +0000 |
---|---|---|
committer | Torok Edwin <edwintorok@gmail.com> | 2010-01-22 15:51:31 +0000 |
commit | fbcd2c76d52a9b91dc657d16be0e2b101ddc1f59 (patch) | |
tree | 488695a6929237b39739766b70ab758e7893420f /llvm/unittests/Support/System.cpp | |
parent | 0599df16a69d42bf5f2c4951712f9011a6dc2610 (diff) | |
download | bcm5719-llvm-fbcd2c76d52a9b91dc657d16be0e2b101ddc1f59.tar.gz bcm5719-llvm-fbcd2c76d52a9b91dc657d16be0e2b101ddc1f59.zip |
Fix TimeValue::now() on Unix.
TimeValue()::now().toEpochTime() is supposed to be the same as time(),
but it wasn't, because toEpoch subtracted PosixZeroTime, but now()
didn't add PosixZeroTime!
Add a unittest to check this works.
llvm-svn: 94178
Diffstat (limited to 'llvm/unittests/Support/System.cpp')
-rw-r--r-- | llvm/unittests/Support/System.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/unittests/Support/System.cpp b/llvm/unittests/Support/System.cpp new file mode 100644 index 00000000000..b3dd17d380d --- /dev/null +++ b/llvm/unittests/Support/System.cpp @@ -0,0 +1,16 @@ +//===- 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(now_t - now.toEpochTime()) < 2); +} +} |