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
8e4d7085
Commit
8e4d7085
authored
Aug 11, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added random number generators for Uint8, Sint8, Uint16, Sint16,
Uint64 and Sint64.
parent
694dda2a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
1 deletion
+113
-1
fuzzer.c
test/test-automation/src/libSDLtest/fuzzer/fuzzer.c
+62
-1
fuzzer.h
test/test-automation/src/libSDLtest/fuzzer/fuzzer.h
+49
-0
testdummy.c
test/test-automation/tests/testdummy/testdummy.c
+2
-0
No files found.
test/test-automation/src/libSDLtest/fuzzer/fuzzer.c
View file @
8e4d7085
...
@@ -26,6 +26,9 @@
...
@@ -26,6 +26,9 @@
#include "fuzzer.h"
#include "fuzzer.h"
/*!
* Note: doxygen documentation markup is in the header file.
*/
//! context for test-specific random number generator
//! context for test-specific random number generator
static
RND_CTX
rndContext
;
static
RND_CTX
rndContext
;
...
@@ -105,6 +108,30 @@ DeinitFuzzer()
...
@@ -105,6 +108,30 @@ DeinitFuzzer()
}
}
Uint8
RandomUint8
()
{
return
(
Uint8
)
utl_randomInt
(
&
rndContext
)
&
0x000000FF
;
}
Sint8
RandomSint8
()
{
return
(
Sint8
)
utl_randomInt
(
&
rndContext
)
&
0x000000FF
;
}
Uint16
RandomUint16
()
{
return
(
Uint16
)
utl_randomInt
(
&
rndContext
)
&
0x0000FFFF
;
}
Sint16
RandomSint16
()
{
return
(
Sint16
)
utl_randomInt
(
&
rndContext
)
&
0x0000FFFF
;
}
Sint32
Sint32
RandomInteger
()
RandomInteger
()
{
{
...
@@ -117,6 +144,36 @@ RandomPositiveInteger()
...
@@ -117,6 +144,36 @@ RandomPositiveInteger()
return
(
Uint32
)
utl_randomInt
(
&
rndContext
);
return
(
Uint32
)
utl_randomInt
(
&
rndContext
);
}
}
Uint64
RandomUint64
()
{
Uint8
string
[
16
];
int
counter
=
0
;
for
(
;
counter
<
16
;
++
counter
)
{
string
[
counter
]
=
(
Uint8
)
RandomIntegerInRange
(
0
,
255
);
}
Uint64
*
value
=
(
Uint64
*
)
string
;
return
value
[
0
];
}
Sint64
RandomSint64
()
{
Uint8
string
[
16
];
int
counter
=
0
;
for
(
;
counter
<
16
;
++
counter
)
{
string
[
counter
]
=
(
Uint8
)
RandomIntegerInRange
(
0
,
255
);
}
Sint64
*
value
=
(
Sint64
*
)
string
;
return
value
[
0
];
}
Sint32
Sint32
RandomIntegerInRange
(
Sint32
pMin
,
Sint32
pMax
)
RandomIntegerInRange
(
Sint32
pMin
,
Sint32
pMax
)
{
{
...
@@ -507,6 +564,10 @@ RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDoma
...
@@ -507,6 +564,10 @@ RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDoma
return
retVal
;
return
retVal
;
}
}
float
RandomFloat
()
{
return
(
float
)
utl_randomInt
(
&
rndContext
)
/
UINT_MAX
;
}
char
*
char
*
RandomAsciiString
()
RandomAsciiString
()
{
{
...
@@ -521,7 +582,7 @@ RandomAsciiStringWithMaximumLength(int maxSize)
...
@@ -521,7 +582,7 @@ RandomAsciiStringWithMaximumLength(int maxSize)
}
}
int
size
=
(
abs
(
RandomInteger
())
%
(
maxSize
+
1
))
+
1
;
int
size
=
(
abs
(
RandomInteger
())
%
(
maxSize
+
1
))
+
1
;
char
*
string
=
SDL_malloc
(
size
*
sizeof
(
size
));
char
*
string
=
SDL_malloc
(
size
*
sizeof
(
char
));
int
counter
=
0
;
int
counter
=
0
;
for
(
;
counter
<
size
;
++
counter
)
{
for
(
;
counter
<
size
;
++
counter
)
{
...
...
test/test-automation/src/libSDLtest/fuzzer/fuzzer.h
View file @
8e4d7085
...
@@ -40,6 +40,36 @@ void InitFuzzer(Uint64 execKey);
...
@@ -40,6 +40,36 @@ void InitFuzzer(Uint64 execKey);
void
DeinitFuzzer
();
void
DeinitFuzzer
();
/*!
* Returns a random Uint8
*
* \returns Generated integer
*/
Uint8
RandomUint8
();
/*!
* Returns a random Sint8
*
* \returns Generated signed integer
*/
Sint8
RandomSint8
();
/*!
* Returns a random Uint16
*
* \returns Generated integer
*/
Uint16
RandomUint16
();
/*!
* Returns a random Sint16
*
* \returns Generated signed integer
*/
Sint16
RandomSint16
();
/*!
/*!
* Returns a random integer
* Returns a random integer
*
*
...
@@ -55,6 +85,25 @@ Sint32 RandomInteger();
...
@@ -55,6 +85,25 @@ Sint32 RandomInteger();
*/
*/
Uint32
RandomPositiveInteger
();
Uint32
RandomPositiveInteger
();
/*!
* Returns random Uint64.
*
* \returns Generated integer
*/
Uint64
RandomUint64
();
/*!
* Returns random Sint64.
*
* \returns Generated signed integer
*/
Sint64
RandomSint64
();
/*!
* Returns random float in range [0.0 - 1.0] (inclusive)
*/
float
RandomFloat
();
/*!
/*!
* Returns a random boundary value for Uint8 within the given boundaries.
* Returns a random boundary value for Uint8 within the given boundaries.
...
...
test/test-automation/tests/testdummy/testdummy.c
View file @
8e4d7085
...
@@ -100,6 +100,8 @@ dummycase1(void *arg)
...
@@ -100,6 +100,8 @@ dummycase1(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
(;
01
;
)
printf
(
"%d
\n
"
,
RandomSint16
());
for
(
;
0
;
)
{
for
(
;
0
;
)
{
//Log(0, "sint8: %d", RandomSint8BoundaryValue(-11, 10, SDL_TRUE));
//Log(0, "sint8: %d", RandomSint8BoundaryValue(-11, 10, SDL_TRUE));
...
...
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