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
f4870f39
Commit
f4870f39
authored
Aug 28, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added elementary fuzzer-randgen invocation count.
parent
ab1eaa67
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
10 deletions
+81
-10
SDL_test.c
test/test-automation/src/libSDLtest/SDL_test.c
+24
-6
fuzzer.c
test/test-automation/src/libSDLtest/fuzzer/fuzzer.c
+50
-2
fuzzer.h
test/test-automation/src/libSDLtest/fuzzer/fuzzer.h
+4
-0
testdummy.c
test/test-automation/tests/testdummy/testdummy.c
+3
-2
No files found.
test/test-automation/src/libSDLtest/SDL_test.c
View file @
f4870f39
...
@@ -65,6 +65,8 @@ _QuitTestEnvironment()
...
@@ -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() {
...
@@ -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, ...)
...
@@ -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, ...)
...
@@ -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, ...)
...
@@ -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
}
}
test/test-automation/src/libSDLtest/fuzzer/fuzzer.c
View file @
f4870f39
...
@@ -33,6 +33,9 @@
...
@@ -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)
...
@@ -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()
...
@@ -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()
...
@@ -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)
...
@@ -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)
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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)
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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()
...
@@ -574,6 +615,8 @@ RandomUnitDouble()
float
float
RandomFloat
()
RandomFloat
()
{
{
invocationCounter
++
;
// \todo to be implemented
// \todo to be implemented
return
0
.
0
f
;
return
0
.
0
f
;
}
}
...
@@ -581,6 +624,8 @@ RandomFloat()
...
@@ -581,6 +624,8 @@ RandomFloat()
double
double
RandomDouble
()
RandomDouble
()
{
{
invocationCounter
++
;
// \todo to be implemented
// \todo to be implemented
return
0
.
0
f
;
return
0
.
0
f
;
}
}
...
@@ -589,12 +634,15 @@ RandomDouble()
...
@@ -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
;
}
}
...
...
test/test-automation/src/libSDLtest/fuzzer/fuzzer.h
View file @
f4870f39
...
@@ -353,5 +353,9 @@ char *RandomAsciiStringWithMaximumLength(int maxLength);
...
@@ -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
test/test-automation/tests/testdummy/testdummy.c
View file @
f4870f39
...
@@ -103,7 +103,8 @@ test_dummy1(void *arg)
...
@@ -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
;
)
...
...
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