Fixed an issue with fuzzing seeds.
This commit is contained in:
parent
ed4e1582bf
commit
e6997f706e
9 changed files with 29 additions and 30 deletions
|
@ -21,6 +21,6 @@ do
|
|||
cp -f "$suite/.libs/lib$suite.$EXT" $DIRECTORY
|
||||
done
|
||||
|
||||
sudo cp .libs/libtest.0.dylib /usr/local/lib/libtest.0.dylib
|
||||
#sudo cp .libs/libtest.0.dylib /usr/local/lib/libtest.0.dylib
|
||||
|
||||
echo "Test suites installed."
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
//! context for test-specific random number generator
|
||||
static RND_CTX rndContext;
|
||||
|
||||
char *
|
||||
int
|
||||
GenerateExecKey(char *runSeed, char *suiteName,
|
||||
char *testName, int iterationNumber)
|
||||
{
|
||||
if(runSeed == NULL || suiteName == NULL ||
|
||||
testName == NULL || iterationNumber < 0) {
|
||||
fprintf(stderr, "Error: Incorrect parameter given to GenerateExecKey function\n");
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
char iterationString[256];
|
||||
|
@ -34,14 +34,12 @@ GenerateExecKey(char *runSeed, char *suiteName,
|
|||
|
||||
char *buffer = SDL_malloc(entireString);
|
||||
if(!buffer) {
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_snprintf(buffer, entireString, "%s/%s/%s/%d", runSeed, suiteName,
|
||||
testName, iterationNumber);
|
||||
|
||||
//printf("Debug: %s", buffer);
|
||||
|
||||
MD5_CTX md5Context;
|
||||
utl_md5Init(&md5Context);
|
||||
|
||||
|
@ -50,21 +48,20 @@ GenerateExecKey(char *runSeed, char *suiteName,
|
|||
|
||||
SDL_free(buffer);
|
||||
|
||||
const int keyLength = SDL_strlen(md5Context.digest);
|
||||
char *key = SDL_malloc(keyLength);
|
||||
SDL_snprintf(key, keyLength, "%s", md5Context.digest);
|
||||
char *execKey = md5Context.digest;
|
||||
|
||||
return key;
|
||||
int key = execKey[4] << 24 |
|
||||
execKey[9] << 16 |
|
||||
execKey[13] << 8 |
|
||||
execKey[3] << 0;
|
||||
|
||||
return abs(key);
|
||||
}
|
||||
|
||||
void
|
||||
InitFuzzer(char *execKey)
|
||||
InitFuzzer(int execKey)
|
||||
{
|
||||
//int a = execKey[8,9,10,11];
|
||||
int a = execKey[8] | execKey[9] | execKey[10] | execKey[11];
|
||||
int b = execKey[12] | execKey[13] | execKey[14] | execKey[15];
|
||||
|
||||
utl_randomInit(&rndContext, a, b);
|
||||
utl_randomInit(&rndContext, execKey, execKey / 0xfafafafa);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
/*!
|
||||
* Inits the fuzzer for a test
|
||||
*/
|
||||
void InitFuzzer(char *execKey);
|
||||
void InitFuzzer(int execKey);
|
||||
|
||||
|
||||
/*!
|
||||
|
@ -113,6 +113,6 @@ char *RandomAsciiStringWithMaximumLength(int maxLength);
|
|||
* \return Generated execution key as blob of 16 bytes. It needs be deallocated.
|
||||
* On error, returns NULL.
|
||||
*/
|
||||
char *GenerateExecKey(char *runSeed, char *suiteName, char *testName, int interationNumber);
|
||||
int GenerateExecKey(char *runSeed, char *suiteName, char *testName, int interationNumber);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef void (*SuiteEndedFp)(int testsPassed, int testsFailed, int testsSkipped,
|
|||
time_t endTime, double totalRuntime);
|
||||
|
||||
typedef void (*TestStartedFp)(const char *testName, const char *suiteName,
|
||||
const char *testDescription, char *execKey, time_t startTime);
|
||||
const char *testDescription, int execKey, time_t startTime);
|
||||
typedef void (*TestEndedFp)(const char *testName, const char *suiteName, int testResult,
|
||||
time_t endTime, double totalRuntime);
|
||||
|
||||
|
@ -86,7 +86,7 @@ extern AssertSummaryFp AssertSummary;
|
|||
extern LogFp Log;
|
||||
|
||||
//! \todo move these two away from here
|
||||
extern char *globalExecKey;
|
||||
extern int globalExecKey;
|
||||
//! Run seed for harness
|
||||
extern char *runSeed;
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
|
|||
|
||||
void
|
||||
PlainTestStarted(const char *testName, const char *suiteName,
|
||||
const char *testDescription, char *execKey, time_t startTime)
|
||||
const char *testDescription, int execKey, time_t startTime)
|
||||
{
|
||||
Output(indentLevel++, "Executing test: %s (in %s). Exec key: %X", testName, suiteName, execKey);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ void PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
|
|||
* \param startTime When the test started to execute
|
||||
*/
|
||||
void PlainTestStarted(const char *testName, const char *suiteName,
|
||||
const char *testDescription, char *execKey, time_t startTime);
|
||||
const char *testDescription, int execKey, time_t startTime);
|
||||
|
||||
/*!
|
||||
* Prints information about the test test that was just executed
|
||||
|
|
|
@ -112,10 +112,10 @@ char *runSeed = NULL;
|
|||
|
||||
|
||||
//! Variable is used to pass the generated execution key to a test
|
||||
char *globalExecKey = NULL;
|
||||
int globalExecKey = 0;
|
||||
|
||||
//! Execution key that user supplied via command options
|
||||
char *userExecKey = NULL;
|
||||
int userExecKey = 0;
|
||||
|
||||
//! How man time a test will be invocated
|
||||
int testInvocationCount = 1;
|
||||
|
@ -716,7 +716,7 @@ CheckTestRequirements(TestCase *testCase)
|
|||
* \param test result
|
||||
*/
|
||||
int
|
||||
RunTest(TestCase *testCase, char *execKey)
|
||||
RunTest(TestCase *testCase, int execKey)
|
||||
{
|
||||
if(!testCase) {
|
||||
return -1;
|
||||
|
@ -765,7 +765,7 @@ RunTest(TestCase *testCase, char *execKey)
|
|||
* \return The return value of the test. Zero means success, non-zero failure.
|
||||
*/
|
||||
int
|
||||
ExecuteTest(TestCase *testItem, char *execKey) {
|
||||
ExecuteTest(TestCase *testItem, int execKey) {
|
||||
int retVal = -1;
|
||||
|
||||
if(execute_inproc) {
|
||||
|
@ -1121,7 +1121,9 @@ ParseOptions(int argc, char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
userExecKey = execKeyString;
|
||||
// \todo User given string should be handled as a string
|
||||
// representing a hex digit
|
||||
userExecKey = atoi(execKeyString);
|
||||
}
|
||||
else if(SDL_strcmp(arg, "--test") == 0 || SDL_strcmp(arg, "-t") == 0) {
|
||||
only_selected_test = 1;
|
||||
|
@ -1341,7 +1343,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
UnloadTestCases(testCases);
|
||||
UnloadTestSuites(suites); // crashes here with -ts case1
|
||||
UnloadTestSuites(suites);
|
||||
|
||||
const Uint32 endTicks = SDL_GetTicks();
|
||||
const double totalRunTime = (endTicks - startTicks) / 1000.0f;
|
||||
|
|
|
@ -351,7 +351,7 @@ XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
|
|||
|
||||
void
|
||||
XMLTestStarted(const char *testName, const char *suiteName,
|
||||
const char *testDescription, char *execKey, time_t startTime)
|
||||
const char *testDescription, int execKey, time_t startTime)
|
||||
{
|
||||
char * output = XMLOpenElement(testElementName);
|
||||
XMLOutputter(indentLevel++, YES, output);
|
||||
|
|
|
@ -59,7 +59,7 @@ void XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
|
|||
* \param startTime When the test started to execute
|
||||
*/
|
||||
void XMLTestStarted(const char *testName, const char *suiteName,
|
||||
const char *testDescription, char *execKey, time_t startTime);
|
||||
const char *testDescription, int execKey, time_t startTime);
|
||||
|
||||
/*!
|
||||
* Prints information about the test test that was just executed in XML
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue