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
cdb6aa7f
Commit
cdb6aa7f
authored
Aug 15, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes based on CR.
Some tests in rwops suite broken up to smaller tests.
parent
516b5e80
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
28 deletions
+99
-28
fuzzer.c
test/test-automation/src/libSDLtest/fuzzer/fuzzer.c
+36
-20
fuzzer.h
test/test-automation/src/libSDLtest/fuzzer/fuzzer.h
+20
-0
testrwops.c
test/test-automation/tests/testrwops/testrwops.c
+43
-8
No files found.
test/test-automation/src/libSDLtest/fuzzer/fuzzer.c
View file @
cdb6aa7f
...
@@ -57,8 +57,6 @@ GenerateExecKey(char *runSeed, char *suiteName,
...
@@ -57,8 +57,6 @@ GenerateExecKey(char *runSeed, char *suiteName,
return
-
1
;
return
-
1
;
}
}
// Change to itoa
char
iterationString
[
16
];
char
iterationString
[
16
];
memset
(
iterationString
,
0
,
sizeof
(
iterationString
));
memset
(
iterationString
,
0
,
sizeof
(
iterationString
));
SDL_snprintf
(
iterationString
,
sizeof
(
iterationString
)
-
1
,
"%d"
,
iterationNumber
);
SDL_snprintf
(
iterationString
,
sizeof
(
iterationString
)
-
1
,
"%d"
,
iterationNumber
);
...
@@ -75,7 +73,7 @@ GenerateExecKey(char *runSeed, char *suiteName,
...
@@ -75,7 +73,7 @@ GenerateExecKey(char *runSeed, char *suiteName,
char
*
buffer
=
SDL_malloc
(
entireString
);
char
*
buffer
=
SDL_malloc
(
entireString
);
if
(
!
buffer
)
{
if
(
!
buffer
)
{
return
-
1
;
return
0
;
}
}
SDL_snprintf
(
buffer
,
entireString
,
"%s/%s/%s/%d"
,
runSeed
,
suiteName
,
SDL_snprintf
(
buffer
,
entireString
,
"%s/%s/%s/%d"
,
runSeed
,
suiteName
,
...
@@ -89,9 +87,8 @@ GenerateExecKey(char *runSeed, char *suiteName,
...
@@ -89,9 +87,8 @@ GenerateExecKey(char *runSeed, char *suiteName,
SDL_free
(
buffer
);
SDL_free
(
buffer
);
Uint64
*
keys
=
(
Uint64
*
)
md5Context
.
digest
;
Uint64
*
keys
=
(
Uint64
*
)
md5Context
.
digest
;
Uint64
key
=
keys
[
0
];
return
key
;
return
key
s
[
0
]
;
}
}
void
void
...
@@ -147,29 +144,25 @@ RandomPositiveInteger()
...
@@ -147,29 +144,25 @@ RandomPositiveInteger()
Uint64
Uint64
RandomUint64
()
RandomUint64
()
{
{
Uint
8
string
[
16
]
;
Uint
64
value
;
int
counter
=
0
;
Uint32
*
vp
=
(
Uint32
*
)
&
value
;
for
(
;
counter
<
16
;
++
counter
)
{
vp
[
0
]
=
RandomSint32
();
string
[
counter
]
=
(
Uint8
)
RandomIntegerInRange
(
0
,
255
);
vp
[
1
]
=
RandomSint32
();
}
Uint64
*
value
=
(
Uint64
*
)
string
;
return
value
;
return
value
[
0
];
}
}
Sint64
Sint64
RandomSint64
()
RandomSint64
()
{
{
Uint
8
string
[
16
]
;
Uint
64
value
;
int
counter
=
0
;
Uint32
*
vp
=
(
Uint32
*
)
&
value
;
for
(
;
counter
<
16
;
++
counter
)
{
vp
[
0
]
=
RandomSint32
();
string
[
counter
]
=
(
Uint8
)
RandomIntegerInRange
(
0
,
255
);
vp
[
1
]
=
RandomSint32
();
}
Sint64
*
value
=
(
Sint64
*
)
string
;
return
value
;
return
value
[
0
];
}
}
...
@@ -566,10 +559,33 @@ RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDoma
...
@@ -566,10 +559,33 @@ RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDoma
return
retVal
;
return
retVal
;
}
}
float
RandomFloat
()
{
float
RandomUnitFloat
()
{
return
(
float
)
utl_randomInt
(
&
rndContext
)
/
UINT_MAX
;
return
(
float
)
utl_randomInt
(
&
rndContext
)
/
UINT_MAX
;
}
}
double
RandomUnitDouble
()
{
return
(
double
)
RandomUint64
()
/
LLONG_MAX
;
}
float
RandomFloat
()
{
// \todo to be implemented
return
0
.
0
f
;
}
double
RandomDouble
()
{
// \todo to be implemented
return
0
.
0
f
;
}
char
*
char
*
RandomAsciiString
()
RandomAsciiString
()
{
{
...
...
test/test-automation/src/libSDLtest/fuzzer/fuzzer.h
View file @
cdb6aa7f
...
@@ -27,6 +27,11 @@
...
@@ -27,6 +27,11 @@
#include "utl_md5.h"
#include "utl_md5.h"
#include "utl_random.h"
#include "utl_random.h"
/*!
* \file
* Note: fuzzer implementation uses static instance of random context
* internally which makes it thread-UNsafe.
*/
/*!
/*!
* Inits the fuzzer for a test
* Inits the fuzzer for a test
...
@@ -103,8 +108,23 @@ Sint64 RandomSint64();
...
@@ -103,8 +108,23 @@ Sint64 RandomSint64();
/*!
/*!
* Returns random float in range [0.0 - 1.0] (inclusive)
* Returns random float in range [0.0 - 1.0] (inclusive)
*/
*/
float
RandomUnitFloat
();
/*!
* Returns random double in range [0.0 - 1.0] (inclusive)
*/
double
RandomUnitDouble
();
/*!
* Returns random float
*/
float
RandomFloat
();
float
RandomFloat
();
/*!
* Returns random double
*/
double
RandomDouble
();
/*!
/*!
* Returns a random boundary value for Uint8 within the given boundaries.
* Returns a random boundary value for Uint8 within the given boundaries.
* Boundaries are inclusive, see the usage examples below. If validDomain
* Boundaries are inclusive, see the usage examples below. If validDomain
...
...
test/test-automation/tests/testrwops/testrwops.c
View file @
cdb6aa7f
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include "../../include/SDL_test.h"
#include "../../include/SDL_test.h"
// TODO create these at SetUp() and such TearDown()
const
char
*
RWOPS_READ
=
"tests/testrwops/read"
;
const
char
*
RWOPS_READ
=
"tests/testrwops/read"
;
const
char
*
RWOPS_WRITE
=
"tests/testrwops/write"
;
const
char
*
RWOPS_WRITE
=
"tests/testrwops/write"
;
...
@@ -30,15 +31,22 @@ static const TestCaseReference test3 =
...
@@ -30,15 +31,22 @@ static const TestCaseReference test3 =
(
TestCaseReference
){
"rwops_testConstMem"
,
"Tests opening from (const) memory"
,
TEST_ENABLED
,
0
,
0
};
(
TestCaseReference
){
"rwops_testConstMem"
,
"Tests opening from (const) memory"
,
TEST_ENABLED
,
0
,
0
};
static
const
TestCaseReference
test4
=
static
const
TestCaseReference
test4
=
(
TestCaseReference
){
"rwops_testFile
"
,
"rwop sy
"
,
TEST_ENABLED
,
0
,
0
};
(
TestCaseReference
){
"rwops_testFile
Read"
,
"Tests reading from a file
"
,
TEST_ENABLED
,
0
,
0
};
static
const
TestCaseReference
test5
=
static
const
TestCaseReference
test5
=
(
TestCaseReference
){
"rwops_testFP"
,
"rwop sy"
,
TEST_ENABLED
,
TEST_REQUIRES_STDIO
,
0
};
(
TestCaseReference
){
"rwops_testFileWrite"
,
"Test writing to a file"
,
TEST_ENABLED
,
0
,
0
};
static
const
TestCaseReference
test6
=
(
TestCaseReference
){
"rwops_testFPRead"
,
"Test reading from stdio"
,
TEST_ENABLED
,
TEST_REQUIRES_STDIO
,
0
};
static
const
TestCaseReference
test7
=
(
TestCaseReference
){
"rwops_testFPWrite"
,
"Test writing to stdio"
,
TEST_ENABLED
,
TEST_REQUIRES_STDIO
,
0
};
/* Test suite */
/* Test suite */
extern
const
TestCaseReference
*
testSuite
[]
=
{
extern
const
TestCaseReference
*
testSuite
[]
=
{
&
test1
,
&
test2
,
&
test3
,
&
test4
,
&
test5
,
NULL
&
test1
,
&
test2
,
&
test3
,
&
test4
,
&
test5
,
&
test6
,
&
test7
,
NULL
};
};
TestCaseReference
**
QueryTestSuite
()
{
TestCaseReference
**
QueryTestSuite
()
{
...
@@ -52,7 +60,6 @@ TestCaseReference **QueryTestSuite() {
...
@@ -52,7 +60,6 @@ TestCaseReference **QueryTestSuite() {
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_RWseek
* http://wiki.libsdl.org/moin.cgi/SDL_RWseek
* http://wiki.libsdl.org/moin.cgi/SDL_RWread
* http://wiki.libsdl.org/moin.cgi/SDL_RWread
*
*/
*/
int
_testGeneric
(
SDL_RWops
*
rw
,
int
write
)
int
_testGeneric
(
SDL_RWops
*
rw
,
int
write
)
{
{
...
@@ -99,6 +106,8 @@ int _testGeneric( SDL_RWops *rw, int write )
...
@@ -99,6 +106,8 @@ int _testGeneric( SDL_RWops *rw, int write )
* Tests rwops parameters
* Tests rwops parameters
*
*
* \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
* \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
*
* TODO Add fuzzer support here, write and read a string
*/
*/
void
rwops_testParam
(
void
)
void
rwops_testParam
(
void
)
{
{
...
@@ -167,13 +176,14 @@ void rwops_testConstMem (void)
...
@@ -167,13 +176,14 @@ void rwops_testConstMem (void)
/**
/**
* @brief Tests
open
ing from memory.
* @brief Tests
read
ing from memory.
*
*
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
* http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
* http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
* http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
*/
*/
void
rwops_testFile
(
void
)
void
rwops_testFileRead
(
void
)
{
{
SDL_RWops
*
rw
;
SDL_RWops
*
rw
;
...
@@ -184,6 +194,19 @@ void rwops_testFile (void)
...
@@ -184,6 +194,19 @@ void rwops_testFile (void)
_testGeneric
(
rw
,
0
);
_testGeneric
(
rw
,
0
);
SDL_FreeRW
(
rw
);
SDL_FreeRW
(
rw
);
}
/**
* @brief Tests writing from memory.
*
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
* http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
*/
void
rwops_testFileWrite
(
void
)
{
SDL_RWops
*
rw
;
/* Write test. */
/* Write test. */
rw
=
SDL_RWFromFile
(
RWOPS_WRITE
,
"w+"
);
rw
=
SDL_RWFromFile
(
RWOPS_WRITE
,
"w+"
);
...
@@ -196,13 +219,15 @@ void rwops_testFile (void)
...
@@ -196,13 +219,15 @@ void rwops_testFile (void)
/**
/**
* @brief Tests
open
ing from stdio
* @brief Tests
read
ing from stdio
*
*
* \sa
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
* http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
* http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
* http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
*
*/
*/
void
rwops_testFP
(
void
)
void
rwops_testFPRead
(
void
)
{
{
FILE
*
fp
;
FILE
*
fp
;
SDL_RWops
*
rw
;
SDL_RWops
*
rw
;
...
@@ -214,9 +239,18 @@ void rwops_testFP (void)
...
@@ -214,9 +239,18 @@ void rwops_testFP (void)
rw
=
SDL_RWFromFP
(
fp
,
1
);
rw
=
SDL_RWFromFP
(
fp
,
1
);
AssertTrue
(
rw
!=
NULL
,
"Opening memory with SDL_RWFromFP"
);
AssertTrue
(
rw
!=
NULL
,
"Opening memory with SDL_RWFromFP"
);
// TODO bail out if NULL
_testGeneric
(
rw
,
0
);
_testGeneric
(
rw
,
0
);
SDL_FreeRW
(
rw
);
SDL_FreeRW
(
rw
);
fclose
(
fp
);
}
void
rwops_testFPWrite
(
void
)
{
FILE
*
fp
;
SDL_RWops
*
rw
;
/* Run write tests. */
/* Run write tests. */
fp
=
fopen
(
RWOPS_WRITE
,
"w+"
);
fp
=
fopen
(
RWOPS_WRITE
,
"w+"
);
...
@@ -228,4 +262,5 @@ void rwops_testFP (void)
...
@@ -228,4 +262,5 @@ void rwops_testFP (void)
_testGeneric
(
rw
,
1
);
_testGeneric
(
rw
,
1
);
SDL_FreeRW
(
rw
);
SDL_FreeRW
(
rw
);
fclose
(
fp
);
}
}
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