Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
6132d65f
Commit
6132d65f
authored
Jul 25, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing the execution key generator.
Fixed --iterations option.
parent
46f39ab2
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
64 additions
and
53 deletions
+64
-53
SDL_test.c
test/test-automation/SDL_test.c
+1
-1
SDL_test.h
test/test-automation/SDL_test.h
+1
-1
fuzzer.c
test/test-automation/fuzzer/fuzzer.c
+33
-26
fuzzer.h
test/test-automation/fuzzer/fuzzer.h
+4
-3
logger.h
test/test-automation/logger.h
+4
-3
plain_logger.c
test/test-automation/plain_logger.c
+1
-1
plain_logger.h
test/test-automation/plain_logger.h
+1
-1
runner.c
test/test-automation/runner.c
+15
-13
testdummy.c
test/test-automation/testdummy/testdummy.c
+2
-2
xml_logger.c
test/test-automation/xml_logger.c
+1
-1
xml_logger.h
test/test-automation/xml_logger.h
+1
-1
No files found.
test/test-automation/SDL_test.c
View file @
6132d65f
...
...
@@ -37,7 +37,7 @@ int _testAssertsFailed;
int
_testAssertsPassed
;
void
_InitTestEnvironment
(
c
onst
int
execKey
)
_InitTestEnvironment
(
c
har
*
execKey
)
{
// The execKey gets corrupted while passing arguments
// hence the global variable to circumvent the problem
...
...
test/test-automation/SDL_test.h
View file @
6132d65f
...
...
@@ -69,7 +69,7 @@ typedef struct TestCaseReference {
* Initialized the test environment such as asserts. Must be called at
* the beginning of every test case, before doing anything else.
*/
void
_InitTestEnvironment
(
c
onst
int
execKey
);
void
_InitTestEnvironment
(
c
har
*
execKey
);
/*!
* Deinitializes the test environment and
...
...
test/test-automation/fuzzer/fuzzer.c
View file @
6132d65f
...
...
@@ -5,16 +5,16 @@
//! context for test-specific random number generator
RND_CTX
rndContext3
;
static
RND_CTX
rndContext
;
int
GenerateExecKey
(
CRC32_CTX
crcContext
,
char
*
runSeed
,
char
*
suiteName
,
char
*
GenerateExecKey
(
char
*
runSeed
,
char
*
suiteName
,
char
*
testName
,
int
iterationNumber
)
{
if
(
runSeed
==
NULL
||
suiteName
==
NULL
||
testName
==
NULL
||
iterationNumber
<
0
)
{
fprintf
(
stderr
,
"Incorrect parameter given to GenerateExecKey function
\n
"
);
return
-
1
;
fprintf
(
stderr
,
"
Error:
Incorrect parameter given to GenerateExecKey function
\n
"
);
return
NULL
;
}
char
iterationString
[
256
];
...
...
@@ -30,33 +30,41 @@ GenerateExecKey(CRC32_CTX crcContext, char *runSeed, char *suiteName,
// size of the entire + 3 for slashes and + 1 for '\0'
const
int
entireString
=
runSeedLength
+
suiteNameLength
+
testNameLength
+
iterationString
+
3
+
1
;
testNameLength
+
iterationString
Length
+
3
+
1
;
int
result
=
0
;
char
*
buffer
=
SDL_malloc
(
entireString
);
if
(
!
buffer
)
{
return
NULL
;
}
SDL_snprintf
(
buffer
,
entireString
,
"%s/%s/%s/%d"
,
runSeed
,
suiteName
,
testName
,
iterationNumber
);
//printf("Debug: %s", buffer);
/* Let's take a hash from the strings separately because
* it's really slow to calculate md5 or crc32 for a really long string
* like 'runSeed/testSuiteName/testName/iteration'
*/
MD5_CTX
md5Context
;
utl_md5Init
(
&
md5Context
);
utl_md5Update
(
&
md5Context
,
runSeed
,
runSeedLength
);
utl_md5Update
(
&
md5Context
,
suiteName
,
suiteNameLength
);
utl_md5Update
(
&
md5Context
,
testName
,
testNameLength
);
utl_md5Update
(
&
md5Context
,
iterationString
,
iterationStringLength
);
utl_md5Update
(
&
md5Context
,
buffer
,
entireString
);
utl_md5Final
(
&
md5Context
);
utl_crc32Calc
(
&
crcContext
,
md5Context
.
digest
,
sizeof
(
md5Context
.
digest
),
&
result
);
SDL_free
(
buffer
);
return
abs
(
result
);
// makes sure that the key is positive
const
int
keyLength
=
SDL_strlen
(
md5Context
.
digest
);
char
*
key
=
SDL_malloc
(
keyLength
);
SDL_snprintf
(
key
,
keyLength
,
"%s"
,
md5Context
.
digest
);
return
key
;
}
void
InitFuzzer
(
c
onst
int
execKey
)
InitFuzzer
(
c
har
*
execKey
)
{
utl_randomInit
(
&
rndContext3
,
globalExecKey
,
globalExecKey
/
0xfafafafa
);
//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
);
}
void
...
...
@@ -68,13 +76,13 @@ DeinitFuzzer()
int
RandomInteger
()
{
return
utl_randomInt
(
&
rndContext
3
);
return
utl_randomInt
(
&
rndContext
);
}
int
RandomPositiveInteger
()
{
return
abs
(
utl_randomInt
(
&
rndContext
3
));
return
abs
(
utl_randomInt
(
&
rndContext
));
}
int
...
...
@@ -84,7 +92,7 @@ RandomIntegerInRange(int min, int max)
return
-
1
;
// Doesn't really make sense to return -1 on error?
}
int
number
=
utl_randomInt
(
&
rndContext
3
);
int
number
=
utl_randomInt
(
&
rndContext
);
number
=
abs
(
number
);
return
(
number
%
((
max
+
1
)
-
min
))
+
min
;
...
...
@@ -130,13 +138,12 @@ RandomAsciiStringWithMaximumLength(int maxSize)
return
NULL
;
}
const
int
size
=
abs
(
RandomInteger
)
%
maxSize
;
int
size
=
abs
(
RandomInteger
)
%
maxSize
;
char
*
string
=
SDL_malloc
(
size
*
sizeof
(
size
));
int
counter
=
0
;
for
(
;
counter
<
size
;
++
counter
)
{
char
character
=
(
char
)
RandomIntegerInRange
(
1
,
127
);
string
[
counter
]
=
character
;
string
[
counter
]
=
(
char
)
RandomIntegerInRange
(
1
,
127
);
}
string
[
counter
]
=
'\0'
;
...
...
test/test-automation/fuzzer/fuzzer.h
View file @
6132d65f
...
...
@@ -29,7 +29,7 @@
/*!
* Inits the fuzzer for a test
*/
void
InitFuzzer
(
c
onst
int
execKey
);
void
InitFuzzer
(
c
har
*
execKey
);
/*!
...
...
@@ -110,8 +110,9 @@ char *RandomAsciiStringWithMaximumLength(int maxLength);
* \param testName Test name
* \param iteration Number of test iteration
*
* \return Generated execution key
* \return Generated execution key as blob of 16 bytes. It needs be deallocated.
* On error, returns NULL.
*/
int
GenerateExecKey
(
CRC32_CTX
crcContext
,
char
*
runSeed
,
char
*
suiteName
,
char
*
testName
,
int
interationNumber
);
char
*
GenerateExecKey
(
char
*
runSeed
,
char
*
suiteName
,
char
*
testName
,
int
interationNumber
);
#endif
test/test-automation/logger.h
View file @
6132d65f
...
...
@@ -37,7 +37,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
,
int
execKey
,
time_t
startTime
);
const
char
*
testDescription
,
char
*
execKey
,
time_t
startTime
);
typedef
void
(
*
TestEndedFp
)(
const
char
*
testName
,
const
char
*
suiteName
,
int
testResult
,
time_t
endTime
,
double
totalRuntime
);
...
...
@@ -67,9 +67,10 @@ extern AssertWithValuesFp AssertWithValues;
extern
AssertSummaryFp
AssertSummary
;
extern
LogFp
Log
;
extern
int
globalExecKey
;
//! \todo move these two away from here
extern
char
*
globalExecKey
;
//! Run seed for harness
extern
c
onst
c
har
*
runSeed
;
extern
char
*
runSeed
;
#endif
test/test-automation/plain_logger.c
View file @
6132d65f
...
...
@@ -82,7 +82,7 @@ PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
void
PlainTestStarted
(
const
char
*
testName
,
const
char
*
suiteName
,
const
char
*
testDescription
,
int
execKey
,
time_t
startTime
)
const
char
*
testDescription
,
char
*
execKey
,
time_t
startTime
)
{
Output
(
indentLevel
++
,
"Executing test: %s (in %s). Exec key: %X"
,
testName
,
suiteName
,
execKey
);
}
...
...
test/test-automation/plain_logger.h
View file @
6132d65f
...
...
@@ -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
,
int
execKey
,
time_t
startTime
);
const
char
*
testDescription
,
char
*
execKey
,
time_t
startTime
);
/*!
* Prints information about the test test that was just executed
...
...
test/test-automation/runner.c
View file @
6132d65f
...
...
@@ -91,10 +91,10 @@ int universal_timeout = -1;
//! Default directory of the test suites
#define DEFAULT_TEST_DIRECTORY "tests/"
int
globalExecKey
=
-
1
;
c
onst
c
har
*
runSeed
=
"seed"
;
char
*
globalExecKey
=
NULL
;
char
*
runSeed
=
"seed"
;
int
userExecKey
=
0
;
char
*
userExecKey
=
NULL
;
//! How man time a test will be invocated
int
testInvocationCount
=
1
;
...
...
@@ -689,7 +689,7 @@ CheckTestRequirements(TestCase *testCase)
* \param test result
*/
int
RunTest
(
TestCase
*
testCase
,
c
onst
int
execKey
)
RunTest
(
TestCase
*
testCase
,
c
har
*
execKey
)
{
if
(
!
testCase
)
{
return
-
1
;
...
...
@@ -738,7 +738,7 @@ RunTest(TestCase *testCase, const int execKey)
* \return The return value of the test. Zero means success, non-zero failure.
*/
int
ExecuteTest
(
TestCase
*
testItem
,
c
onst
int
execKey
)
{
ExecuteTest
(
TestCase
*
testItem
,
c
har
*
execKey
)
{
int
retVal
=
-
1
;
if
(
execute_inproc
)
{
...
...
@@ -948,6 +948,10 @@ ParseOptions(int argc, char *argv[])
}
testInvocationCount
=
atoi
(
iterationsString
);
if
(
testInvocationCount
<
1
)
{
printf
(
"Iteration value has to bigger than 0.
\n
"
);
exit
(
1
);
}
}
else
if
(
SDL_strcmp
(
arg
,
"--exec-key"
)
==
0
)
{
char
*
execKeyString
=
NULL
;
...
...
@@ -959,7 +963,7 @@ ParseOptions(int argc, char *argv[])
exit
(
1
);
}
userExecKey
=
atoi
(
execKeyString
)
;
userExecKey
=
execKeyString
;
}
else
if
(
SDL_strcmp
(
arg
,
"--test"
)
==
0
||
SDL_strcmp
(
arg
,
"-t"
)
==
0
)
{
only_selected_test
=
1
;
...
...
@@ -1047,9 +1051,6 @@ main(int argc, char *argv[])
{
ParseOptions
(
argc
,
argv
);
CRC32_CTX
crcContext
;
utl_crc32Init
(
&
crcContext
);
// print: Testing against SDL version fuu (rev: bar) if verbose == true
char
*
testSuiteName
=
NULL
;
...
...
@@ -1122,10 +1123,10 @@ main(int argc, char *argv[])
int
currentIteration
=
testInvocationCount
;
while
(
currentIteration
>
0
)
{
if
(
userExecKey
!=
0
)
{
if
(
userExecKey
!=
NULL
)
{
globalExecKey
=
userExecKey
;
}
else
{
c
onst
int
execKey
=
GenerateExecKey
(
crcContext
,
runSeed
,
testItem
->
suiteName
,
c
har
*
execKey
=
GenerateExecKey
(
runSeed
,
testItem
->
suiteName
,
testItem
->
testName
,
currentIteration
);
globalExecKey
=
execKey
;
}
...
...
@@ -1142,6 +1143,9 @@ main(int argc, char *argv[])
TestEnded
(
testItem
->
testName
,
testItem
->
suiteName
,
retVal
,
time
(
0
),
testTotalRuntime
);
currentIteration
--
;
SDL_free
(
globalExecKey
);
globalExecKey
=
NULL
;
}
}
...
...
@@ -1162,7 +1166,5 @@ main(int argc, char *argv[])
// Some SDL subsystem might be init'ed so shut them down
SDL_Quit
();
utl_crc32Done
(
&
crcContext
);
return
(
totalTestFailureCount
?
1
:
0
);
}
test/test-automation/testdummy/testdummy.c
View file @
6132d65f
...
...
@@ -107,7 +107,7 @@ dummycase1(void *arg)
Log
(
0
,
"%d"
,
random
);
}
//Log(0, "Random: %s", RandomAsciiStringWithMaximumLength(2
));
Log
(
0
,
"Random: %s"
,
RandomAsciiString
(
));
}
void
...
...
@@ -121,7 +121,7 @@ dummycase2(void *arg)
void
dummycase3
(
void
*
arg
)
{
while
(
1
);
while
(
0
);
//AssertTrue(1, "Assert message");
}
test/test-automation/xml_logger.c
View file @
6132d65f
...
...
@@ -324,7 +324,7 @@ XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
void
XMLTestStarted
(
const
char
*
testName
,
const
char
*
suiteName
,
const
char
*
testDescription
,
int
execKey
,
time_t
startTime
)
const
char
*
testDescription
,
char
*
execKey
,
time_t
startTime
)
{
char
*
output
=
XMLOpenElement
(
testElementName
);
XMLOutputter
(
indentLevel
++
,
YES
,
output
);
...
...
test/test-automation/xml_logger.h
View file @
6132d65f
...
...
@@ -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
,
int
execKey
,
time_t
startTime
);
const
char
*
testDescription
,
char
*
execKey
,
time_t
startTime
);
/*!
* Prints information about the test test that was just executed in XML
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment