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
Hide 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()
_testReturnValue
=
TEST_RESULT_NO_ASSERT
;
}
Log
(
time
(
0
),
"Fuzzer invocation count: %d"
,
GetInvocationCount
());
DeinitFuzzer
();
return
_testReturnValue
;
...
...
@@ -75,6 +77,25 @@ _CountFailedAsserts() {
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
AssertEquals
(
int
expected
,
int
actual
,
char
*
message
,
...)
...
...
@@ -93,8 +114,7 @@ AssertEquals(int expected, int actual, char *message, ...)
_testReturnValue
=
TEST_RESULT_FAILURE
;
_testAssertsFailed
++
;
if
(
canBailOut
)
exit
(
TEST_RESULT_FAILURE
);
// bail out from the test
_BailOut
();
}
else
{
AssertWithValues
(
"AssertEquals"
,
1
,
buf
,
actual
,
expected
,
time
(
0
));
...
...
@@ -119,8 +139,7 @@ AssertTrue(int condition, char *message, ...)
_testReturnValue
=
TEST_RESULT_FAILURE
;
_testAssertsFailed
++
;
if
(
canBailOut
)
exit
(
TEST_RESULT_FAILURE
);
// bail out from the test
_BailOut
();
}
else
{
Assert
(
"AssertTrue"
,
1
,
buf
,
time
(
0
));
...
...
@@ -159,7 +178,6 @@ AssertFail(char *message, ...)
_testReturnValue
=
TEST_RESULT_FAILURE
;
_testAssertsFailed
++
;
if
(
canBailOut
)
exit
(
TEST_RESULT_FAILURE
);
// bail out from the test
_BailOut
();
}
test/test-automation/src/libSDLtest/fuzzer/fuzzer.c
View file @
f4870f39
...
...
@@ -33,6 +33,9 @@
//! context for test-specific random number generator
static
RND_CTX
rndContext
;
//! Counts invocation of fuzzer generator functions
int
invocationCounter
=
0
;
Uint64
GenerateExecKey
(
char
*
runSeed
,
char
*
suiteName
,
char
*
testName
,
int
iterationNumber
)
...
...
@@ -99,45 +102,63 @@ InitFuzzer(Uint64 execKey)
utl_randomInit
(
&
rndContext
,
a
,
b
);
}
int
GetInvocationCount
()
{
return
invocationCounter
;
}
void
DeinitFuzzer
()
{
invocationCounter
=
0
;
}
Uint8
RandomUint8
()
{
invocationCounter
++
;
return
(
Uint8
)
utl_randomInt
(
&
rndContext
)
&
0x000000FF
;
}
Sint8
RandomSint8
()
{
invocationCounter
++
;
return
(
Sint8
)
utl_randomInt
(
&
rndContext
)
&
0x000000FF
;
}
Uint16
RandomUint16
()
{
invocationCounter
++
;
return
(
Uint16
)
utl_randomInt
(
&
rndContext
)
&
0x0000FFFF
;
}
Sint16
RandomSint16
()
{
invocationCounter
++
;
return
(
Sint16
)
utl_randomInt
(
&
rndContext
)
&
0x0000FFFF
;
}
Sint32
RandomSint32
()
{
invocationCounter
++
;
return
(
Sint32
)
utl_randomInt
(
&
rndContext
);
}
Uint32
RandomUint32
()
{
invocationCounter
++
;
return
(
Uint32
)
utl_randomInt
(
&
rndContext
);
}
...
...
@@ -146,6 +167,8 @@ RandomUint64()
{
Uint64
value
;
invocationCounter
++
;
Uint32
*
vp
=
(
Uint32
*
)
&
value
;
vp
[
0
]
=
RandomSint32
();
vp
[
1
]
=
RandomSint32
();
...
...
@@ -158,6 +181,8 @@ RandomSint64()
{
Uint64
value
;
invocationCounter
++
;
Uint32
*
vp
=
(
Uint32
*
)
&
value
;
vp
[
0
]
=
RandomSint32
();
vp
[
1
]
=
RandomSint32
();
...
...
@@ -180,7 +205,7 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
return
min
;
}
Sint32
number
=
RandomSint32
();
Sint32
number
=
RandomSint32
();
// invocation count increment in there
return
(
number
%
((
max
+
1
)
-
min
))
+
min
;
}
...
...
@@ -292,6 +317,8 @@ RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
SDL_free
(
buffer
);
invocationCounter
++
;
return
retVal
;
}
...
...
@@ -316,6 +343,8 @@ RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDoma
SDL_free
(
buffer
);
invocationCounter
++
;
return
retVal
;
}
...
...
@@ -340,6 +369,8 @@ RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDoma
SDL_free
(
buffer
);
invocationCounter
++
;
return
retVal
;
}
...
...
@@ -364,6 +395,8 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma
SDL_free
(
buffer
);
invocationCounter
++
;
return
retVal
;
}
...
...
@@ -481,6 +514,8 @@ RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain)
SDL_free
(
buffer
);
invocationCounter
++
;
return
retVal
;
}
...
...
@@ -506,6 +541,8 @@ RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDoma
SDL_free
(
buffer
);
invocationCounter
++
;
return
retVal
;
}
...
...
@@ -531,6 +568,8 @@ RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDoma
SDL_free
(
buffer
);
invocationCounter
++
;
return
retVal
;
}
...
...
@@ -556,6 +595,8 @@ RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDoma
SDL_free
(
buffer
);
invocationCounter
++
;
return
retVal
;
}
...
...
@@ -574,6 +615,8 @@ RandomUnitDouble()
float
RandomFloat
()
{
invocationCounter
++
;
// \todo to be implemented
return
0
.
0
f
;
}
...
...
@@ -581,6 +624,8 @@ RandomFloat()
double
RandomDouble
()
{
invocationCounter
++
;
// \todo to be implemented
return
0
.
0
f
;
}
...
...
@@ -589,12 +634,15 @@ RandomDouble()
char
*
RandomAsciiString
()
{
// note: invocationCounter is increment in the RandomAsciiStringWithMaximumLenght
return
RandomAsciiStringWithMaximumLength
(
255
);
}
char
*
RandomAsciiStringWithMaximumLength
(
int
maxSize
)
{
invocationCounter
++
;
if
(
maxSize
<
1
)
{
return
NULL
;
}
...
...
test/test-automation/src/libSDLtest/fuzzer/fuzzer.h
View file @
f4870f39
...
...
@@ -353,5 +353,9 @@ char *RandomAsciiStringWithMaximumLength(int maxLength);
*/
Uint64
GenerateExecKey
(
char
*
runSeed
,
char
*
suiteName
,
char
*
testName
,
int
iterationNumber
);
/*!
* Returns test specific invocation count for the fuzzer.
*/
int
GetInvocationCount
();
#endif
test/test-automation/tests/testdummy/testdummy.c
View file @
f4870f39
...
...
@@ -103,8 +103,9 @@ test_dummy1(void *arg)
//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
for
(;
1
;
)
printf
(
"%f
\n
"
,
RandomUnitFloat
());
int
c
=
0
;
//for(; c < 100 ; c++)
printf
(
"%f
\n
"
,
RandomUnitFloat
());
for
(;
0
;
)
printf
(
"%d
\n
"
,
RandomSint16
());
...
...
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