forked from OSchip/llvm-project
[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 llvm-svn: 274234
This commit is contained in:
parent
7c6eab5777
commit
2d1938be0d
|
@ -47,6 +47,9 @@ void TestFlag(const char *start_value, const char *env,
|
|||
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, bool expected_flag1,
|
|||
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue