summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support
diff options
context:
space:
mode:
authorTorok Edwin <edwintorok@gmail.com>2010-01-22 15:51:31 +0000
committerTorok Edwin <edwintorok@gmail.com>2010-01-22 15:51:31 +0000
commitfbcd2c76d52a9b91dc657d16be0e2b101ddc1f59 (patch)
tree488695a6929237b39739766b70ab758e7893420f /llvm/unittests/Support
parent0599df16a69d42bf5f2c4951712f9011a6dc2610 (diff)
downloadbcm5719-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')
-rw-r--r--llvm/unittests/Support/System.cpp16
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);
+}
+}
OpenPOWER on IntegriCloud