Added elementary fuzzer-randgen invocation count.
This commit is contained in:
parent
ab1eaa672b
commit
f4870f3996
4 changed files with 81 additions and 10 deletions
|
@ -65,6 +65,8 @@ _QuitTestEnvironment()
|
||||||
_testReturnValue = TEST_RESULT_NO_ASSERT;
|
_testReturnValue = TEST_RESULT_NO_ASSERT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log(time(0), "Fuzzer invocation count: %d", GetInvocationCount());
|
||||||
|
|
||||||
DeinitFuzzer();
|
DeinitFuzzer();
|
||||||
|
|
||||||
return _testReturnValue;
|
return _testReturnValue;
|
||||||
|
@ -75,6 +77,25 @@ _CountFailedAsserts() {
|
||||||
return _testAssertsFailed;
|
return _testAssertsFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Bail out from test case. For example, function is used to bail out
|
||||||
|
* after failed assert.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_BailOut()
|
||||||
|
{
|
||||||
|
if(!canBailOut)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
AssertSummary(_testAssertsFailed + _testAssertsPassed,
|
||||||
|
_testAssertsFailed, _testAssertsPassed, time(0));
|
||||||
|
|
||||||
|
Log(time(0), "Fuzzer invocation count: %d", GetInvocationCount());
|
||||||
|
|
||||||
|
DeinitFuzzer();
|
||||||
|
|
||||||
|
exit(TEST_RESULT_FAILURE); // bail out from the test
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AssertEquals(int expected, int actual, char *message, ...)
|
AssertEquals(int expected, int actual, char *message, ...)
|
||||||
|
@ -93,8 +114,7 @@ AssertEquals(int expected, int actual, char *message, ...)
|
||||||
_testReturnValue = TEST_RESULT_FAILURE;
|
_testReturnValue = TEST_RESULT_FAILURE;
|
||||||
_testAssertsFailed++;
|
_testAssertsFailed++;
|
||||||
|
|
||||||
if(canBailOut)
|
_BailOut();
|
||||||
exit(TEST_RESULT_FAILURE); // bail out from the test
|
|
||||||
} else {
|
} else {
|
||||||
AssertWithValues("AssertEquals", 1, buf,
|
AssertWithValues("AssertEquals", 1, buf,
|
||||||
actual, expected, time(0));
|
actual, expected, time(0));
|
||||||
|
@ -119,8 +139,7 @@ AssertTrue(int condition, char *message, ...)
|
||||||
_testReturnValue = TEST_RESULT_FAILURE;
|
_testReturnValue = TEST_RESULT_FAILURE;
|
||||||
_testAssertsFailed++;
|
_testAssertsFailed++;
|
||||||
|
|
||||||
if(canBailOut)
|
_BailOut();
|
||||||
exit(TEST_RESULT_FAILURE); // bail out from the test
|
|
||||||
} else {
|
} else {
|
||||||
Assert("AssertTrue", 1, buf, time(0));
|
Assert("AssertTrue", 1, buf, time(0));
|
||||||
|
|
||||||
|
@ -159,7 +178,6 @@ AssertFail(char *message, ...)
|
||||||
_testReturnValue = TEST_RESULT_FAILURE;
|
_testReturnValue = TEST_RESULT_FAILURE;
|
||||||
_testAssertsFailed++;
|
_testAssertsFailed++;
|
||||||
|
|
||||||
if(canBailOut)
|
_BailOut();
|
||||||
exit(TEST_RESULT_FAILURE); // bail out from the test
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
//! context for test-specific random number generator
|
//! context for test-specific random number generator
|
||||||
static RND_CTX rndContext;
|
static RND_CTX rndContext;
|
||||||
|
|
||||||
|
//! Counts invocation of fuzzer generator functions
|
||||||
|
int invocationCounter = 0;
|
||||||
|
|
||||||
Uint64
|
Uint64
|
||||||
GenerateExecKey(char *runSeed, char *suiteName,
|
GenerateExecKey(char *runSeed, char *suiteName,
|
||||||
char *testName, int iterationNumber)
|
char *testName, int iterationNumber)
|
||||||
|
@ -99,45 +102,63 @@ InitFuzzer(Uint64 execKey)
|
||||||
utl_randomInit(&rndContext, a, b);
|
utl_randomInit(&rndContext, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
GetInvocationCount()
|
||||||
|
{
|
||||||
|
return invocationCounter;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DeinitFuzzer()
|
DeinitFuzzer()
|
||||||
{
|
{
|
||||||
|
invocationCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
RandomUint8()
|
RandomUint8()
|
||||||
{
|
{
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return (Uint8) utl_randomInt(&rndContext) & 0x000000FF;
|
return (Uint8) utl_randomInt(&rndContext) & 0x000000FF;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sint8
|
Sint8
|
||||||
RandomSint8()
|
RandomSint8()
|
||||||
{
|
{
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return (Sint8) utl_randomInt(&rndContext) & 0x000000FF;
|
return (Sint8) utl_randomInt(&rndContext) & 0x000000FF;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint16
|
Uint16
|
||||||
RandomUint16()
|
RandomUint16()
|
||||||
{
|
{
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return (Uint16) utl_randomInt(&rndContext) & 0x0000FFFF;
|
return (Uint16) utl_randomInt(&rndContext) & 0x0000FFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sint16
|
Sint16
|
||||||
RandomSint16()
|
RandomSint16()
|
||||||
{
|
{
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return (Sint16) utl_randomInt(&rndContext) & 0x0000FFFF;
|
return (Sint16) utl_randomInt(&rndContext) & 0x0000FFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sint32
|
Sint32
|
||||||
RandomSint32()
|
RandomSint32()
|
||||||
{
|
{
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return (Sint32) utl_randomInt(&rndContext);
|
return (Sint32) utl_randomInt(&rndContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32
|
Uint32
|
||||||
RandomUint32()
|
RandomUint32()
|
||||||
{
|
{
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return (Uint32) utl_randomInt(&rndContext);
|
return (Uint32) utl_randomInt(&rndContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +167,8 @@ RandomUint64()
|
||||||
{
|
{
|
||||||
Uint64 value;
|
Uint64 value;
|
||||||
|
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
Uint32 *vp = (Uint32*)&value;
|
Uint32 *vp = (Uint32*)&value;
|
||||||
vp[0] = RandomSint32();
|
vp[0] = RandomSint32();
|
||||||
vp[1] = RandomSint32();
|
vp[1] = RandomSint32();
|
||||||
|
@ -158,6 +181,8 @@ RandomSint64()
|
||||||
{
|
{
|
||||||
Uint64 value;
|
Uint64 value;
|
||||||
|
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
Uint32 *vp = (Uint32*)&value;
|
Uint32 *vp = (Uint32*)&value;
|
||||||
vp[0] = RandomSint32();
|
vp[0] = RandomSint32();
|
||||||
vp[1] = RandomSint32();
|
vp[1] = RandomSint32();
|
||||||
|
@ -180,7 +205,7 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sint32 number = RandomSint32();
|
Sint32 number = RandomSint32(); // invocation count increment in there
|
||||||
|
|
||||||
return (number % ((max + 1) - min)) + min;
|
return (number % ((max + 1) - min)) + min;
|
||||||
}
|
}
|
||||||
|
@ -292,6 +317,8 @@ RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
|
||||||
|
|
||||||
SDL_free(buffer);
|
SDL_free(buffer);
|
||||||
|
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +343,8 @@ RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDoma
|
||||||
|
|
||||||
SDL_free(buffer);
|
SDL_free(buffer);
|
||||||
|
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,6 +369,8 @@ RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDoma
|
||||||
|
|
||||||
SDL_free(buffer);
|
SDL_free(buffer);
|
||||||
|
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,6 +395,8 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma
|
||||||
|
|
||||||
SDL_free(buffer);
|
SDL_free(buffer);
|
||||||
|
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,6 +514,8 @@ RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain)
|
||||||
|
|
||||||
SDL_free(buffer);
|
SDL_free(buffer);
|
||||||
|
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,6 +541,8 @@ RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDoma
|
||||||
|
|
||||||
SDL_free(buffer);
|
SDL_free(buffer);
|
||||||
|
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,6 +568,8 @@ RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDoma
|
||||||
|
|
||||||
SDL_free(buffer);
|
SDL_free(buffer);
|
||||||
|
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,6 +595,8 @@ RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDoma
|
||||||
|
|
||||||
SDL_free(buffer);
|
SDL_free(buffer);
|
||||||
|
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,6 +615,8 @@ RandomUnitDouble()
|
||||||
float
|
float
|
||||||
RandomFloat()
|
RandomFloat()
|
||||||
{
|
{
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
// \todo to be implemented
|
// \todo to be implemented
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
@ -581,6 +624,8 @@ RandomFloat()
|
||||||
double
|
double
|
||||||
RandomDouble()
|
RandomDouble()
|
||||||
{
|
{
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
// \todo to be implemented
|
// \todo to be implemented
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
@ -589,12 +634,15 @@ RandomDouble()
|
||||||
char *
|
char *
|
||||||
RandomAsciiString()
|
RandomAsciiString()
|
||||||
{
|
{
|
||||||
|
// note: invocationCounter is increment in the RandomAsciiStringWithMaximumLenght
|
||||||
return RandomAsciiStringWithMaximumLength(255);
|
return RandomAsciiStringWithMaximumLength(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
RandomAsciiStringWithMaximumLength(int maxSize)
|
RandomAsciiStringWithMaximumLength(int maxSize)
|
||||||
{
|
{
|
||||||
|
invocationCounter++;
|
||||||
|
|
||||||
if(maxSize < 1) {
|
if(maxSize < 1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,5 +353,9 @@ char *RandomAsciiStringWithMaximumLength(int maxLength);
|
||||||
*/
|
*/
|
||||||
Uint64 GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iterationNumber);
|
Uint64 GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iterationNumber);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns test specific invocation count for the fuzzer.
|
||||||
|
*/
|
||||||
|
int GetInvocationCount();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -103,7 +103,8 @@ test_dummy1(void *arg)
|
||||||
|
|
||||||
//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
|
//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
|
||||||
|
|
||||||
for(; 1 ; )
|
int c = 0;
|
||||||
|
//for(; c < 100 ; c++)
|
||||||
printf("%f\n", RandomUnitFloat());
|
printf("%f\n", RandomUnitFloat());
|
||||||
|
|
||||||
for(; 0 ; )
|
for(; 0 ; )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue