diff options
Diffstat (limited to 'unittests/Support')
-rw-r--r-- | unittests/Support/ConstantRangeTest.cpp | 54 | ||||
-rw-r--r-- | unittests/Support/EndianTest.cpp | 72 | ||||
-rw-r--r-- | unittests/Support/Path.cpp | 253 | ||||
-rw-r--r-- | unittests/Support/SwapByteOrderTest.cpp | 128 | ||||
-rw-r--r-- | unittests/Support/System.cpp | 16 | ||||
-rw-r--r-- | unittests/Support/TimeValue.cpp | 23 | ||||
-rw-r--r-- | unittests/Support/ValueHandleTest.cpp | 4 |
7 files changed, 518 insertions, 32 deletions
diff --git a/unittests/Support/ConstantRangeTest.cpp b/unittests/Support/ConstantRangeTest.cpp index 091ecd4a..161e2cf 100644 --- a/unittests/Support/ConstantRangeTest.cpp +++ b/unittests/Support/ConstantRangeTest.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/ConstantRange.h" +#include "llvm/Instructions.h" #include "gtest/gtest.h" @@ -146,6 +147,22 @@ TEST_F(ConstantRangeTest, GetMinsAndMaxes) { APInt(4, 7)); } +TEST_F(ConstantRangeTest, SignWrapped) { + EXPECT_TRUE(Full.isSignWrappedSet()); + EXPECT_FALSE(Empty.isSignWrappedSet()); + EXPECT_FALSE(One.isSignWrappedSet()); + EXPECT_FALSE(Some.isSignWrappedSet()); + EXPECT_TRUE(Wrap.isSignWrappedSet()); + + EXPECT_FALSE(ConstantRange(APInt(8, 127), APInt(8, 128)).isSignWrappedSet()); + EXPECT_TRUE(ConstantRange(APInt(8, 127), APInt(8, 129)).isSignWrappedSet()); + EXPECT_FALSE(ConstantRange(APInt(8, 128), APInt(8, 129)).isSignWrappedSet()); + EXPECT_TRUE(ConstantRange(APInt(8, 10), APInt(8, 9)).isSignWrappedSet()); + EXPECT_TRUE(ConstantRange(APInt(8, 10), APInt(8, 250)).isSignWrappedSet()); + EXPECT_FALSE(ConstantRange(APInt(8, 250), APInt(8, 10)).isSignWrappedSet()); + EXPECT_FALSE(ConstantRange(APInt(8, 250), APInt(8, 251)).isSignWrappedSet()); +} + TEST_F(ConstantRangeTest, Trunc) { ConstantRange TFull = Full.truncate(10); ConstantRange TEmpty = Empty.truncate(10); @@ -154,8 +171,8 @@ TEST_F(ConstantRangeTest, Trunc) { ConstantRange TWrap = Wrap.truncate(10); EXPECT_TRUE(TFull.isFullSet()); EXPECT_TRUE(TEmpty.isEmptySet()); - EXPECT_EQ(TOne, ConstantRange(APInt(One.getLower()).trunc(10), - APInt(One.getUpper()).trunc(10))); + EXPECT_EQ(TOne, ConstantRange(One.getLower().trunc(10), + One.getUpper().trunc(10))); EXPECT_TRUE(TSome.isFullSet()); } @@ -167,12 +184,11 @@ TEST_F(ConstantRangeTest, ZExt) { ConstantRange ZWrap = Wrap.zeroExtend(20); EXPECT_EQ(ZFull, ConstantRange(APInt(20, 0), APInt(20, 0x10000))); EXPECT_TRUE(ZEmpty.isEmptySet()); - EXPECT_EQ(ZOne, ConstantRange(APInt(One.getLower()).zext(20), - APInt(One.getUpper()).zext(20))); - EXPECT_EQ(ZSome, ConstantRange(APInt(Some.getLower()).zext(20), - APInt(Some.getUpper()).zext(20))); - EXPECT_EQ(ZWrap, ConstantRange(APInt(Wrap.getLower()).zext(20), - APInt(Wrap.getUpper()).zext(20))); + EXPECT_EQ(ZOne, ConstantRange(One.getLower().zext(20), + One.getUpper().zext(20))); + EXPECT_EQ(ZSome, ConstantRange(Some.getLower().zext(20), + Some.getUpper().zext(20))); + EXPECT_EQ(ZWrap, ConstantRange(APInt(20, 0), APInt(20, 0x10000))); } TEST_F(ConstantRangeTest, SExt) { @@ -184,12 +200,15 @@ TEST_F(ConstantRangeTest, SExt) { EXPECT_EQ(SFull, ConstantRange(APInt(20, (uint64_t)INT16_MIN, true), APInt(20, INT16_MAX + 1, true))); EXPECT_TRUE(SEmpty.isEmptySet()); - EXPECT_EQ(SOne, ConstantRange(APInt(One.getLower()).sext(20), - APInt(One.getUpper()).sext(20))); - EXPECT_EQ(SSome, ConstantRange(APInt(Some.getLower()).sext(20), - APInt(Some.getUpper()).sext(20))); - EXPECT_EQ(SWrap, ConstantRange(APInt(Wrap.getLower()).sext(20), - APInt(Wrap.getUpper()).sext(20))); + EXPECT_EQ(SOne, ConstantRange(One.getLower().sext(20), + One.getUpper().sext(20))); + EXPECT_EQ(SSome, ConstantRange(Some.getLower().sext(20), + Some.getUpper().sext(20))); + EXPECT_EQ(SWrap, ConstantRange(APInt(20, (uint64_t)INT16_MIN, true), + APInt(20, INT16_MAX + 1, true))); + + EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, 140)).signExtend(16), + ConstantRange(APInt(16, -128), APInt(16, 128))); } TEST_F(ConstantRangeTest, IntersectWith) { @@ -411,4 +430,11 @@ TEST_F(ConstantRangeTest, Lshr) { EXPECT_EQ(Wrap.lshr(Wrap), Full); } +TEST(ConstantRange, MakeICmpRegion) { + // PR8250 + ConstantRange SMax = ConstantRange(APInt::getSignedMaxValue(32)); + EXPECT_TRUE(ConstantRange::makeICmpRegion(ICmpInst::ICMP_SGT, + SMax).isEmptySet()); +} + } // anonymous namespace diff --git a/unittests/Support/EndianTest.cpp b/unittests/Support/EndianTest.cpp new file mode 100644 index 0000000..6fe0247 --- /dev/null +++ b/unittests/Support/EndianTest.cpp @@ -0,0 +1,72 @@ +//===- unittests/Support/EndianTest.cpp - Endian.h 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/Support/Endian.h" +#include "llvm/Support/DataTypes.h" +#include <cstdlib> +#include <ctime> +using namespace llvm; +using namespace support; + +#undef max + +namespace { + +TEST(Endian, Read) { + // These are 5 bytes so we can be sure at least one of the reads is unaligned. + unsigned char big[] = {0x00, 0x01, 0x02, 0x03, 0x04}; + unsigned char little[] = {0x00, 0x04, 0x03, 0x02, 0x01}; + int32_t BigAsHost = 0x00010203; + EXPECT_EQ(BigAsHost, (endian::read_be<int32_t, unaligned>(big))); + int32_t LittleAsHost = 0x02030400; + EXPECT_EQ(LittleAsHost, (endian::read_le<int32_t, unaligned>(little))); + + EXPECT_EQ((endian::read_be<int32_t, unaligned>(big + 1)), + (endian::read_le<int32_t, unaligned>(little + 1))); +} + +TEST(Endian, Write) { + unsigned char data[5]; + endian::write_be<int32_t, unaligned>(data, -1362446643); + EXPECT_EQ(data[0], 0xAE); + EXPECT_EQ(data[1], 0xCA); + EXPECT_EQ(data[2], 0xB6); + EXPECT_EQ(data[3], 0xCD); + endian::write_be<int32_t, unaligned>(data + 1, -1362446643); + EXPECT_EQ(data[1], 0xAE); + EXPECT_EQ(data[2], 0xCA); + EXPECT_EQ(data[3], 0xB6); + EXPECT_EQ(data[4], 0xCD); + + endian::write_le<int32_t, unaligned>(data, -1362446643); + EXPECT_EQ(data[0], 0xCD); + EXPECT_EQ(data[1], 0xB6); + EXPECT_EQ(data[2], 0xCA); + EXPECT_EQ(data[3], 0xAE); + endian::write_le<int32_t, unaligned>(data + 1, -1362446643); + EXPECT_EQ(data[1], 0xCD); + EXPECT_EQ(data[2], 0xB6); + EXPECT_EQ(data[3], 0xCA); + EXPECT_EQ(data[4], 0xAE); +} + +TEST(Endian, PackedEndianSpecificIntegral) { + // These are 5 bytes so we can be sure at least one of the reads is unaligned. + unsigned char big[] = {0x00, 0x01, 0x02, 0x03, 0x04}; + unsigned char little[] = {0x00, 0x04, 0x03, 0x02, 0x01}; + big32_t *big_val = + reinterpret_cast<big32_t *>(big + 1); + little32_t *little_val = + reinterpret_cast<little32_t *>(little + 1); + + EXPECT_EQ(*big_val, *little_val); +} + +} diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp new file mode 100644 index 0000000..60d08bc --- /dev/null +++ b/unittests/Support/Path.cpp @@ -0,0 +1,253 @@ +//===- llvm/unittest/Support/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 "llvm/Support/FileSystem.h" +#include "llvm/Support/PathV2.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" + +#include "gtest/gtest.h" + +using namespace llvm; +using namespace llvm::sys; + +#define ASSERT_NO_ERROR(x) \ + if (error_code ASSERT_NO_ERROR_ec = x) { \ + SmallString<128> MessageStorage; \ + raw_svector_ostream Message(MessageStorage); \ + Message << #x ": did not return errc::success.\n" \ + << "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \ + << "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \ + GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \ + } else {} + +namespace { + +TEST(is_separator, Works) { + EXPECT_TRUE(path::is_separator('/')); + EXPECT_FALSE(path::is_separator('\0')); + EXPECT_FALSE(path::is_separator('-')); + EXPECT_FALSE(path::is_separator(' ')); + +#ifdef LLVM_ON_WIN32 + EXPECT_TRUE(path::is_separator('\\')); +#else + EXPECT_FALSE(path::is_separator('\\')); +#endif +} + +TEST(Support, Path) { + SmallVector<StringRef, 40> paths; + paths.push_back(""); + paths.push_back("."); + paths.push_back(".."); + paths.push_back("foo"); + paths.push_back("/"); + paths.push_back("/foo"); + paths.push_back("foo/"); + paths.push_back("/foo/"); + paths.push_back("foo/bar"); + paths.push_back("/foo/bar"); + paths.push_back("//net"); + paths.push_back("//net/foo"); + paths.push_back("///foo///"); + paths.push_back("///foo///bar"); + paths.push_back("/."); + paths.push_back("./"); + paths.push_back("/.."); + paths.push_back("../"); + paths.push_back("foo/."); + paths.push_back("foo/.."); + paths.push_back("foo/./"); + paths.push_back("foo/./bar"); + paths.push_back("foo/.."); + paths.push_back("foo/../"); + paths.push_back("foo/../bar"); + paths.push_back("c:"); + paths.push_back("c:/"); + paths.push_back("c:foo"); + paths.push_back("c:/foo"); + paths.push_back("c:foo/"); + paths.push_back("c:/foo/"); + paths.push_back("c:/foo/bar"); + paths.push_back("prn:"); + paths.push_back("c:\\"); + paths.push_back("c:foo"); + paths.push_back("c:\\foo"); + paths.push_back("c:foo\\"); + paths.push_back("c:\\foo\\"); + paths.push_back("c:\\foo/"); + paths.push_back("c:/foo\\bar"); + + for (SmallVector<StringRef, 40>::const_iterator i = paths.begin(), + e = paths.end(); + i != e; + ++i) { + for (sys::path::const_iterator ci = sys::path::begin(*i), + ce = sys::path::end(*i); + ci != ce; + ++ci) { + ASSERT_FALSE(ci->empty()); + } + +#if 0 // Valgrind is whining about this. + outs() << " Reverse Iteration: ["; + for (sys::path::reverse_iterator ci = sys::path::rbegin(*i), + ce = sys::path::rend(*i); + ci != ce; + ++ci) { + outs() << *ci << ','; + } + outs() << "]\n"; +#endif + + path::has_root_path(*i); + path::root_path(*i); + path::has_root_name(*i); + path::root_name(*i); + path::has_root_directory(*i); + path::root_directory(*i); + path::has_parent_path(*i); + path::parent_path(*i); + path::has_filename(*i); + path::filename(*i); + path::has_stem(*i); + path::stem(*i); + path::has_extension(*i); + path::extension(*i); + path::is_absolute(*i); + path::is_relative(*i); + + SmallString<128> temp_store; + temp_store = *i; + ASSERT_NO_ERROR(fs::make_absolute(temp_store)); + temp_store = *i; + path::remove_filename(temp_store); + + temp_store = *i; + path::replace_extension(temp_store, "ext"); + StringRef filename(temp_store.begin(), temp_store.size()), stem, ext; + stem = path::stem(filename); + ext = path::extension(filename); + EXPECT_EQ(*(--sys::path::end(filename)), (stem + ext).str()); + + path::native(*i, temp_store); + } +} + +class FileSystemTest : public testing::Test { +protected: + /// Unique temporary directory in which all created filesystem entities must + /// be placed. It is recursively removed at the end of each test. + SmallString<128> TestDirectory; + + virtual void SetUp() { + int fd; + ASSERT_NO_ERROR( + fs::unique_file("file-system-test-%%-%%-%%-%%/test-directory.anchor", fd, + TestDirectory)); + // We don't care about this specific file. + ::close(fd); + TestDirectory = path::parent_path(TestDirectory); + errs() << "Test Directory: " << TestDirectory << '\n'; + errs().flush(); + } + + virtual void TearDown() { + uint32_t removed; + ASSERT_NO_ERROR(fs::remove_all(TestDirectory.str(), removed)); + } +}; + +TEST_F(FileSystemTest, TempFiles) { + // Create a temp file. + int FileDescriptor; + SmallString<64> TempPath; + ASSERT_NO_ERROR( + fs::unique_file("%%-%%-%%-%%.temp", FileDescriptor, TempPath)); + + // Make sure it exists. + bool TempFileExists; + ASSERT_NO_ERROR(sys::fs::exists(Twine(TempPath), TempFileExists)); + EXPECT_TRUE(TempFileExists); + + // Create another temp tile. + int FD2; + SmallString<64> TempPath2; + ASSERT_NO_ERROR(fs::unique_file("%%-%%-%%-%%.temp", FD2, TempPath2)); + ASSERT_NE(TempPath.str(), TempPath2.str()); + + // Try to copy the first to the second. + EXPECT_EQ( + fs::copy_file(Twine(TempPath), Twine(TempPath2)), errc::file_exists); + + ::close(FD2); + // Try again with the proper options. + ASSERT_NO_ERROR(fs::copy_file(Twine(TempPath), Twine(TempPath2), + fs::copy_option::overwrite_if_exists)); + // Remove Temp2. + ASSERT_NO_ERROR(fs::remove(Twine(TempPath2), TempFileExists)); + EXPECT_TRUE(TempFileExists); + + // Make sure Temp2 doesn't exist. + ASSERT_NO_ERROR(fs::exists(Twine(TempPath2), TempFileExists)); + EXPECT_FALSE(TempFileExists); + + // Create a hard link to Temp1. + ASSERT_NO_ERROR(fs::create_hard_link(Twine(TempPath), Twine(TempPath2))); + bool equal; + ASSERT_NO_ERROR(fs::equivalent(Twine(TempPath), Twine(TempPath2), equal)); + EXPECT_TRUE(equal); + + // Remove Temp1. + ::close(FileDescriptor); + ASSERT_NO_ERROR(fs::remove(Twine(TempPath), TempFileExists)); + EXPECT_TRUE(TempFileExists); + + // Remove the hard link. + ASSERT_NO_ERROR(fs::remove(Twine(TempPath2), TempFileExists)); + EXPECT_TRUE(TempFileExists); + + // Make sure Temp1 doesn't exist. + ASSERT_NO_ERROR(fs::exists(Twine(TempPath), TempFileExists)); + EXPECT_FALSE(TempFileExists); +} + +TEST_F(FileSystemTest, DirectoryIteration) { + error_code ec; + for (fs::directory_iterator i(".", ec), e; i != e; i.increment(ec)) + ASSERT_NO_ERROR(ec); +} + +TEST_F(FileSystemTest, Magic) { + struct type { + const char *filename; + const char *magic_str; + size_t magic_str_len; + } types [] = {{"magic.archive", "!<arch>\x0A", 8}}; + + // Create some files filled with magic. + for (type *i = types, *e = types + (sizeof(types) / sizeof(type)); i != e; + ++i) { + SmallString<128> file_pathname(TestDirectory); + path::append(file_pathname, i->filename); + std::string ErrMsg; + raw_fd_ostream file(file_pathname.c_str(), ErrMsg, + raw_fd_ostream::F_Binary); + ASSERT_FALSE(file.has_error()); + StringRef magic(i->magic_str, i->magic_str_len); + file << magic; + file.close(); + bool res = false; + ASSERT_NO_ERROR(fs::has_magic(file_pathname.c_str(), magic, res)); + EXPECT_TRUE(res); + } +} + +} // anonymous namespace diff --git a/unittests/Support/SwapByteOrderTest.cpp b/unittests/Support/SwapByteOrderTest.cpp new file mode 100644 index 0000000..c2a0c27 --- /dev/null +++ b/unittests/Support/SwapByteOrderTest.cpp @@ -0,0 +1,128 @@ +//===- unittests/Support/SwapByteOrderTest.cpp - swap byte order test -----===// +// +// 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/Support/SwapByteOrder.h" +#include <cstdlib> +#include <ctime> +using namespace llvm; + +#undef max + +namespace { + +// In these first two tests all of the origional_uintx values are truncated +// except for 64. We could avoid this, but there's really no point. + +TEST(SwapByteOrder, UnsignedRoundTrip) { + // The point of the bit twiddling of magic is to test with and without bits + // in every byte. + uint64_t value = 1; + for (std::size_t i = 0; i <= sizeof(value); ++i) { + uint8_t origional_uint8 = static_cast<uint8_t>(value); + EXPECT_EQ(origional_uint8, + sys::SwapByteOrder(sys::SwapByteOrder(origional_uint8))); + + uint16_t origional_uint16 = static_cast<uint16_t>(value); + EXPECT_EQ(origional_uint16, + sys::SwapByteOrder(sys::SwapByteOrder(origional_uint16))); + + uint32_t origional_uint32 = static_cast<uint32_t>(value); + EXPECT_EQ(origional_uint32, + sys::SwapByteOrder(sys::SwapByteOrder(origional_uint32))); + + uint64_t origional_uint64 = static_cast<uint64_t>(value); + EXPECT_EQ(origional_uint64, + sys::SwapByteOrder(sys::SwapByteOrder(origional_uint64))); + + value = (value << 8) | 0x55; // binary 0101 0101. + } +} + +TEST(SwapByteOrder, SignedRoundTrip) { + // The point of the bit twiddling of magic is to test with and without bits + // in every byte. + uint64_t value = 1; + for (std::size_t i = 0; i <= sizeof(value); ++i) { + int8_t origional_int8 = static_cast<int8_t>(value); + EXPECT_EQ(origional_int8, + sys::SwapByteOrder(sys::SwapByteOrder(origional_int8))); + + int16_t origional_int16 = static_cast<int16_t>(value); + EXPECT_EQ(origional_int16, + sys::SwapByteOrder(sys::SwapByteOrder(origional_int16))); + + int32_t origional_int32 = static_cast<int32_t>(value); + EXPECT_EQ(origional_int32, + sys::SwapByteOrder(sys::SwapByteOrder(origional_int32))); + + int64_t origional_int64 = static_cast<int64_t>(value); + EXPECT_EQ(origional_int64, + sys::SwapByteOrder(sys::SwapByteOrder(origional_int64))); + + // Test other sign. + value *= -1; + + origional_int8 = static_cast<int8_t>(value); + EXPECT_EQ(origional_int8, + sys::SwapByteOrder(sys::SwapByteOrder(origional_int8))); + + origional_int16 = static_cast<int16_t>(value); + EXPECT_EQ(origional_int16, + sys::SwapByteOrder(sys::SwapByteOrder(origional_int16))); + + origional_int32 = static_cast<int32_t>(value); + EXPECT_EQ(origional_int32, + sys::SwapByteOrder(sys::SwapByteOrder(origional_int32))); + + origional_int64 = static_cast<int64_t>(value); + EXPECT_EQ(origional_int64, + sys::SwapByteOrder(sys::SwapByteOrder(origional_int64))); + + // Return to normal sign and twiddle. + value *= -1; + value = (value << 8) | 0x55; // binary 0101 0101. + } +} + +TEST(SwapByteOrder, uint8_t) { + EXPECT_EQ(uint8_t(0x11), sys::SwapByteOrder(uint8_t(0x11))); +} + +TEST(SwapByteOrder, uint16_t) { + EXPECT_EQ(uint16_t(0x1122), sys::SwapByteOrder(uint16_t(0x2211))); +} + +TEST(SwapByteOrder, uint32_t) { + EXPECT_EQ(uint32_t(0x11223344), sys::SwapByteOrder(uint32_t(0x44332211))); +} + +TEST(SwapByteOrder, uint64_t) { + EXPECT_EQ(uint64_t(0x1122334455667788ULL), + sys::SwapByteOrder(uint64_t(0x8877665544332211ULL))); +} + +TEST(SwapByteOrder, int8_t) { + EXPECT_EQ(int8_t(0x11), sys::SwapByteOrder(int8_t(0x11))); +} + +TEST(SwapByteOrder, int16_t) { + EXPECT_EQ(int16_t(0x1122), sys::SwapByteOrder(int16_t(0x2211))); +} + +TEST(SwapByteOrder, int32_t) { + EXPECT_EQ(int32_t(0x11223344), sys::SwapByteOrder(int32_t(0x44332211))); +} + +TEST(SwapByteOrder, int64_t) { + EXPECT_EQ(int64_t(0x1122334455667788LL), + sys::SwapByteOrder(int64_t(0x8877665544332211LL))); +} + +} diff --git a/unittests/Support/System.cpp b/unittests/Support/System.cpp deleted file mode 100644 index b3dd17d..0000000 --- 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(now_t - now.toEpochTime()) < 2); -} -} diff --git a/unittests/Support/TimeValue.cpp b/unittests/Support/TimeValue.cpp new file mode 100644 index 0000000..27883ae --- /dev/null +++ b/unittests/Support/TimeValue.cpp @@ -0,0 +1,23 @@ +//===- llvm/unittest/Support/TimeValue.cpp - Time Value 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/Support/TimeValue.h" +#include <time.h> + +using namespace llvm; +namespace { + +TEST(Support, 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/Support/ValueHandleTest.cpp b/unittests/Support/ValueHandleTest.cpp index ba610ea..2e5e5b1 100644 --- a/unittests/Support/ValueHandleTest.cpp +++ b/unittests/Support/ValueHandleTest.cpp @@ -108,7 +108,7 @@ TEST_F(ValueHandle, WeakVH_NullOnDeletion) { TEST_F(ValueHandle, AssertingVH_BasicOperation) { AssertingVH<CastInst> AVH(BitcastV.get()); CastInst *implicit_to_exact_type = AVH; - implicit_to_exact_type = implicit_to_exact_type; // Avoid warning. + (void)implicit_to_exact_type; // Avoid warning. AssertingVH<Value> GenericAVH(BitcastV.get()); EXPECT_EQ(BitcastV.get(), GenericAVH); @@ -125,7 +125,7 @@ TEST_F(ValueHandle, AssertingVH_Const) { const CastInst *ConstBitcast = BitcastV.get(); AssertingVH<const CastInst> AVH(ConstBitcast); const CastInst *implicit_to_exact_type = AVH; - implicit_to_exact_type = implicit_to_exact_type; // Avoid warning. + (void)implicit_to_exact_type; // Avoid warning. } TEST_F(ValueHandle, AssertingVH_Comparisons) { |