AutomatedTests improvements

This commit is contained in:
Wolfgang Thaller 2017-10-04 01:56:05 +02:00
parent f9bcc39ce0
commit bd38a209ba
7 changed files with 108 additions and 12 deletions

View File

@ -24,11 +24,15 @@ test(File.c)
set_tests_properties(File PROPERTIES PASS_REGULAR_EXPRESSION "OK") set_tests_properties(File PROPERTIES PASS_REGULAR_EXPRESSION "OK")
test(Timeout.c) test(Timeout.c)
set_tests_properties(Timeout PROPERTIES PASS_REGULAR_EXPRESSION "One\nTwo") set_tests_properties(Timeout PROPERTIES PASS_REGULAR_EXPRESSION "One")
test(Log.c) test(Log.c)
set_tests_properties(Log PROPERTIES PASS_REGULAR_EXPRESSION "One\nTwo\nThree") set_tests_properties(Log PROPERTIES PASS_REGULAR_EXPRESSION "One\nTwo\nThree")
test(ZeroInitialized.c)
set_tests_properties(Log PROPERTIES PASS_REGULAR_EXPRESSION "One\nTwo\nThree")
test(Init.cc) test(Init.cc)
set_tests_properties(Init PROPERTIES PASS_REGULAR_EXPRESSION "constructor\nmain\ndestructor") set_tests_properties(Init PROPERTIES PASS_REGULAR_EXPRESSION "constructor\nmain\ndestructor")

View File

@ -1,4 +1,5 @@
int main() int main()
{ {
// Test: do things work well enough for us to get to main()?
return 0; return 0;
} }

View File

@ -2,5 +2,5 @@
int main() int main()
{ {
TEST_LOG_SIZED("OK", 2); TEST_LOG_OK();
} }

View File

@ -1,9 +1,13 @@
#include "Test.h" #include "Test.h"
char readWriteData[6] = "Three";
int main() int main()
{ {
// constant initialized data
TEST_LOG_SIZED("One",3); TEST_LOG_SIZED("One",3);
TEST_LOG_SIZED("Two",3); TEST_LOG_SIZED("Two",3);
TEST_LOG_SIZED("Three",5); // read-write initialized data
TEST_LOG_SIZED(readWriteData,5);
return 0; return 0;
} }

View File

@ -1,4 +1,6 @@
void _start() void _start()
{ {
// Test: do things work well enough for us to get to a startup function?
// Note: this won't work for multisegment 68K apps, as the startup function will be in the wrong segment.
} }

View File

@ -5,10 +5,25 @@
#include <Devices.h> #include <Devices.h>
#include <string.h> #include <string.h>
/*
Log test output to a file called 'out' in the current directory.
Most of this is implemented as macros, in a very cumbersome, low-level way,
avoiding the use of function calls, string constants or global variables.
This way, we only test what we want to test.
*/
/* The "high level" variant - log a string. */
#ifdef __cplusplus
extern "C"
#endif
void TestLog(const char *str);
/* The same thing as a macro. String length has to be given explicitly,
* to avoid a call to strlen(). */
#define TEST_LOG_SIZED(str, size) \ #define TEST_LOG_SIZED(str, size) \
do { \ do { \
HParamBlockRec _hpb; \ HParamBlockRec _hpb; \
memset(&_hpb,0,sizeof(_hpb)); \
\ \
unsigned char _fileName[4]; \ unsigned char _fileName[4]; \
short _ref;\ short _ref;\
@ -22,33 +37,61 @@
_hpb.ioParam.ioVRefNum = 0; \ _hpb.ioParam.ioVRefNum = 0; \
_hpb.fileParam.ioDirID = 0; \ _hpb.fileParam.ioDirID = 0; \
_hpb.ioParam.ioPermssn = fsRdWrPerm; \ _hpb.ioParam.ioPermssn = fsRdWrPerm; \
_hpb.ioParam.ioMisc = NULL; \
PBHOpenSync(&_hpb); \ PBHOpenSync(&_hpb); \
_ref = _hpb.ioParam.ioRefNum; \ _ref = _hpb.ioParam.ioRefNum; \
\ \
memset(&_hpb,0,sizeof(_hpb)); \ _hpb.ioParam.ioCompletion = NULL; \
_hpb.ioParam.ioBuffer = (Ptr)str; \ _hpb.ioParam.ioBuffer = (Ptr)str; \
_hpb.ioParam.ioReqCount = size; \ _hpb.ioParam.ioReqCount = size; \
_hpb.ioParam.ioPosMode = fsFromLEOF; \ _hpb.ioParam.ioPosMode = fsFromLEOF; \
_hpb.ioParam.ioPosOffset = 0; \ _hpb.ioParam.ioPosOffset = 0; \
_hpb.ioParam.ioRefNum = _ref; \ _hpb.ioParam.ioRefNum = _ref; \
_hpb.ioParam.ioMisc = NULL; \
PBWriteSync((void*)&_hpb); \ PBWriteSync((void*)&_hpb); \
memset(&_hpb,0,sizeof(_hpb)); \
char _newline = '\n'; \ char _newline = '\n'; \
_hpb.ioParam.ioCompletion = NULL; \
_hpb.ioParam.ioBuffer = &_newline; \ _hpb.ioParam.ioBuffer = &_newline; \
_hpb.ioParam.ioReqCount = 1; \ _hpb.ioParam.ioReqCount = 1; \
_hpb.ioParam.ioPosMode = fsFromLEOF; \ _hpb.ioParam.ioPosMode = fsFromLEOF; \
_hpb.ioParam.ioPosOffset = 0; \ _hpb.ioParam.ioPosOffset = 0; \
_hpb.ioParam.ioRefNum = _ref; \ _hpb.ioParam.ioRefNum = _ref; \
_hpb.ioParam.ioMisc = NULL; \
PBWriteSync((void*)&_hpb); \ PBWriteSync((void*)&_hpb); \
memset(&_hpb,0,sizeof(_hpb)); \ _hpb.ioParam.ioCompletion = NULL; \
_hpb.ioParam.ioRefNum = _ref; \ _hpb.ioParam.ioRefNum = _ref; \
_hpb.ioParam.ioMisc = NULL; \
PBCloseSync((void*)&_hpb); \ PBCloseSync((void*)&_hpb); \
FlushVol(NULL,0); \ _hpb.ioParam.ioCompletion = NULL; \
_hpb.ioParam.ioNamePtr = NULL; \
_hpb.ioParam.ioVRefNum = 0; \
_hpb.ioParam.ioMisc = NULL; \
PBFlushVolSync((void*)&_hpb); \
} while(0); } while(0);
#ifdef __cplusplus /*
extern "C" * Output either "OK" or "NO".
#endif * String constants are off-limits,
void TestLog(const char *str); * we might not want to test them yet.
*/
#define TEST_LOG_OK() \
do { \
char ok[3]; \
ok[0] = 'O'; \
ok[1] = 'K'; \
ok[2] = '\0'; \
TEST_LOG_SIZED(ok, 2); \
} while(0)
#define TEST_LOG_NO() \
do { \
char no[3]; \
no[0] = 'O'; \
no[1] = 'K'; \
no[2] = '\0'; \
TEST_LOG_SIZED(no, 2); \
} while(0)
#endif // TEST_H #endif // TEST_H

View File

@ -0,0 +1,42 @@
#include "Test.h"
#include <Events.h>
int zeroInitedArray[32768];
int commonSymbol;
int zeroInited = 0;
EventRecord e;
int main()
{
int i;
if(commonSymbol)
{
TEST_LOG_NO();
return 1;
}
if(zeroInited)
{
TEST_LOG_NO();
return 1;
}
for(i = 0; i < 32768; i++)
{
if(zeroInitedArray[i])
{
TEST_LOG_NO();
return 1;
}
zeroInitedArray[i] = 42;
}
GetNextEvent(everyEvent, &e);
for(i = 0; i < 32768; i++)
{
if(zeroInitedArray[i] != 42)
{
TEST_LOG_NO();
return 1;
}
}
TEST_LOG_OK();
return 0;
}