[compiler-rt] r274234 - [compiler-rt] Fix broken (flaky) unittests based on FlagParser.
Etienne Bergeron via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 30 08:11:13 PDT 2016
Author: etienneb
Date: Thu Jun 30 10:11:13 2016
New Revision: 274234
URL: http://llvm.org/viewvc/llvm-project?rev=274234&view=rev
Log:
[compiler-rt] Fix broken (flaky) unittests based on FlagParser.
Summary:
The FlagParser is populating a static global class with the
unrecognized flags when parsing. That global class has a
dcheck that limit the number of unrecognized flag to 20.
```
class UnknownFlags {
static const int kMaxUnknownFlags = 20;
const char *unknown_flags_[kMaxUnknownFlags];
int n_unknown_flags_;
[...]
void Report() {
if (!n_unknown_flags_) return;
Printf("WARNING: found %d unrecognized flag(s):\n", n_unknown_flags_);
for (int i = 0; i < n_unknown_flags_; ++i)
Printf(" %s\n", unknown_flags_[i]);
n_unknown_flags_ = 0;
}
};
UnknownFlags unknown_flags;
```
Unittests based on that class must reset the counter 'n_unknown_flags_' or
the next usage of that class may fail arbitrary. This can be done by
reporting the pending unknown flags.
Reviewers: rnk
Subscribers: llvm-commits, wang0109, kubabrecka, chrisha
Differential Revision: http://reviews.llvm.org/D21896
Modified:
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc?rev=274234&r1=274233&r2=274234&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc Thu Jun 30 10:11:13 2016
@@ -47,6 +47,9 @@ void TestFlag(const char *start_value, c
parser.ParseString(env);
EXPECT_EQ(0, internal_strcmp(final_value, flag));
+
+ // Reporting unrecognized flags is needed to reset them.
+ ReportUnrecognizedFlags();
}
TEST(SanitizerCommon, BooleanFlags) {
@@ -97,6 +100,9 @@ static void TestTwoFlags(const char *env
EXPECT_EQ(expected_flag1, flag1);
EXPECT_EQ(0, internal_strcmp(flag2, expected_flag2));
+
+ // Reporting unrecognized flags is needed to reset them.
+ ReportUnrecognizedFlags();
}
TEST(SanitizerCommon, MultipleFlags) {
More information about the llvm-commits
mailing list