More tests to round out (for now) createArea
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2542 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -10,3 +10,5 @@ BinCommand setup : testSetup.C : root be libvm.so ;
|
||||
BinCommand mmapTest1 : mmapTest1.C : root be libvm.so ;
|
||||
BinCommand mmapTest2 : mmapTest2.C : root be libvm.so ;
|
||||
BinCommand mmapTest3 : mmapTest3.C : root be libvm.so ;
|
||||
BinCommand createAreaFails : createAreaFails.C : root be libvm.so ;
|
||||
BinCommand createAreaTestsGood : createAreaTestsGood.C : root be libvm.so ;
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "vmInterface.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <mman.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <OS.h>
|
||||
|
||||
vmInterface *vm;
|
||||
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
void *location;
|
||||
char *testName;
|
||||
|
||||
location=NULL;
|
||||
testName="vmInterface construction";
|
||||
try { vm = new vmInterface (30); }
|
||||
catch (const char *t) { error ("Exception thrown in %s! %s\n",testName,t); exit(1); }
|
||||
|
||||
testName="NULL name vm->createArea test";
|
||||
try { if (vm->createArea(NULL,1,&location)>=0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); }
|
||||
|
||||
testName="HUGE name vm->createArea test";
|
||||
try { if (vm->createArea("This is a crazy, way too long name that should never, ever be permited to work at any time and under any circumstances!",1,&location)>=0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); }
|
||||
|
||||
testName="0 page count vm->createArea test";
|
||||
try { if (vm->createArea("test",0,&location)>=0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); }
|
||||
|
||||
testName="page count larger than VM vm->createArea test";
|
||||
try { if (vm->createArea("test",131,&location)>=0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); }
|
||||
error ("Previous test is expected to fail, until sizing of VM file is worked out\n");
|
||||
|
||||
testName="page count larger than physical memory vm->createArea test";
|
||||
try { if (vm->createArea("test",31,&location,ANY,FULL)>=0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); }
|
||||
|
||||
testName="clone vm->createArea test";
|
||||
try { if (vm->createArea("test",1,&location,CLONE)>=0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); }
|
||||
|
||||
catch (const char *t) {
|
||||
error ("Exception thrown! %s\n",t);
|
||||
exit(1);
|
||||
}
|
||||
catch (...) {
|
||||
error ("Unknown Exception thrown!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
#include "vmInterface.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <mman.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <OS.h>
|
||||
|
||||
vmInterface *vm;
|
||||
/* - specified address (EXACT)
|
||||
- base address (BASE)
|
||||
- kernel address (ANY_KERNEL)
|
||||
- FULL_LOCK
|
||||
- CONTIGUOUS
|
||||
- LAZY_LOCK
|
||||
- NO_LOCK
|
||||
- LOMEM
|
||||
*/
|
||||
|
||||
static void *orig;
|
||||
void assignAddress(unsigned long a, void *&b) {b=(void *)a;orig=b;}
|
||||
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
void *location;
|
||||
char *testName;
|
||||
|
||||
location=NULL;
|
||||
testName="vmInterface construction";
|
||||
try { vm = new vmInterface (60); }
|
||||
catch (const char *t) { error ("Exception thrown in %s! %s\n",testName,t); exit(1); }
|
||||
|
||||
testName="Specified Address succeeds";
|
||||
try {assignAddress(0x14000000,location) ; if (vm->createArea(testName,1,&location,EXACT)<0) throw (testName);
|
||||
if (location != orig) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); exit(1);}
|
||||
|
||||
testName="Specified Address fails"; // Because we want the same space
|
||||
try {assignAddress(0x14000000,location) ; if (vm->createArea(testName,1,&location,EXACT)>=0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); }
|
||||
|
||||
testName="Base Address";
|
||||
try {assignAddress(0x12000000,location) ; if (vm->createArea(testName,1,&location,EXACT)<0) throw (testName);
|
||||
if (location != orig) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); }
|
||||
|
||||
testName="Kernel Address";
|
||||
try {assignAddress(0,location) ; if (vm->createArea(testName,1,&location,ANY_KERNEL)<0) throw (testName);
|
||||
if (location != orig) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); }
|
||||
|
||||
testName="Specified Address ";// This needs more and better testing
|
||||
try {assignAddress(0,location) ; if (vm->createArea(testName,1,&location,ANY,FULL)<0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); exit(1);}
|
||||
|
||||
testName="Contiguous Memory "; // This needs more and better testing
|
||||
try {assignAddress(0,location) ; if (vm->createArea(testName,1,&location,ANY,CONTIGUOUS)<0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); exit(1);}
|
||||
|
||||
testName="Lazy Lock "; // This needs more and better testing
|
||||
try {assignAddress(0,location) ; if (vm->createArea(testName,1,&location,ANY,LAZY)<0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); exit(1);}
|
||||
|
||||
testName="No Lock "; // This needs more and better testing
|
||||
try {assignAddress(0,location) ; if (vm->createArea(testName,1,&location,ANY,NO_LOCK)<0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); exit(1);}
|
||||
|
||||
testName="LOMEM "; // This needs more and better testing
|
||||
try {assignAddress(0,location) ; if (vm->createArea(testName,1,&location,ANY,LOMEM)<0) throw (testName); else error ("%s passed!\n",testName); }
|
||||
catch (const char *t) { error ("Exception thrown in %s!\n",t); exit(1);}
|
||||
|
||||
catch (const char *t) {
|
||||
error ("Exception thrown! %s\n",t);
|
||||
exit(1);
|
||||
}
|
||||
catch (...) {
|
||||
error ("Unknown Exception thrown!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user