Skip to content

Commit

Permalink
testrunner: added TestFixture::ignore_errout() to ignore output
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Apr 6, 2024
1 parent 2903b09 commit 42fb5b2
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 79 deletions.
5 changes: 5 additions & 0 deletions test/fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ class TestFixture : public ErrorLogger {
return s;
}

void ignore_errout() {
if (errout_str().empty())
throw std::runtime_error("no errout to ignore");
}

const Settings settingsDefault;

private:
Expand Down
2 changes: 1 addition & 1 deletion test/testbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4979,7 +4979,7 @@ class TestBufferOverrun : public TestFixture {
const Check& c = getCheck<CheckBufferOverrun>();
c.getErrorMessages(this, nullptr);
// we are not interested in the output - just consume it
(void)errout_str();
ignore_errout();
}

void arrayIndexThenCheck() {
Expand Down
2 changes: 1 addition & 1 deletion test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6688,7 +6688,7 @@ class TestClass : public TestFixture {
"struct D : S<150> {};\n");
// don't hang
// we are not interested in the output - just consume it
(void)errout_str();
ignore_errout();
}

void const93() { // #12162
Expand Down
58 changes: 29 additions & 29 deletions test/testgarbage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class TestGarbage : public TestFixture {

// don't segfault..
ASSERT_THROW(checkCode(code), InternalError);
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}


Expand Down Expand Up @@ -495,7 +495,7 @@ class TestGarbage : public TestFixture {

void garbageCode12() { // do not crash
checkCode("{ g; S (void) { struct } { } int &g; }");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode13() {
Expand Down Expand Up @@ -563,7 +563,7 @@ class TestGarbage : public TestFixture {
" cptr = (char *)buffer;\n"
" cptr += (-(long int) buffer & (16 * sizeof (float) - 1));\n"
"}\n"), InternalError);
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode25() {
Expand Down Expand Up @@ -598,15 +598,15 @@ class TestGarbage : public TestFixture {
" int a;\n"
" R1 () : a { }\n"
"};");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode30() {
// simply survive - a syntax error would be even better (#5867)
checkCode("void f(int x) {\n"
" x = 42\n"
"}");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode31() {
Expand Down Expand Up @@ -676,7 +676,7 @@ class TestGarbage : public TestFixture {

void garbageCode46() { // #6705
checkCode(" { bar(char *x); void foo (int ...) { struct } va_list ap; va_start(ap, size); va_arg(ap, (d)); }");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode47() { // #6706
Expand All @@ -685,7 +685,7 @@ class TestGarbage : public TestFixture {

void garbageCode48() { // #6712
checkCode(" { d\" ) d ...\" } int main ( ) { ( ) catch ( A a ) { { } catch ( ) \"\" } }");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode49() { // #6715
Expand Down Expand Up @@ -776,7 +776,7 @@ class TestGarbage : public TestFixture {

void garbageCode74() { // #6751
ASSERT_THROW(checkCode("_lenraw(const char* digits) { } typedef decltype(sizeof(0)) { } operator"), InternalError);
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode76() { // #6754
Expand All @@ -789,7 +789,7 @@ class TestGarbage : public TestFixture {

void garbageCode78() { // #6756
ASSERT_THROW(checkCode("( ) { [ ] } ( ) { } const_array_of_int ( ) { } typedef int A [ ] [ ] ; A a = { { } { } }"), InternalError);
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode79() { // #6757
Expand Down Expand Up @@ -887,7 +887,7 @@ class TestGarbage : public TestFixture {

void garbageCode102() { // #6846
checkCode("struct Object { ( ) ; Object & operator= ( Object ) { ( ) { } if ( this != & b ) } }");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode103() { // #6824
Expand Down Expand Up @@ -916,7 +916,7 @@ class TestGarbage : public TestFixture {

void garbageCode109() { // #6900 "segmentation fault (invalid code) in CheckStl::runSimplifiedChecks"
checkCode("( *const<> (( ) ) { } ( *const ( ) ( ) ) { } ( * const<> ( size_t )) ) { } ( * const ( ) ( ) ) { }");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode110() { // #6902 "segmentation fault (invalid code) in CheckStl::string_c_str"
Expand Down Expand Up @@ -963,7 +963,7 @@ class TestGarbage : public TestFixture {

void garbageCode119() { // #5598
checkCode("{ { void foo() { struct }; template <typename> struct S { Used x; void bar() } auto f = [this] { }; } };");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode120() { // #4927
Expand All @@ -984,7 +984,7 @@ class TestGarbage : public TestFixture {
"char *a = malloc(10);\n"
"a[0]\n"
"}");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode123() {
Expand All @@ -993,7 +993,7 @@ class TestGarbage : public TestFixture {
" C tpl_mem(T *) { return }\n"
" };\n"
"}");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode125() {
Expand All @@ -1017,7 +1017,7 @@ class TestGarbage : public TestFixture {
"};\n"
" const A& foo(const A& arg) { return arg; }\n"
" foo(A(12)).Var");
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void garbageCode128() {
Expand Down Expand Up @@ -1106,7 +1106,7 @@ class TestGarbage : public TestFixture {
"template<int S::*p, typename U> struct X {}; "
"X<&S::i, int> x = X<&S::i, int>(); "
"X<&S::j, int> y = X<&S::j, int>();");
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
checkCode("template <typename T> struct A {}; "
"template <> struct A<void> {}; "
"void foo(const void* f = 0) {}");
Expand All @@ -1124,7 +1124,7 @@ class TestGarbage : public TestFixture {
" static int i; "
"}; "
"void f() { A<int>::i = 0; }");
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}

void garbageCode135() { // #4994
Expand All @@ -1133,7 +1133,7 @@ class TestGarbage : public TestFixture {
"}\n"
"long a = 1 ;\n"
"long b = 2 ;");
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}

void garbageCode136() { // #7033
Expand All @@ -1155,7 +1155,7 @@ class TestGarbage : public TestFixture {
" } halo;\n"
"}\n"
"CS_PLUGIN_NAMESPACE_END(csparser)");
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}

void garbageCode139() { // #6659 heap user after free: kernel: sm750_accel.c
Expand Down Expand Up @@ -1255,7 +1255,7 @@ class TestGarbage : public TestFixture {
"static std::string foo(char *Bla) {\n"
" while (Bla[1] && Bla[1] != ',') }\n";
checkCode(code);
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}

void garbageCode153() {
Expand Down Expand Up @@ -1327,7 +1327,7 @@ class TestGarbage : public TestFixture {
" case YY_STATE_EOF(block):\n"
" yyterminate();\n"
"} }"); // #5663
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}

void garbageAST() {
Expand Down Expand Up @@ -1398,7 +1398,7 @@ class TestGarbage : public TestFixture {
"typedef something_like_tuple<char, int, float> something_like_tuple_t;\n"
"SA ((is_last<float, something_like_tuple_t>::value == false));\n"
"SA ((is_last<int, something_like_tuple_t>::value == false));");
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output

checkCode( // #6225
"template <typename...>\n"
Expand Down Expand Up @@ -1494,7 +1494,7 @@ class TestGarbage : public TestFixture {

void garbageCode176() { // #7527
checkCode("class t { { struct } enum class f : unsigned { q } b ; operator= ( T ) { switch ( b ) { case f::q: } } { assert ( b ) ; } } { ; & ( t ) ( f::t ) ; } ;");
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}

void garbageCode181() {
Expand Down Expand Up @@ -1527,7 +1527,7 @@ class TestGarbage : public TestFixture {
" return bStatus;\n"
" };\n"
"}");
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}

// #8151 - segfault due to incorrect template syntax
Expand Down Expand Up @@ -1721,15 +1721,15 @@ class TestGarbage : public TestFixture {

void garbageCode218() { // #8763
checkCode("d f(){t n0000 const[]n0000+0!=n0000,(0)}"); // don't crash
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}
void garbageCode219() { // #10101
checkCode("typedef void (*func) (addr) ;\n"
"void bar(void) {\n"
" func f;\n"
" f & = (func)42;\n"
"}\n"); // don't crash
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}
void garbageCode220() { // #6832
ASSERT_THROW(checkCode("(){(){{()}}return;{switch()0 case(){}break;l:()}}\n"), InternalError); // don't crash
Expand Down Expand Up @@ -1817,7 +1817,7 @@ class TestGarbage : public TestFixture {
ASSERT_THROW(checkCode("void f(){x=0,return return''[]()}"), InternalError);
ASSERT_THROW(checkCode("void f(){x='0'++'0'(return)[];}"), InternalError); // #9063
checkCode("void f(){*(int *)42=0;}"); // no syntax error
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
ASSERT_THROW(checkCode("void f() { x= 'x' > typedef name5 | ( , ;){ } (); }"), InternalError); // #9067
ASSERT_THROW(checkCode("void f() { x= {}( ) ( 'x')[ ] (); }"), InternalError); // #9068
ASSERT_THROW(checkCode("void f() { x= y{ } name5 y[ ] + y ^ name5 ^ name5 for ( ( y y y && y y y && name5 ++ int )); }"), InternalError); // #9069
Expand All @@ -1832,7 +1832,7 @@ class TestGarbage : public TestFixture {
"bool bReturn(false);\n"
"}\n"
"};"));
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}

void enumTrailingComma() {
Expand All @@ -1850,7 +1850,7 @@ class TestGarbage : public TestFixture {
"template< class Predicate > int\n"
"List<T>::DeleteIf( const Predicate &pred )\n"
"{}");
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output

// #8749
checkCode(
Expand Down
2 changes: 1 addition & 1 deletion test/testpreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ class TestPreprocessor : public TestFixture {
ASSERT_EQUALS(false, suppr.checked);
ASSERT_EQUALS(false, suppr.matched);

(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}

void predefine1() {
Expand Down
4 changes: 2 additions & 2 deletions test/testprocessexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class TestProcessExecutorBase : public TestFixture {
" return 0;\n"
"}", dinit(CheckOptions, $.showtime = SHOWTIME_MODES::SHOWTIME_SUMMARY));
// we are not interested in the results - so just consume them
(void)errout_str();
ignore_errout();
}

void many_threads_plist() {
Expand All @@ -201,7 +201,7 @@ class TestProcessExecutorBase : public TestFixture {
" return 0;\n"
"}", dinit(CheckOptions, $.plistOutput = plistOutput.c_str()));
// we are not interested in the results - so just consume them
(void)errout_str();
ignore_errout();
}

void no_errors_more_files() {
Expand Down
6 changes: 3 additions & 3 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,7 @@ class TestSimplifyTypedef : public TestFixture {
void simplifyTypedef107() { // ticket #3963 (bad code => segmentation fault)
const char code[] = "typedef int x[]; int main() { return x }";
ASSERT_EQUALS("int main ( ) { return x }", tok(code));
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void simplifyTypedef108() { // ticket #4777
Expand Down Expand Up @@ -3403,14 +3403,14 @@ class TestSimplifyTypedef : public TestFixture {
" sizeof(t);\n"
"}\n";
ASSERT_EQUALS("void g ( ) { sizeof ( t ) ; }", tok(code)); // TODO: handle implicit int
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output

code = "typedef t[3];\n"
"void g() {\n"
" sizeof(t);\n"
"}\n";
ASSERT_EQUALS("void g ( ) { sizeof ( t ) ; }", tok(code)); // TODO: handle implicit int
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void simplifyTypedef146() {
Expand Down
10 changes: 5 additions & 5 deletions test/testsimplifyusing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ class TestSimplifyUsing : public TestFixture {
"}\n"
"}";
tok(code); // don't hang
(void)errout_str(); // we are not interested in the output
ignore_errout(); // we are not interested in the output
}

void simplifyUsing20() {
Expand Down Expand Up @@ -530,7 +530,7 @@ class TestSimplifyUsing : public TestFixture {
"}\n"
"}}}}}}}";
tok(code); // don't hang
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void simplifyUsing21() {
Expand Down Expand Up @@ -562,7 +562,7 @@ class TestSimplifyUsing : public TestFixture {
"} "
"} } } } }";
ASSERT_EQUALS(expected, tok(code)); // don't hang
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}

void simplifyUsing23() {
Expand Down Expand Up @@ -1294,7 +1294,7 @@ class TestSimplifyUsing : public TestFixture {
" return ret;\n"
"}";
tok(code); // don't crash
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}
}

Expand Down Expand Up @@ -1440,7 +1440,7 @@ class TestSimplifyUsing : public TestFixture {
"} "
"}";
ASSERT_EQUALS(exp, tok(code));
(void)errout_str(); // we do not care about the output
ignore_errout(); // we do not care about the output
}
}

Expand Down
Loading

0 comments on commit 42fb5b2

Please sign in to comment.