From cf36a366a81bdca3083cdcdf2f405a9071598230 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Tue, 29 Jul 2014 22:29:23 +0000 Subject: [PATCH] llvm-profdata: Clean up and reorganize some tests This moves some tests around to make it clearer what's being tested, and adds very rudimentary comment syntax to the text input format to make specifying this kind of test a little bit simpler. llvm-svn: 214235 --- llvm/lib/ProfileData/InstrProfReader.cpp | 4 ++-- llvm/test/tools/llvm-profdata/Inputs/overflow.profdata | 4 ---- llvm/test/tools/llvm-profdata/hash-mismatch.profdata | 17 +++++++++++++++++ llvm/test/tools/llvm-profdata/lit.local.cfg | 1 + .../llvm-profdata/{simple.test => multiple-inputs.test} | 2 ++ llvm/test/tools/llvm-profdata/overflow.profdata | 12 ++++++++++++ .../{errors.test => text-format-errors.test} | 6 ------ 7 files changed, 34 insertions(+), 12 deletions(-) delete mode 100644 llvm/test/tools/llvm-profdata/Inputs/overflow.profdata create mode 100644 llvm/test/tools/llvm-profdata/hash-mismatch.profdata create mode 100644 llvm/test/tools/llvm-profdata/lit.local.cfg rename llvm/test/tools/llvm-profdata/{simple.test => multiple-inputs.test} (98%) create mode 100644 llvm/test/tools/llvm-profdata/overflow.profdata rename llvm/test/tools/llvm-profdata/{errors.test => text-format-errors.test} (69%) diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index 0b36728..e8f6461 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -83,8 +83,8 @@ void InstrProfIterator::Increment() { } std::error_code TextInstrProfReader::readNextRecord(InstrProfRecord &Record) { - // Skip empty lines. - while (!Line.is_at_end() && Line->empty()) + // Skip empty lines and comments. + while (!Line.is_at_end() && (Line->empty() || Line->startswith("#"))) ++Line; // If we hit EOF while looking for a name, we're done. if (Line.is_at_end()) diff --git a/llvm/test/tools/llvm-profdata/Inputs/overflow.profdata b/llvm/test/tools/llvm-profdata/Inputs/overflow.profdata deleted file mode 100644 index c9a9d69..0000000 --- a/llvm/test/tools/llvm-profdata/Inputs/overflow.profdata +++ /dev/null @@ -1,4 +0,0 @@ -overflow -1 -1 -9223372036854775808 diff --git a/llvm/test/tools/llvm-profdata/hash-mismatch.profdata b/llvm/test/tools/llvm-profdata/hash-mismatch.profdata new file mode 100644 index 0000000..1263258 --- /dev/null +++ b/llvm/test/tools/llvm-profdata/hash-mismatch.profdata @@ -0,0 +1,17 @@ +# RUN: llvm-profdata merge %s -o %t.out 2>&1 | FileCheck %s +# CHECK: hash-mismatch.profdata: foo: Function hash mismatch + +foo +3 +3 +1 +2 +3 + +foo +4 +4 +11 +22 +33 +44 diff --git a/llvm/test/tools/llvm-profdata/lit.local.cfg b/llvm/test/tools/llvm-profdata/lit.local.cfg new file mode 100644 index 0000000..33bc0a9 --- /dev/null +++ b/llvm/test/tools/llvm-profdata/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes.add('.profdata') diff --git a/llvm/test/tools/llvm-profdata/simple.test b/llvm/test/tools/llvm-profdata/multiple-inputs.test similarity index 98% rename from llvm/test/tools/llvm-profdata/simple.test rename to llvm/test/tools/llvm-profdata/multiple-inputs.test index 18741dd..82d417e 100644 --- a/llvm/test/tools/llvm-profdata/simple.test +++ b/llvm/test/tools/llvm-profdata/multiple-inputs.test @@ -1,3 +1,5 @@ +Some very basic tests for the multiple input cases. + RUN: llvm-profdata merge %p/Inputs/foo3-1.profdata %p/Inputs/foo3-2.profdata -o %t RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FOO3 RUN: llvm-profdata merge %p/Inputs/foo3-2.profdata %p/Inputs/foo3-1.profdata -o %t diff --git a/llvm/test/tools/llvm-profdata/overflow.profdata b/llvm/test/tools/llvm-profdata/overflow.profdata new file mode 100644 index 0000000..62ced05 --- /dev/null +++ b/llvm/test/tools/llvm-profdata/overflow.profdata @@ -0,0 +1,12 @@ +# RUN: llvm-profdata merge %s -o %t.out 2>&1 | FileCheck %s +# CHECK: overflow.profdata: overflow: Counter overflow + +overflow +1 +1 +9223372036854775808 + +overflow +1 +1 +9223372036854775808 diff --git a/llvm/test/tools/llvm-profdata/errors.test b/llvm/test/tools/llvm-profdata/text-format-errors.test similarity index 69% rename from llvm/test/tools/llvm-profdata/errors.test rename to llvm/test/tools/llvm-profdata/text-format-errors.test index 28262ef..870001f 100644 --- a/llvm/test/tools/llvm-profdata/errors.test +++ b/llvm/test/tools/llvm-profdata/text-format-errors.test @@ -1,9 +1,3 @@ -RUN: llvm-profdata merge %p/Inputs/foo3-1.profdata %p/Inputs/foo4-1.profdata -o %t.out 2>&1 | FileCheck %s --check-prefix=HASH -HASH: foo4-1.profdata: foo: Function hash mismatch - -RUN: llvm-profdata merge %p/Inputs/overflow.profdata %p/Inputs/overflow.profdata -o %t.out 2>&1 | FileCheck %s --check-prefix=OVERFLOW -OVERFLOW: overflow.profdata: overflow: Counter overflow - RUN: not llvm-profdata show %p/Inputs/invalid-count-later.profdata 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER RUN: not llvm-profdata merge %p/Inputs/invalid-count-later.profdata %p/Inputs/invalid-count-later.profdata -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER INVALID-COUNT-LATER: error: {{.*}}invalid-count-later.profdata: Malformed profile data -- 2.7.4