Remove calls to cout.flush() for AppVeyor

They seemed to produce a hang when running self tests in AppVeyor.
Also use IsDebuggerPresent() to determine when we should call DebugBreak(). The OS killed our debug build when fuzzing caused an assert to fail
pull/424/merge
Jeffrey Walton 2017-05-29 00:43:20 -04:00
parent 0df38c3506
commit ae3922dda0
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
4 changed files with 11 additions and 20 deletions

7
trap.h
View File

@ -23,9 +23,8 @@
# if defined(UNIX_SIGNALS_AVAILABLE)
# include "ossig.h"
# elif defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(__CYGWIN__)
# if (_MSC_VER >= 1400)
# include <intrin.h>
# endif
extern "C" __declspec(dllimport) void __stdcall DebugBreak();
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
# endif
#endif // CRYPTOPP_DEBUG
@ -80,7 +79,7 @@
<< (int)(__LINE__) << "): " << (char*)(__FUNCTION__) \
<< std::endl; \
std::cerr << oss.str(); \
__debugbreak(); \
if (IsDebuggerPresent()) {DebugBreak();} \
} \
}
#endif // DEBUG and Unix or Windows

View File

@ -141,9 +141,6 @@ bool TestPolynomialMod2()
std::cout << (!pass2 ? "FAILED" : "passed") << ": " << "0x" << std::hex << word(SIZE_MAX) << std::dec << " shifted over range [" << start << "," << stop << "]" << "\n";
std::cout << (!pass3 ? "FAILED" : "passed") << ": " << "random values shifted over range [" << std::dec << start << "," << stop << "]" << "\n";
if (!(pass1 && pass2 && pass3))
std::cout.flush();
return pass1 && pass2 && pass3;
}
#endif
@ -428,7 +425,6 @@ bool TestCompressors()
// **************************************************************
std::cout.flush();
return !fail1 && !fail2 && !fail3;
}
@ -684,6 +680,7 @@ bool TestSharing()
vector_member_ptrs<StringSource> strSources(threshold);
channel.resize(CHID_LENGTH);
for (unsigned int i=0; i<threshold; i++)
{
strSources[i].reset(new StringSource(strShares[i], false));
@ -717,6 +714,7 @@ bool TestSharing()
for (unsigned int shares=3; shares<SECRET_SHARES; ++shares)
{
std::string message;
unsigned int len = GlobalRNG().GenerateWord32(0, 0xff);
unsigned int threshold = GlobalRNG().GenerateWord32(2, shares-1);
@ -1226,7 +1224,6 @@ bool TestRounding()
std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word128, overflow\n";
#endif
std::cout.flush();
return pass;
}
#endif
@ -1305,7 +1302,6 @@ bool RunASN1TestSet(const ASN1_TestTuple asnTuples[], size_t count)
pass = !fail && pass;
}
std::cout.flush();
return pass;
}
@ -1479,7 +1475,6 @@ bool TestASN1Parse()
pass = RunASN1TestSet(integerValues, COUNTOF(integerValues)) && pass;
std::cout.flush();
return pass;
}
#endif
@ -2444,7 +2439,6 @@ bool TestSecBlock()
std::cout << " FixedSizeAllocator Grow with word128\n";
#endif
std::cout.flush();
return pass1 && pass2 && pass3 && pass4 && pass5 && pass6 && pass7;
}
#endif
@ -3212,7 +3206,6 @@ bool TestIntegerBitops()
std::cout << "FAILED:";
std::cout << " Bitwise XOR over 32-bits to 1024-bits\n";
std::cout.flush();
return opa && opo && opx;
}
#endif

View File

@ -79,9 +79,10 @@ bool ValidateAll(bool thorough)
#if defined(CRYPTOPP_EXTENDED_VALIDATION)
pass=TestMersenne() && pass;
#endif
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
pass=TestRDRAND() && pass;
pass=TestRDSEED() && pass;
#endif
#if defined(CRYPTOPP_EXTENDED_VALIDATION)
// http://github.com/weidai11/cryptopp/issues/92
pass=TestSecBlock() && pass;
@ -714,7 +715,6 @@ bool TestRandomPool()
}
#endif
std::cout.flush();
return pass;
}
@ -809,7 +809,6 @@ bool TestAutoSeededX917()
std::cout << "passed:";
std::cout << " GenerateWord32 and Crop\n";
std::cout.flush();
return pass;
}
#endif
@ -920,11 +919,11 @@ bool TestMersenne()
std::cout << "passed:";
std::cout << " GenerateWord32 and Crop\n";
std::cout.flush();
return pass;
}
#endif
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
bool TestRDRAND()
{
std::cout << "\nTesting RDRAND generator...\n\n";
@ -1024,7 +1023,6 @@ bool TestRDRAND()
else
std::cout << "RDRAND generator not available, skipping test.\n";
std::cout.flush();
return pass;
}
@ -1127,9 +1125,9 @@ bool TestRDSEED()
else
std::cout << "RDSEED generator not available, skipping test.\n";
std::cout.flush();
return pass;
}
#endif
bool ValidateHashDRBG()
{

View File

@ -25,9 +25,10 @@ bool TestRandomPool();
#if !defined(NO_OS_DEPENDENCE)
bool TestAutoSeededX917();
#endif
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
bool TestRDRAND();
bool TestRDSEED();
#endif
bool ValidateBaseCode();
bool ValidateCRC32();
bool ValidateCRC32C();