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
9c7ff005
Commit
9c7ff005
authored
Aug 09, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the fuzzer a bit.
parent
dc97e62c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
61 deletions
+71
-61
fuzzer.c
test/test-automation/src/libSDLtest/fuzzer/fuzzer.c
+61
-61
testdummy.c
test/test-automation/tests/testdummy/testdummy.c
+10
-0
No files found.
test/test-automation/src/libSDLtest/fuzzer/fuzzer.c
View file @
9c7ff005
...
@@ -108,13 +108,13 @@ DeinitFuzzer()
...
@@ -108,13 +108,13 @@ DeinitFuzzer()
Sint32
Sint32
RandomInteger
()
RandomInteger
()
{
{
return
utl_randomInt
(
&
rndContext
);
return
(
Sint32
)
utl_randomInt
(
&
rndContext
);
}
}
Uint32
Uint32
RandomPositiveInteger
()
RandomPositiveInteger
()
{
{
return
utl_randomInt
(
&
rndContext
);
return
(
Uint32
)
utl_randomInt
(
&
rndContext
);
}
}
Sint32
Sint32
...
@@ -150,6 +150,9 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
...
@@ -150,6 +150,9 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
*
*
* Generator works the same for other types of unsigned integers.
* Generator works the same for other types of unsigned integers.
*
*
* Note: outBuffer will be allocated and needs to be freed later.
* If outbuffer != NULL, it'll be freed.
*
* \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.
* \param pBoundary1 defines lower boundary
* \param pBoundary1 defines lower boundary
...
@@ -159,12 +162,12 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
...
@@ -159,12 +162,12 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
* \param outBuffer The generated boundary values are put here
* \param outBuffer The generated boundary values are put here
* \param outBufferSize Size of outBuffer
* \param outBufferSize Size of outBuffer
*
*
* \returns
NULL on error, outBuffer on success
* \returns
Returns the number of elements in outBuffer or -1 in case of error
*/
*/
Uint
64
*
Uint
32
GenerateUnsignedBoundaryValues
(
const
Uint64
maxValue
,
GenerateUnsignedBoundaryValues
(
const
Uint64
maxValue
,
Uint64
pBoundary1
,
Uint64
pBoundary2
,
SDL_bool
validDomain
,
Uint64
pBoundary1
,
Uint64
pBoundary2
,
SDL_bool
validDomain
,
Uint64
*
outBuffer
,
Uint32
*
outBufferSize
)
Uint64
*
outBuffer
)
{
{
Uint64
boundary1
=
pBoundary1
,
boundary2
=
pBoundary2
;
Uint64
boundary1
=
pBoundary1
,
boundary2
=
pBoundary2
;
...
@@ -178,9 +181,7 @@ GenerateUnsignedBoundaryValues(const Uint64 maxValue,
...
@@ -178,9 +181,7 @@ GenerateUnsignedBoundaryValues(const Uint64 maxValue,
boundary2
=
temp
;
boundary2
=
temp
;
}
}
Uint64
tempBuf
[
8
];
Uint64
tempBuf
[
4
];
memset
(
tempBuf
,
0
,
8
*
sizeof
(
Uint64
));
Uint64
index
=
0
;
Uint64
index
=
0
;
if
(
boundary1
==
boundary2
)
{
if
(
boundary1
==
boundary2
)
{
...
@@ -207,20 +208,18 @@ GenerateUnsignedBoundaryValues(const Uint64 maxValue,
...
@@ -207,20 +208,18 @@ GenerateUnsignedBoundaryValues(const Uint64 maxValue,
if
(
index
==
0
)
{
if
(
index
==
0
)
{
// There are no valid boundaries
// There are no valid boundaries
return
NULL
;
return
0
;
}
}
// Create the return buffer
// Create the return buffer
outBuffer
=
SDL_malloc
(
index
*
sizeof
(
Uint64
));
outBuffer
=
SDL_malloc
(
index
*
sizeof
(
Uint64
));
if
(
outBuffer
==
NULL
)
{
if
(
outBuffer
==
NULL
)
{
return
NULL
;
return
0
;
}
}
SDL_memcpy
(
outBuffer
,
tempBuf
,
index
*
sizeof
(
Uint64
));
SDL_memcpy
(
outBuffer
,
tempBuf
,
index
*
sizeof
(
Uint64
));
*
outBufferSize
=
index
;
return
index
;
return
outBuffer
;
}
}
Uint8
Uint8
...
@@ -232,11 +231,11 @@ RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
...
@@ -232,11 +231,11 @@ RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
// max value for Uint8
// max value for Uint8
const
Uint64
maxValue
=
UINT8_MAX
;
const
Uint64
maxValue
=
UINT8_MAX
;
buffer
=
GenerateUnsignedBoundaryValues
(
maxValue
,
size
=
GenerateUnsignedBoundaryValues
(
maxValue
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
validDomain
,
buffer
);
if
(
buffer
==
NULL
)
{
if
(
size
==
0
)
{
return
-
1
;
// Change to some better error value? What would be better?
return
0
;
}
}
Uint32
index
=
RandomInteger
()
%
size
;
Uint32
index
=
RandomInteger
()
%
size
;
...
@@ -256,11 +255,11 @@ RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDoma
...
@@ -256,11 +255,11 @@ RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDoma
// max value for Uint16
// max value for Uint16
const
Uint64
maxValue
=
UINT16_MAX
;
const
Uint64
maxValue
=
UINT16_MAX
;
buffer
=
GenerateUnsignedBoundaryValues
(
maxValue
,
size
=
GenerateUnsignedBoundaryValues
(
maxValue
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
validDomain
,
buffer
);
if
(
buffer
==
NULL
)
{
if
(
size
==
0
)
{
return
-
1
;
// Change to some better error value? What would be better?
return
0
;
}
}
Uint32
index
=
RandomInteger
()
%
size
;
Uint32
index
=
RandomInteger
()
%
size
;
...
@@ -280,11 +279,11 @@ RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDoma
...
@@ -280,11 +279,11 @@ RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDoma
// max value for Uint32
// max value for Uint32
const
Uint64
maxValue
=
UINT32_MAX
;
const
Uint64
maxValue
=
UINT32_MAX
;
buffer
=
GenerateUnsignedBoundaryValues
(
maxValue
,
size
=
GenerateUnsignedBoundaryValues
(
maxValue
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
validDomain
,
buffer
);
if
(
buffer
==
NULL
)
{
if
(
size
==
0
)
{
return
-
1
;
// Change to some better error value? What would be better?
return
0
;
}
}
Uint32
index
=
RandomInteger
()
%
size
;
Uint32
index
=
RandomInteger
()
%
size
;
...
@@ -304,11 +303,11 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma
...
@@ -304,11 +303,11 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma
// max value for Uint64
// max value for Uint64
const
Uint64
maxValue
=
UINT64_MAX
;
const
Uint64
maxValue
=
UINT64_MAX
;
buffer
=
GenerateUnsignedBoundaryValues
(
maxValue
,
size
=
GenerateUnsignedBoundaryValues
(
maxValue
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
(
Uint64
)
boundary1
,
(
Uint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
validDomain
,
buffer
);
if
(
buffer
==
NULL
)
{
if
(
size
==
0
)
{
return
-
1
;
// Change to some better error value? What would be better?
return
0
;
}
}
Uint32
index
=
RandomInteger
()
%
size
;
Uint32
index
=
RandomInteger
()
%
size
;
...
@@ -330,6 +329,10 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma
...
@@ -330,6 +329,10 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma
*
*
* Generator works the same for other types of signed integers.
* Generator works the same for other types of signed integers.
*
*
* Note: outBuffer will be allocated and needs to be freed later.
* If outbuffer != NULL, it'll be freed.
*
*
* \paran minValue The smallest value that is acceptable for this data type.
* \paran minValue The smallest value that is acceptable for this data type.
* For instance, for Uint8 -> -128, Uint16 -> -32,768 etc.
* For instance, for Uint8 -> -128, Uint16 -> -32,768 etc.
* \param maxValue The biggest value that is acceptable for this data type.
* \param maxValue The biggest value that is acceptable for this data type.
...
@@ -341,12 +344,12 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma
...
@@ -341,12 +344,12 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma
* \param outBuffer The generated boundary values are put here
* \param outBuffer The generated boundary values are put here
* \param outBufferSize Size of outBuffer
* \param outBufferSize Size of outBuffer
*
*
* \returns
NULL on error, outBuffer on success
* \returns
Returns the number of elements in outBuffer or -1 in case of error
*/
*/
Uint
64
*
Uint
32
GenerateSignedBoundaryValues
(
const
Sint64
minValue
,
const
Sint64
maxValue
,
GenerateSignedBoundaryValues
(
const
Sint64
minValue
,
const
Sint64
maxValue
,
Sint64
pBoundary1
,
Sint64
pBoundary2
,
SDL_bool
validDomain
,
Sint64
pBoundary1
,
Sint64
pBoundary2
,
SDL_bool
validDomain
,
Sint64
*
outBuffer
,
Uint32
*
outBufferSize
)
Sint64
*
outBuffer
)
{
{
Sint64
boundary1
=
pBoundary1
,
boundary2
=
pBoundary2
;
Sint64
boundary1
=
pBoundary1
,
boundary2
=
pBoundary2
;
...
@@ -360,8 +363,7 @@ GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue,
...
@@ -360,8 +363,7 @@ GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue,
boundary2
=
temp
;
boundary2
=
temp
;
}
}
Sint64
tempBuf
[
8
];
Sint64
tempBuf
[
4
];
memset
(
tempBuf
,
0
,
8
*
sizeof
(
Sint64
));
Sint64
index
=
0
;
Sint64
index
=
0
;
...
@@ -391,20 +393,18 @@ GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue,
...
@@ -391,20 +393,18 @@ GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue,
if
(
index
==
0
)
{
if
(
index
==
0
)
{
// There are no valid boundaries
// There are no valid boundaries
return
NULL
;
return
0
;
}
}
// Create the return buffer
// Create the return buffer
outBuffer
=
SDL_malloc
(
index
*
sizeof
(
Sint64
));
outBuffer
=
SDL_malloc
(
index
*
sizeof
(
Sint64
));
if
(
outBuffer
==
NULL
)
{
if
(
outBuffer
==
NULL
)
{
return
NULL
;
return
0
;
}
}
SDL_memcpy
(
outBuffer
,
tempBuf
,
index
*
sizeof
(
Sint64
));
SDL_memcpy
(
outBuffer
,
tempBuf
,
index
*
sizeof
(
Sint64
));
*
outBufferSize
=
index
;
return
index
;
return
outBuffer
;
}
}
Sint8
Sint8
...
@@ -417,10 +417,10 @@ RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain)
...
@@ -417,10 +417,10 @@ RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain)
const
Sint64
maxValue
=
CHAR_MAX
;
const
Sint64
maxValue
=
CHAR_MAX
;
const
Sint64
minValue
=
CHAR_MIN
;
const
Sint64
minValue
=
CHAR_MIN
;
buffer
=
GenerateSignedBoundaryValues
(
minValue
,
maxValue
,
size
=
GenerateSignedBoundaryValues
(
minValue
,
maxValue
,
(
Sint64
)
boundary1
,
(
Sint64
)
boundary2
,
(
Sint64
)
boundary1
,
(
Sint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
validDomain
,
buffer
);
if
(
buffer
==
NULL
)
{
if
(
size
==
0
)
{
return
CHAR_MIN
;
return
CHAR_MIN
;
}
}
...
@@ -442,10 +442,10 @@ RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDoma
...
@@ -442,10 +442,10 @@ RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDoma
const
Sint64
maxValue
=
SHRT_MAX
;
const
Sint64
maxValue
=
SHRT_MAX
;
const
Sint64
minValue
=
SHRT_MIN
;
const
Sint64
minValue
=
SHRT_MIN
;
buffer
=
GenerateSignedBoundaryValues
(
minValue
,
maxValue
,
size
=
GenerateSignedBoundaryValues
(
minValue
,
maxValue
,
(
Sint64
)
boundary1
,
(
Sint64
)
boundary2
,
(
Sint64
)
boundary1
,
(
Sint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
validDomain
,
buffer
);
if
(
buffer
==
NULL
)
{
if
(
size
==
0
)
{
return
SHRT_MIN
;
return
SHRT_MIN
;
}
}
...
@@ -467,10 +467,10 @@ RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDoma
...
@@ -467,10 +467,10 @@ RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDoma
const
Sint64
maxValue
=
INT_MAX
;
const
Sint64
maxValue
=
INT_MAX
;
const
Sint64
minValue
=
INT_MIN
;
const
Sint64
minValue
=
INT_MIN
;
buffer
=
GenerateSignedBoundaryValues
(
minValue
,
maxValue
,
size
=
GenerateSignedBoundaryValues
(
minValue
,
maxValue
,
(
Sint64
)
boundary1
,
(
Sint64
)
boundary2
,
(
Sint64
)
boundary1
,
(
Sint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
validDomain
,
buffer
);
if
(
buffer
==
NULL
)
{
if
(
size
==
0
)
{
return
INT_MIN
;
return
INT_MIN
;
}
}
...
@@ -492,10 +492,10 @@ RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDoma
...
@@ -492,10 +492,10 @@ RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDoma
const
Sint64
maxValue
=
LLONG_MAX
;
const
Sint64
maxValue
=
LLONG_MAX
;
const
Sint64
minValue
=
LLONG_MIN
;
const
Sint64
minValue
=
LLONG_MIN
;
buffer
=
GenerateSignedBoundaryValues
(
minValue
,
maxValue
,
size
=
GenerateSignedBoundaryValues
(
minValue
,
maxValue
,
(
Sint64
)
boundary1
,
(
Sint64
)
boundary2
,
(
Sint64
)
boundary1
,
(
Sint64
)
boundary2
,
validDomain
,
buffer
,
&
size
);
validDomain
,
buffer
);
if
(
buffer
==
NULL
)
{
if
(
size
==
0
)
{
return
LLONG_MIN
;
return
LLONG_MIN
;
}
}
...
@@ -516,11 +516,11 @@ RandomAsciiString()
...
@@ -516,11 +516,11 @@ RandomAsciiString()
char
*
char
*
RandomAsciiStringWithMaximumLength
(
int
maxSize
)
RandomAsciiStringWithMaximumLength
(
int
maxSize
)
{
{
if
(
maxSize
<
0
)
{
if
(
maxSize
<
1
)
{
return
NULL
;
return
NULL
;
}
}
int
size
=
abs
(
RandomInteger
())
%
maxSize
;
int
size
=
(
abs
(
RandomInteger
())
%
(
maxSize
+
1
))
+
1
;
char
*
string
=
SDL_malloc
(
size
*
sizeof
(
size
));
char
*
string
=
SDL_malloc
(
size
*
sizeof
(
size
));
int
counter
=
0
;
int
counter
=
0
;
...
...
test/test-automation/tests/testdummy/testdummy.c
View file @
9c7ff005
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
#include "../../include/SDL_test.h"
#include "../../include/SDL_test.h"
#include <limits.h>
/* Test case references */
/* Test case references */
static
const
TestCaseReference
test1
=
static
const
TestCaseReference
test1
=
(
TestCaseReference
){
"dummycase1"
,
"description"
,
TEST_ENABLED
,
0
,
4
};
(
TestCaseReference
){
"dummycase1"
,
"description"
,
TEST_ENABLED
,
0
,
4
};
...
@@ -98,6 +100,14 @@ dummycase1(void *arg)
...
@@ -98,6 +100,14 @@ 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
(
;
1
;
)
{
//Log(0, "sint8: %d", RandomSint8BoundaryValue(-11, 10, SDL_TRUE));
//Log(0, "sint16: %d", RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE));
Log
(
0
,
"sint32: %d"
,
RandomSint32BoundaryValue
(
INT_MIN
,
3000
,
SDL_FALSE
));
//Log(0, "sint64: %lld", RandomSint64BoundaryValue(-34, -34, SDL_FALSE));
}
for
(;
0
;)
{
for
(;
0
;)
{
//Log(0, "int8: %u", RandomUint8BoundaryValue(0, 255, SDL_FALSE));
//Log(0, "int8: %u", RandomUint8BoundaryValue(0, 255, SDL_FALSE));
//Log(0, "uint16: %u", RandomUint16BoundaryValue(0, UINT16_MAX, SDL_FALSE));
//Log(0, "uint16: %u", RandomUint16BoundaryValue(0, UINT16_MAX, SDL_FALSE));
...
...
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