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
716a42e9
Commit
716a42e9
authored
Aug 04, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added functions that generate random boundary values
for Uint16, Uint32 and Uint64 to the fuzzer.
parent
e45c8d75
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
12 deletions
+106
-12
fuzzer.c
test/test-automation/fuzzer/fuzzer.c
+82
-8
fuzzer.h
test/test-automation/fuzzer/fuzzer.h
+16
-0
testdummy.c
test/test-automation/testdummy/testdummy.c
+8
-4
No files found.
test/test-automation/fuzzer/fuzzer.c
View file @
716a42e9
...
@@ -137,12 +137,14 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
...
@@ -137,12 +137,14 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
* If boundary2 < boundary1, the values are swapped.
* If boundary2 < boundary1, the values are swapped.
* If boundary1 == boundary2, value of boundary1 will be returned
* If boundary1 == boundary2, value of boundary1 will be returned
*
*
* Generating boundary values for Uint8
* Generating boundary values for Uint8
:
* BoundaryValues(sizeof(Uint8), 10, 20, True) -> [10,11,19,20]
* BoundaryValues(sizeof(Uint8), 10, 20, True) -> [10,11,19,20]
* BoundaryValues(sizeof(Uint8), 10, 20, False) -> [9,21]
* BoundaryValues(sizeof(Uint8), 10, 20, False) -> [9,21]
* BoundaryValues(sizeof(Uint8), 0, 15, True) -> [0, 1, 14, 15]
* BoundaryValues(sizeof(Uint8), 0, 15, True) -> [0, 1, 14, 15]
* BoundaryValues(sizeof(Uint8), 0, 15, False) -> [16]
* BoundaryValues(sizeof(Uint8), 0, 15, False) -> [16]
* BoundaryValues(sizeof(Uint8), 0, 255, False) -> []
* BoundaryValues(sizeof(Uint8), 0, 255, False) -> NULL
*
* Generator works the same for other types of unsigned integers.
*
*
* \param maxValue The biggest value that is acceptable for this data type.
* \param maxValue The biggest value that is acceptable for this data type.
* For instance, for Uint8 -> 255, Uint16 -> 65536 etc.
* For instance, for Uint8 -> 255, Uint16 -> 65536 etc.
...
@@ -154,7 +156,6 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
...
@@ -154,7 +156,6 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
* \param outBufferSize Size of outBuffer
* \param outBufferSize Size of outBuffer
*
*
* \returns NULL on error, outBuffer on success
* \returns NULL on error, outBuffer on success
*
*/
*/
Uint64
*
Uint64
*
GenerateUnsignedBoundaryValues
(
const
Uint64
maxValue
,
GenerateUnsignedBoundaryValues
(
const
Uint64
maxValue
,
...
@@ -183,17 +184,19 @@ GenerateUnsignedBoundaryValues(const Uint64 maxValue,
...
@@ -183,17 +184,19 @@ GenerateUnsignedBoundaryValues(const Uint64 maxValue,
}
}
else
if
(
validDomain
)
{
else
if
(
validDomain
)
{
tempBuf
[
index
++
]
=
boundary1
;
tempBuf
[
index
++
]
=
boundary1
;
if
(
boundary1
<
UINT64_MAX
)
tempBuf
[
index
++
]
=
boundary1
+
1
;
tempBuf
[
index
++
]
=
boundary1
+
1
;
tempBuf
[
index
++
]
=
boundary2
-
1
;
tempBuf
[
index
++
]
=
boundary2
-
1
;
tempBuf
[
index
++
]
=
boundary2
;
tempBuf
[
index
++
]
=
boundary2
;
}
}
else
{
else
{
if
(
boundary1
!=
0
)
{
if
(
boundary1
>
0
)
{
tempBuf
[
index
++
]
=
boundary1
-
1
;
tempBuf
[
index
++
]
=
boundary1
-
1
;
}
}
if
(
boundary2
!=
maxValue
)
{
if
(
boundary2
<
maxValue
)
{
tempBuf
[
index
++
]
=
boundary2
+
1
;
tempBuf
[
index
++
]
=
boundary2
+
1
;
}
}
}
}
...
@@ -223,13 +226,13 @@ RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
...
@@ -223,13 +226,13 @@ RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
Uint32
size
;
Uint32
size
;
// max value for Uint8
// max value for Uint8
const
Uint64
maxValue
=
255
;
const
Uint64
maxValue
=
UINT8_MAX
;
buffer
=
GenerateUnsignedBoundaryValues
(
maxValue
,
buffer
=
GenerateUnsignedBoundaryValues
(
maxValue
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
validDomain
,
buffer
,
&
size
);
if
(
buffer
==
NULL
)
{
if
(
buffer
==
NULL
)
{
return
0
;
// Change to some better error value? What would be better?
return
-
1
;
// Change to some better error value? What would be better?
}
}
Uint32
index
=
RandomInteger
()
%
size
;
Uint32
index
=
RandomInteger
()
%
size
;
...
@@ -240,6 +243,77 @@ RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
...
@@ -240,6 +243,77 @@ RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
return
retVal
;
return
retVal
;
}
}
Uint16
RandomUint16BoundaryValue
(
Uint16
boundary1
,
Uint16
boundary2
,
SDL_bool
validDomain
)
{
Uint64
*
buffer
=
NULL
;
Uint32
size
;
// max value for Uint16
const
Uint64
maxValue
=
UINT16_MAX
;
buffer
=
GenerateUnsignedBoundaryValues
(
maxValue
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
if
(
buffer
==
NULL
)
{
return
-
1
;
// Change to some better error value? What would be better?
}
Uint32
index
=
RandomInteger
()
%
size
;
Uint16
retVal
=
(
Uint16
)
buffer
[
index
];
SDL_free
(
buffer
);
return
retVal
;
}
Uint32
RandomUint32BoundaryValue
(
Uint32
boundary1
,
Uint32
boundary2
,
SDL_bool
validDomain
)
{
Uint64
*
buffer
=
NULL
;
Uint32
size
;
// max value for Uint32
const
Uint64
maxValue
=
UINT32_MAX
;
buffer
=
GenerateUnsignedBoundaryValues
(
maxValue
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
if
(
buffer
==
NULL
)
{
return
-
1
;
// Change to some better error value? What would be better?
}
Uint32
index
=
RandomInteger
()
%
size
;
Uint32
retVal
=
(
Uint32
)
buffer
[
index
];
SDL_free
(
buffer
);
return
retVal
;
}
Uint64
RandomUint64BoundaryValue
(
Uint64
boundary1
,
Uint64
boundary2
,
SDL_bool
validDomain
)
{
Uint64
*
buffer
=
NULL
;
Uint32
size
;
// max value for Uint64
const
Uint64
maxValue
=
UINT64_MAX
;
buffer
=
GenerateUnsignedBoundaryValues
(
maxValue
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
if
(
buffer
==
NULL
)
{
return
-
1
;
// Change to some better error value? What would be better?
}
Uint32
index
=
RandomInteger
()
%
size
;
Uint64
retVal
=
(
Uint64
)
buffer
[
index
];
SDL_free
(
buffer
);
return
retVal
;
}
Sint8
Sint8
RandomSint8BoundaryValue
()
RandomSint8BoundaryValue
()
...
...
test/test-automation/fuzzer/fuzzer.h
View file @
716a42e9
...
@@ -61,6 +61,22 @@ Uint32 RandomPositiveInteger();
...
@@ -61,6 +61,22 @@ Uint32 RandomPositiveInteger();
*/
*/
Uint8
RandomUint8BoundaryValue
(
Uint8
boundary1
,
Uint8
boundary2
,
SDL_bool
validDomain
);
Uint8
RandomUint8BoundaryValue
(
Uint8
boundary1
,
Uint8
boundary2
,
SDL_bool
validDomain
);
/*!
* todo add markup
*/
Uint16
RandomUint16BoundaryValue
(
Uint16
boundary1
,
Uint16
boundary2
,
SDL_bool
validDomain
);
/*!
* todo add markup
*/
Uint32
RandomUint32BoundaryValue
(
Uint32
boundary1
,
Uint32
boundary2
,
SDL_bool
validDomain
);
/*!
* todo add markup
*/
Uint64
RandomUint64BoundaryValue
(
Uint64
boundary1
,
Uint64
boundary2
,
SDL_bool
validDomain
);
/*!
/*!
* todo add markup
* todo add markup
...
...
test/test-automation/testdummy/testdummy.c
View file @
716a42e9
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
*/
*/
#include <stdio.h>
#include <stdio.h>
#include <stdint.h>
#include <SDL/SDL.h>
#include <SDL/SDL.h>
...
@@ -96,13 +97,16 @@ dummycase1(void *arg)
...
@@ -96,13 +97,16 @@ dummycase1(void *arg)
Log(0, "uint8 (same value): %u", RandomPositiveInteger());
Log(0, "uint8 (same value): %u", RandomPositiveInteger());
// */
// */
//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
Uint64
longlong
=
UINT64_MAX
;
//printf("max: %llu", longlong);
for
(;
1
;)
{
for
(;
1
;)
{
Log
(
0
,
"uint8: %u"
,
RandomUint8BoundaryValue
(
10
,
20
,
SDL_FALSE
));
//Log(0, "int8: %u", RandomUint8BoundaryValue(0, 255, SDL_FALSE));
//Log(0, "int8: %d", RandomInt8BoundaryValue());
//Log(0, "uint16: %u", RandomUint16BoundaryValue(0, UINT16_MAX, SDL_FALSE));
//Log(0, "int32: %u", RandomUint32BoundaryValue(0, 0xFFFFFFFE, SDL_FALSE));
Log
(
0
,
"int64: %llu"
,
RandomUint64BoundaryValue
(
2
,
0xFFFFFFFFFFFFFFFE
,
SDL_FALSE
));
}
}
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