diff options
author | Justin Bogner <mail@justinbogner.com> | 2015-02-17 09:21:43 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2015-02-17 09:21:43 +0000 |
commit | 5b3ad88646df937ab5d45593fdfe2132eacc441e (patch) | |
tree | 1b7ed0ea0de6cc39f81cbaf3aa8c4e76438dd08c /llvm/unittests | |
parent | ba8467251994e318dee34f48e00728b47fef9285 (diff) | |
download | bcm5719-llvm-5b3ad88646df937ab5d45593fdfe2132eacc441e.tar.gz bcm5719-llvm-5b3ad88646df937ab5d45593fdfe2132eacc441e.zip |
Revert "InstrProf: Add unit tests for the profile reader and writer"
This added API to the InstrProfWriter to write to a string so I could
write unittests without using temp files. This doesn't really work,
since the format has tighter alignment requirements than a char.
This reverts r229478 and its follow-up, r229481.
llvm-svn: 229483
Diffstat (limited to 'llvm/unittests')
-rw-r--r-- | llvm/unittests/ProfileData/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/unittests/ProfileData/InstrProfTest.cpp | 97 |
2 files changed, 0 insertions, 98 deletions
diff --git a/llvm/unittests/ProfileData/CMakeLists.txt b/llvm/unittests/ProfileData/CMakeLists.txt index 79137c9510a..3251ff41502 100644 --- a/llvm/unittests/ProfileData/CMakeLists.txt +++ b/llvm/unittests/ProfileData/CMakeLists.txt @@ -6,5 +6,4 @@ set(LLVM_LINK_COMPONENTS add_llvm_unittest(ProfileDataTests CoverageMappingTest.cpp - InstrProfTest.cpp ) diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp deleted file mode 100644 index 1a25a1fd90d..00000000000 --- a/llvm/unittests/ProfileData/InstrProfTest.cpp +++ /dev/null @@ -1,97 +0,0 @@ -//===- unittest/ProfileData/InstrProfTest.cpp -------------------------------=// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/ProfileData/InstrProfReader.h" -#include "llvm/ProfileData/InstrProfWriter.h" -#include "gtest/gtest.h" - -#include <cstdarg> - -using namespace llvm; - -namespace { - -struct InstrProfTest : ::testing::Test { - InstrProfWriter Writer; - std::unique_ptr<IndexedInstrProfReader> Reader; - - void addCounts(StringRef Name, uint64_t Hash, int NumCounts, ...) { - SmallVector<uint64_t, 8> Counts; - va_list Args; - va_start(Args, NumCounts); - for (int I = 0; I < NumCounts; ++I) - Counts.push_back(va_arg(Args, uint64_t)); - va_end(Args); - Writer.addFunctionCounts(Name, Hash, Counts); - } - - std::string writeProfile() { return Writer.writeString(); } - void readProfile(std::string Profile) { - auto ReaderOrErr = - IndexedInstrProfReader::create(MemoryBuffer::getMemBuffer(Profile)); - ASSERT_EQ(std::error_code(), ReaderOrErr.getError()); - Reader = std::move(ReaderOrErr.get()); - } -}; - -TEST_F(InstrProfTest, write_and_read_empty_profile) { - std::string Profile = writeProfile(); - readProfile(Profile); - ASSERT_TRUE(Reader->begin() == Reader->end()); -} - -TEST_F(InstrProfTest, write_and_read_one_function) { - addCounts("foo", 0x1234, 4, 1ULL, 2ULL, 3ULL, 4ULL); - std::string Profile = writeProfile(); - readProfile(Profile); - - auto I = Reader->begin(), E = Reader->end(); - ASSERT_TRUE(I != E); - ASSERT_EQ(StringRef("foo"), I->Name); - ASSERT_EQ(0x1234U, I->Hash); - ASSERT_EQ(4U, I->Counts.size()); - ASSERT_EQ(1U, I->Counts[0]); - ASSERT_EQ(2U, I->Counts[1]); - ASSERT_EQ(3U, I->Counts[2]); - ASSERT_EQ(4U, I->Counts[3]); - ASSERT_TRUE(++I == E); -} - -TEST_F(InstrProfTest, get_function_counts) { - addCounts("foo", 0x1234, 2, 1ULL, 2ULL); - std::string Profile = writeProfile(); - readProfile(Profile); - - std::vector<uint64_t> Counts; - std::error_code EC; - - EC = Reader->getFunctionCounts("foo", 0x1234, Counts); - ASSERT_EQ(instrprof_error::success, EC); - ASSERT_EQ(2U, Counts.size()); - ASSERT_EQ(1U, Counts[0]); - ASSERT_EQ(2U, Counts[1]); - - EC = Reader->getFunctionCounts("foo", 0x5678, Counts); - ASSERT_EQ(instrprof_error::hash_mismatch, EC); - - EC = Reader->getFunctionCounts("bar", 0x1234, Counts); - ASSERT_EQ(instrprof_error::unknown_function, EC); -} - -TEST_F(InstrProfTest, get_max_function_count) { - addCounts("foo", 0x1234, 2, 1ULL << 31, 2ULL); - addCounts("bar", 0, 1, 1ULL << 63); - addCounts("baz", 0x5678, 4, 0ULL, 0ULL, 0ULL, 0ULL); - std::string Profile = writeProfile(); - readProfile(Profile); - - ASSERT_EQ(1ULL << 63, Reader->getMaximumFunctionCount()); -} - -} // end anonymous namespace |