From 21b2687fab9649248b40c203fdc20ca6637f2e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 4 Nov 2008 15:32:02 +0000 Subject: [PATCH] * No need to keep Michael's old VM stuff around. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28499 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/system/vm2/Jamfile | 19 -- src/tests/system/vm2/createAreaFails.C | 56 ----- src/tests/system/vm2/createAreaTestsGood.C | 82 -------- src/tests/system/vm2/freeAreaFails.C | 40 ---- src/tests/system/vm2/getAreaByAddress.C | 53 ----- src/tests/system/vm2/getAreaByName.C | 53 ----- src/tests/system/vm2/getAreaInfoFails.C | 47 ----- src/tests/system/vm2/hashTest.C | 122 ----------- src/tests/system/vm2/mmapTest1.C | 46 ----- src/tests/system/vm2/mmapTest2.C | 57 ------ src/tests/system/vm2/mmapTest3.C | 57 ------ src/tests/system/vm2/olTest.C | 103 ---------- src/tests/system/vm2/pageManTest.C | 102 ---------- src/tests/system/vm2/resizeArea.C | 68 ------- src/tests/system/vm2/simpleTest.C | 60 ------ src/tests/system/vm2/test.C | 226 --------------------- src/tests/system/vm2/testSetup.C | 30 --- src/tests/system/vm2/testsToDo | 74 ------- 18 files changed, 1295 deletions(-) delete mode 100644 src/tests/system/vm2/Jamfile delete mode 100644 src/tests/system/vm2/createAreaFails.C delete mode 100644 src/tests/system/vm2/createAreaTestsGood.C delete mode 100644 src/tests/system/vm2/freeAreaFails.C delete mode 100644 src/tests/system/vm2/getAreaByAddress.C delete mode 100644 src/tests/system/vm2/getAreaByName.C delete mode 100644 src/tests/system/vm2/getAreaInfoFails.C delete mode 100644 src/tests/system/vm2/hashTest.C delete mode 100644 src/tests/system/vm2/mmapTest1.C delete mode 100644 src/tests/system/vm2/mmapTest2.C delete mode 100644 src/tests/system/vm2/mmapTest3.C delete mode 100644 src/tests/system/vm2/olTest.C delete mode 100644 src/tests/system/vm2/pageManTest.C delete mode 100644 src/tests/system/vm2/resizeArea.C delete mode 100644 src/tests/system/vm2/simpleTest.C delete mode 100644 src/tests/system/vm2/test.C delete mode 100644 src/tests/system/vm2/testSetup.C delete mode 100644 src/tests/system/vm2/testsToDo diff --git a/src/tests/system/vm2/Jamfile b/src/tests/system/vm2/Jamfile deleted file mode 100644 index d8d88e0a27..0000000000 --- a/src/tests/system/vm2/Jamfile +++ /dev/null @@ -1,19 +0,0 @@ -SubDir HAIKU_TOP src system vm2 tests ; - -UseHeaders .. ; -BinCommand vmTest : test.C : root be libvm.so ; -BinCommand olTest : olTest.C : root be libvm.so ; -BinCommand hashTest : hashTest.C : root be libvm.so ; -BinCommand pmTest : pageManTest.C : root be libvm.so ; -BinCommand simpleTest : simpleTest.C : root be libvm.so ; -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 freeAreaFails : freeAreaFails.C : root be libvm.so ; -BinCommand getAreaInfoFails : getAreaInfoFails.C : root be libvm.so ; -BinCommand getAreaByName : getAreaByName.C : root be libvm.so ; -BinCommand getAreaByAddress : getAreaByAddress.C : root be libvm.so ; -BinCommand resizeArea : resizeArea.C : root be libvm.so ; -BinCommand createAreaTestsGood : createAreaTestsGood.C : root be libvm.so ; diff --git a/src/tests/system/vm2/createAreaFails.C b/src/tests/system/vm2/createAreaFails.C deleted file mode 100644 index 8684584958..0000000000 --- a/src/tests/system/vm2/createAreaFails.C +++ /dev/null @@ -1,56 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include -#include - -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; -} diff --git a/src/tests/system/vm2/createAreaTestsGood.C b/src/tests/system/vm2/createAreaTestsGood.C deleted file mode 100644 index 7422430a7f..0000000000 --- a/src/tests/system/vm2/createAreaTestsGood.C +++ /dev/null @@ -1,82 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include -#include - -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; -} diff --git a/src/tests/system/vm2/freeAreaFails.C b/src/tests/system/vm2/freeAreaFails.C deleted file mode 100644 index 555ae57b0b..0000000000 --- a/src/tests/system/vm2/freeAreaFails.C +++ /dev/null @@ -1,40 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include -#include - -vmInterface *vm; - -int main(int argc,char **argv) -{ - void *location; - char *testName; - int areaNumber; - - 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); } - try { - testName="delete_area on invalid area test"; - if (vm->delete_area(999999)==B_OK) - error ("%s failed!\n",testName) ; - else - error ("%s passed!\n",testName); - - testName="delete_area twice on same area test"; - if (areaNumber=vm->createArea("sampleArea",1,&location)>=0) { - if (vm->delete_area(areaNumber)!=B_OK) error("%s:Initial free failed!\n",testName); - if (vm->delete_area(areaNumber)==B_OK) - error("%s:Second free succeeded!\n",testName); - else - error ("%s passed\n",testName); - } - } - catch (const char *t) { error ("Exception thrown in %s, while trying to run !\n",t,testName); } - - return 0; -} diff --git a/src/tests/system/vm2/getAreaByAddress.C b/src/tests/system/vm2/getAreaByAddress.C deleted file mode 100644 index d282790d19..0000000000 --- a/src/tests/system/vm2/getAreaByAddress.C +++ /dev/null @@ -1,53 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include -#include - -vmInterface *vm; - -int main(int argc,char **argv) -{ - int areaNum,found; - char *testName; - void *foo; - - testName="vmInterface construction"; - try { vm = new vmInterface (30); } - catch (const char *t) { error ("Exception thrown in %s! %s\n",testName,t); exit(1); } - - try { - testName="getAreaByAddress with NULL address test"; - if (vm->getAreaByAddress(NULL)>=0) - error ("%s failed!\n",testName); - else - error ("%s passed!\n",testName); - - if ((areaNum=vm->createArea("test",1,&foo))<0) - throw (testName); - - testName="getAreaByAddress with out of bounds address test"; - if (vm->getAreaByAddress((void *)(((long)foo)+100000))>=0) - error ("%s failed!\n",testName); - else - error ("%s passed!\n",testName); - - testName="getAreaByAddress with existant area test"; - if ((found=vm->getAreaByAddress((void *)(((long)foo)+2)))==areaNum) - error ("%s passed!\n",testName); - else - error ("%s failed! areaNum = %d, found = %d \n",testName,areaNum,found); - } - catch (const char *t) { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) { - error ("Unknown Exception thrown!\n"); - exit(1); - } - - return 0; -} diff --git a/src/tests/system/vm2/getAreaByName.C b/src/tests/system/vm2/getAreaByName.C deleted file mode 100644 index da5a55c33a..0000000000 --- a/src/tests/system/vm2/getAreaByName.C +++ /dev/null @@ -1,53 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include -#include - -vmInterface *vm; - -int main(int argc,char **argv) -{ - area_info ai; - char *testName; - void *foo; - - testName="vmInterface construction"; - try { vm = new vmInterface (30); } - catch (const char *t) { error ("Exception thrown in %s! %s\n",testName,t); exit(1); } - - try { - testName="getAreaByName with NULL area test"; - if (vm->getAreaByName(NULL)>=0) - error ("%s failed!\n",testName); - else - error ("%s passed!\n",testName); - - testName="getAreaByName with unknown area name test"; - if (vm->getAreaByName("MOO COW")>=0) - error ("%s failed!\n",testName); - else - error ("%s passed!\n",testName); - - testName="getAreaByName with existant area test"; - int areaNum,found; - if ((areaNum=vm->createArea("test",1,&foo))<0) - throw (testName); - if ((found=vm->getAreaByName("test"))==areaNum) - error ("%s passed!\n",testName); - else - error ("%s failed! areaNum = %d, found = %d \n",testName,areaNum,found); - } - catch (const char *t) { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) { - error ("Unknown Exception thrown!\n"); - exit(1); - } - - return 0; -} diff --git a/src/tests/system/vm2/getAreaInfoFails.C b/src/tests/system/vm2/getAreaInfoFails.C deleted file mode 100644 index bff5d45d37..0000000000 --- a/src/tests/system/vm2/getAreaInfoFails.C +++ /dev/null @@ -1,47 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include -#include - -vmInterface *vm; - -int main(int argc,char **argv) -{ - area_info ai; - char *testName; - void *foo; - - testName="vmInterface construction"; - try { vm = new vmInterface (30); } - catch (const char *t) { error ("Exception thrown in %s! %s\n",testName,t); exit(1); } - - try { - testName="getAreaInfo with non-existant areatest"; - if (vm->getAreaInfo(999999,&ai)>=0) - error ("%s failed!\n",testName); - else - error ("%s passed!\n",testName); - - int areaNum; - testName="getAreaInfo with NULL area_info areatest"; - if (areaNum=vm->createArea("test",1,&foo)<0) - throw (testName); - if (vm->getAreaInfo(areaNum,&ai)>=0) - error ("%s failed!\n",testName); - else - error ("%s passed!\n",testName); - } - catch (const char *t) { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) { - error ("Unknown Exception thrown!\n"); - exit(1); - } - - return 0; -} diff --git a/src/tests/system/vm2/hashTest.C b/src/tests/system/vm2/hashTest.C deleted file mode 100644 index 602fc9f123..0000000000 --- a/src/tests/system/vm2/hashTest.C +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include -#include -#include -#include "hashTable.h" -#include "OS.h" -#include "vmInterface.h" - -vmInterface vm(30); - -struct hashTest : public node { - hashTest(int i) {value=i;} - int value; -}; - -ulong hash(node &a) { - hashTest &a1=reinterpret_cast(a); - return a1.value; -} - -bool isEqual (node &a,node &b) { - hashTest &a1=reinterpret_cast(a); - hashTest &b1=reinterpret_cast(b); - return (a1.value==b1.value); -} - -int main(int argc,char **argv) { - // Test 1 - Try to add to foo without setting an isLessThan function - try { - hashTable foo(40); - node tmp; - foo.add(&tmp); - } - catch (const char *badness) - { - if (strcmp(badness,"Attempting to use a hash table without setting up a 'hash' function")) - error ("Failure on adding with no hash, error = %s\n", badness); - error ("Success on adding with no hash, \n" ); - } - catch(...) - { - error ("Failure on adding with no hash, unknown exception\n"); - } - - hashTable *moo; - moo=new hashTable(20); - hashTable &foo=*moo; - - foo.setHash(hash); - foo.setIsEqual(isEqual); - - error ("Add the first couple, in order (easy)\n"); - hashTest first(1); - foo.add(&first); - hashTest second(2); - foo.add(&second); - foo.dump(); - - error ("Add the next three, not in order (harder)\n"); - hashTest third(3); - hashTest fourth(4); - hashTest fifth(5); - foo.add(&fourth); - foo.add(&third); - foo.add(&fifth); - foo.dump(); - - error ("Create bar, populated with 1000 values"); - hashTable bar(200); - bar.setHash(hash); - bar.setIsEqual(isEqual); - for (int a=0;a<100;a++) - bar.add(new hashTest(a)); - for (int a=999;a>=100;a--) - bar.add(new hashTest(a)); - bar.dump(); - - error ("Removing simple case: remove 1,leave 2,3,4,5 \n"); - foo.remove(&first); - foo.dump(); - error ("Removing simple case: remove 2,leave 3,4,5 \n"); - foo.remove(&second); - foo.dump(); - - error ("Setting up middle case (reading 1 and 2)\n"); - foo.add(&first); - foo.add(&second); - foo.dump(); - error ("Removing middle case (removing 2)\n"); - foo.remove(&second); - foo.dump(); - error ("Removing middle case (removing 1)\n"); - foo.remove(&first); - foo.dump(); - - error ("Finding 1\n"); - hashTest findOne(1); - hashTest *found=(hashTest *)bar.find(&findOne); - error ("found value = %d\n",found->value); - - error ("Finding 77\n"); - hashTest findSeventySeven(77); - hashTest *found77=(hashTest *)bar.find(&findSeventySeven); - error ("found value = %d\n",found77->value); - - error ("ensuringSane on smaller (foo) = %s\n",((foo.ensureSane())?"OK":"BAD!")); - error ("ensuringSane on larger (bar) = %s\n",((bar.ensureSane())?"OK":"BAD!")); - - - int count=0; - for (hashIterate hi(bar);node *next=hi.get();) { - count++; - if (next==NULL) - error ("Found a NULL at %d\n",count); - } - if (count==1000) - error ("found 1000, as expected!\n"); - else - error ("did NOT find 1000, as expected, found %d!\n",count); - delete moo; - return 0; -} diff --git a/src/tests/system/vm2/mmapTest1.C b/src/tests/system/vm2/mmapTest1.C deleted file mode 100644 index 2eedc0ef55..0000000000 --- a/src/tests/system/vm2/mmapTest1.C +++ /dev/null @@ -1,46 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include - -vmInterface *vm; - -void writeByte(unsigned long addr,unsigned int offset, char value) { vm->setByte(addr+offset,value); } -unsigned char readByte(unsigned long addr,unsigned int offset ) { char value=vm->getByte(addr+offset); return value; } - -int main(int argc,char **argv) -{ - try { - vm = new vmInterface (30); - error ("Starting Threads!\n"); - - int myfd=open("mmap_test_1_file",O_RDWR|O_CREAT,0707); - error ("error = %s\n",strerror(errno)); - /* - close (myfd); - return 0; - */ - unsigned long result=(unsigned long)(vm->mmap(NULL,16384,PROT_WRITE|PROT_READ,MAP_SHARED,myfd,0)); - for (int i=0;i<16384;i++) - writeByte(result,i,'A'); - for (int i=0;i<16384;i++) - if ('A' != readByte(result,i)) - error ("Non matching byte %c at offset %d"); - vm->munmap((void *)result,16384); - close (myfd); - } - catch (const char *t) - { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) - { - error ("Unknown Exception thrown!\n"); - exit(1); - } - - return 0; -} diff --git a/src/tests/system/vm2/mmapTest2.C b/src/tests/system/vm2/mmapTest2.C deleted file mode 100644 index f413428279..0000000000 --- a/src/tests/system/vm2/mmapTest2.C +++ /dev/null @@ -1,57 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include - -vmInterface *vm; - -void writeByte(unsigned long addr,unsigned int offset, char value) { vm->setByte(addr+offset,value); } -unsigned char readByte(unsigned long addr,unsigned int offset ) { char value=vm->getByte(addr+offset); return value; } - -int main(int argc,char **argv) -{ - try { - vm = new vmInterface (90); - - int myfd=open("mmap_test_2_file",O_RDWR|O_CREAT,0707); - if (myfd==-1) - error ("file opening error = %s\n",strerror(errno)); - - unsigned long result=(unsigned long)(vm->mmap(NULL,32768,PROT_WRITE|PROT_READ,MAP_SHARED,myfd,0)); - for (int i=0;i<16384;i++) { - writeByte(result,i*2,'B'); - writeByte(result,2*i+1,' '); - } - vm->munmap((void *)result,32768); - close (myfd); -//----------------------------------------------------------------------------------------------------------- - myfd=open("mmap_test_2_file",O_RDONLY,0444); - if (myfd==-1) - error ("file reopening error = %s\n",strerror(errno)); - - result=(unsigned long)(vm->mmap(NULL,32768,PROT_WRITE|PROT_READ,MAP_SHARED,myfd,0)); - - for (int i=0;i<16384;i++) { - if ('B' != readByte(result,i*2)) - error ("Non matching byte %c at offset %d\n"); - if (' ' != readByte(result,2*i+1)) - error ("Non matching byte %c at offset %d\n"); - } - vm->munmap((void *)result,32768); - close (myfd); - } - catch (const char *t) - { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) - { - error ("Unknown Exception thrown!\n"); - exit(1); - } - - return 0; -} diff --git a/src/tests/system/vm2/mmapTest3.C b/src/tests/system/vm2/mmapTest3.C deleted file mode 100644 index 26e40b6554..0000000000 --- a/src/tests/system/vm2/mmapTest3.C +++ /dev/null @@ -1,57 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include - -vmInterface *vm; - -void writeByte(unsigned long addr,unsigned int offset, char value) { vm->setByte(addr+offset,value); } -unsigned char readByte(unsigned long addr,unsigned int offset ) { return vm->getByte(addr+offset);} - -int main(int argc,char **argv) -{ - try { - vm = new vmInterface (90); - - system ("rm mmap_test_3_file"); - int myfd=open("mmap_test_3_file",O_RDWR|O_CREAT,0777); - if (myfd==-1) - error ("file opening error = %s\n",strerror(errno)); - - unsigned long result=(unsigned long)(vm->mmap(NULL,32768,PROT_WRITE|PROT_READ,MAP_SHARED,myfd,0)); - error ("result = %x\n",result); - for (int i=0;i<16384;i++) { - writeByte(result,i*2,'B'); - writeByte(result,2*i+1,' '); - } - - unsigned long result2=(unsigned long)(vm->mmap(NULL,32768,PROT_WRITE|PROT_READ,MAP_SHARED,myfd,0)); - error ("result2 = %x\n",result2); - char a; - for (int i=0;i<16384;i+=2048) { - a = readByte(result2,i*2); - if ('B' != a) - error ("Non matching byte %c at offset %d\n",a,i*2); - a = readByte(result2,i*2+1); - if (' ' != a) - error ("Non matching byte %c at offset %d\n",a,i*2+1); - } - vm->munmap((void *)result,32768); - close (myfd); - vm->munmap((void *)result2,32768); - } - catch (const char *t) - { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) - { - error ("Unknown Exception thrown!\n"); - exit(1); - } - - return 0; -} diff --git a/src/tests/system/vm2/olTest.C b/src/tests/system/vm2/olTest.C deleted file mode 100644 index 47a268fbbe..0000000000 --- a/src/tests/system/vm2/olTest.C +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include -#include -#include -#include "olist.h" -#include "error.h" -#include "OS.h" - -struct iltTest : public node -{ - iltTest(int i) {value=i;} - int value; -}; - -bool ilt(void *a,void *b) -{ - iltTest *a1=reinterpret_cast(a); - iltTest *b1=reinterpret_cast(b); - if (a1->valuevalue) - return true; - return false; -} - -int main(int argc,char **argv) -{ - - // Test 1 - Try to add to foo without setting an isLessThan function - try { - orderedList foo; - node tmp; - foo.add(&tmp); - } - catch (const char *badness) - { - if (strcmp(badness,"Attempting to use an ordered list without setting up a 'toLessThan' function")) - printf ("Failure on adding with no isLessThan, printf = %s\n", badness); - printf ("Success on adding with no isLessThan, \n" ); - } - catch(...) - { - printf ("Failure on adding with no isLessThan, unknown exception\n"); - } - - orderedList foo; - foo.setIsLessThan(ilt); - - printf ("Add the first couple, in order (easy)\n"); - iltTest first(1); - foo.add(&first); - iltTest second(2); - foo.add(&second); - foo.dump(); - - printf ("Add the next three, not in order (harder)\n"); - iltTest third(3); - iltTest fourth(4); - iltTest fifth(5); - foo.add(&fourth); - foo.add(&third); - foo.add(&fifth); - foo.dump(); - while (iltTest *n=(iltTest *)(foo.next())) - printf ("Popped %d\n",n->value); - - orderedList bar; - bar.setIsLessThan(ilt); - while (iltTest *n=(iltTest *)(bar.next())) - printf ("Popped %d\n",n->value); - for (int a=0;a<100;a++) - bar.add(new iltTest(a)); - while (iltTest *n=(iltTest *)(bar.next())) - printf ("Popped %d\n",n->value); - for (int a=1000;a>=0;a--) - bar.add(new iltTest(a)); - while (iltTest *n=(iltTest *)(bar.next())) - if (!(n->value%50)) printf ("Popped %d\n",n->value); - - printf ("Setting up simple case\n"); - foo.add(&first); - foo.dump(); - printf ("Removing simple case\n"); - foo.remove(&first); - foo.dump(); - - printf ("Setting up middle case\n"); - foo.add(&first); - foo.add(&second); - foo.dump(); - printf ("Removing middle case\n"); - foo.remove(&second); - foo.dump(); - foo.remove(&first); - - printf ("Setting up final case\n"); - foo.add(&first); - foo.add(&second); - foo.add(&third); - foo.dump(); - printf ("Removing final case\n"); - foo.remove(&second); - foo.dump(); - return 0; -} diff --git a/src/tests/system/vm2/pageManTest.C b/src/tests/system/vm2/pageManTest.C deleted file mode 100644 index 86bf52062c..0000000000 --- a/src/tests/system/vm2/pageManTest.C +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include -#include -#include -#include "pageManager.h" -#include "OS.h" - -enum testType {clean,unused,inuse}; - -pageManager pm; -char *testName; - -bool testCount (int expected, testType type) -{ - int found; - switch (type) { - case clean: - if (found=pm.getCleanCount()!=expected) { - error ("%s, invalid cleanCount of %d, expected: %d\n",testName,found,expected); - return false; - } - break; - case unused: - if (found=pm.getUnusedCount()!=expected) { - error ("%s, invalid unusedCount of %d, expected: %d\n",testName,found,expected); - return false; - } - break; - case inuse: - if (found=pm.getInUseCount()!=expected) { - error ("%s, invalid InUseCount of %d, expected: %d\n",testName,found,expected); - return false; - } - break; - } - return true; -} - -int main(int argc,char **argv) -{ - testName="Setup"; - - pm.setup(malloc(PAGE_SIZE*100),100); - - if (!(testCount(99,unused) || testCount (0,clean) || testCount (0,inuse))) { - pm.dump(); - exit(1); - } - - testName="Get One"; - page *gotten = pm.getPage(); - if (!(testCount(98,unused) || testCount (0,clean) || testCount (1,inuse))) { - pm.dump(); - exit(1); - } - - testName="Put One"; - pm.freePage(gotten); - if (!(testCount(99,unused) || testCount (0,clean) || testCount (0,inuse))) { - pm.dump(); - exit(1); - } - - testName="Clean One"; - pm.cleanOnePage(); - if (!(testCount(98,unused) || testCount (1,clean) || testCount (0,inuse))) { - pm.dump(); - exit(1); - } - - testName="Get One Cleaned"; - gotten = pm.getPage(); - if (!(testCount(98,unused) || testCount (0,clean) || testCount (1,inuse))) { - pm.dump(); - exit(1); - } - - testName="Put One Cleaned"; - pm.freePage(gotten); - if (!(testCount(99,unused) || testCount (0,clean) || testCount (0,inuse))) { - pm.dump(); - exit(1); - } - - testName="Get them all"; - page *pages[100]; - for (int i=0;i<99;i++) - pages[i]=pm.getPage(); - if (!(testCount(0,unused) || testCount (0,clean) || testCount (99,inuse))) { - pm.dump(); - exit(1); - } - - testName="Free them all"; - for (int i=0;i<99;i++) - pm.freePage(pages[i]); - if (!(testCount(99,unused) || testCount (0,clean) || testCount (0,inuse))) { - pm.dump(); - exit(1); - } - exit(0); -} diff --git a/src/tests/system/vm2/resizeArea.C b/src/tests/system/vm2/resizeArea.C deleted file mode 100644 index a9c5e2c457..0000000000 --- a/src/tests/system/vm2/resizeArea.C +++ /dev/null @@ -1,68 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include -#include - -vmInterface *vm; - -int main(int argc,char **argv) -{ - int areaNum; - char *testName; - void *foo; - unsigned long baseAddress; - - testName="vmInterface construction"; - try { vm = new vmInterface (30); } - catch (const char *t) { error ("Exception thrown in %s! %s\n",testName,t); exit(1); } - - try { - testName="resizeArea with unknown area test"; - if (vm->resizeArea(54,8192)>=0) - error ("%s failed!\n",testName); - else - error ("%s passed!\n",testName); - - if ((areaNum=vm->createArea("test",1,&foo))<0) - throw (testName); - baseAddress=(unsigned long)foo; - - testName="initial test sizes of area"; - try {vm->setInt(baseAddress-1,25); error ("%s lower bounds test failed!\n",testName); } catch (char *t) {error ("%s lower bounds test passed!\n",testName);} - try {vm->setInt(baseAddress+8192,25); error ("%s upper bounds test failed!\n",testName);} catch (char *t) {error ("%s upper bounds test passed!\n",testName);} - - testName="enlarging size of area"; - if (vm->resizeArea(areaNum,16384)!=B_OK) - error ("%s failed!\n",testName); - else - error ("%s passed!\n",testName); - - testName=" test enlarged sizes of area"; - try {vm->setInt(baseAddress-1,25); error ("%s lower bounds test failed!\n",testName); } catch (char *t) {error ("%s lower bounds test passed!\n",testName);} - try {vm->setInt(baseAddress+8192,25); error ("%s middle bounds test passed!\n",testName);} catch (char *t) {error ("%s middle bounds test failed!\n",testName);} - try {vm->setInt(baseAddress+16385,25); error ("%s upper bounds test failed!\n",testName);} catch (char *t) {error ("%s upper bounds test passed!\n",testName);} - - testName="reducing size of area"; - if (vm->resizeArea(areaNum,4096)!=B_OK) - error ("%s failed!\n",testName); - else - error ("%s passed!\n",testName); - - testName=" test enlarged sizes of area"; - try {vm->setInt(baseAddress-1,25); error ("%s lower bounds test failed!\n",testName); } catch (char *t) {error ("%s lower bounds test passed!\n",testName);} - try {vm->setInt(baseAddress+4097,25); error ("%s upper bounds test failed!\n",testName);} catch (char *t) {error ("%s upper bounds test passed!\n",testName);} - } - catch (const char *t) { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) { - error ("Unknown Exception thrown!\n"); - exit(1); - } - - return 0; -} diff --git a/src/tests/system/vm2/simpleTest.C b/src/tests/system/vm2/simpleTest.C deleted file mode 100644 index eef3b4a0ef..0000000000 --- a/src/tests/system/vm2/simpleTest.C +++ /dev/null @@ -1,60 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include - -vmInterface *vm; - -void writeByte(unsigned long addr,unsigned int offset, char value) { vm->setByte(addr+offset,value); } -unsigned char readByte(unsigned long addr,unsigned int offset ) { char value=vm->getByte(addr+offset); return value; } - -int createFillAndTest(int pages,char *name) -{ - unsigned long addr; - int area1; - error ("%s: createFillAndTest: about to create \n",name); - area1=vm->createArea(name,pages,(void **)(&addr)); - error ("%s: createFillAndTest: create done\n",name); - for (int i=0;ifreeArea(area1); - error ("%s: createFillAndTest: reading done\n",name); - return area1; -} - -int main(int argc,char **argv) -{ - try { - vm = new vmInterface (30); - error ("Starting Threads!\n"); - - for (int i=0;i<20;i++) - createFillAndTest(1,"myTest"); - } - catch (const char *t) - { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) - { - error ("Unknown Exception thrown!\n"); - exit(1); - } - - return 0; -} diff --git a/src/tests/system/vm2/test.C b/src/tests/system/vm2/test.C deleted file mode 100644 index ffe66caa0c..0000000000 --- a/src/tests/system/vm2/test.C +++ /dev/null @@ -1,226 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include - -vmInterface vm(30); -thread_id loop1,loop2,loop3,info1,mmap1,clone1; - -void writeByte(unsigned long addr,unsigned int offset, char value) { vm.setByte(addr+offset,value); } - -unsigned char readByte(unsigned long addr,unsigned int offset ) { char value=vm.getByte(addr+offset); return value; } - -int createFillAndTest(int pages,char *name) -{ - try{ - unsigned long addr; - int area1; - error ("%s: createFillAndTest: about to create \n",name); - area1=vm.createArea("Mine",pages,(void **)(&addr)); - error ("%s: createFillAndTest: create done\n",name); - for (int i=0;iinitialSnooze); - error ("Creating %s area\n",params->name); - area1=createFillAndTest(params->areaSize,params->name); - snooze(params->holdSnooze); - error ("Freeing %s area\n",params->name); - vm.freeArea(area1); - snooze(params->loopSnooze); - } - } - catch (const char *t) - { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) - { - error ("Exception thrown!\n"); - exit(1); - } - } - -int32 getInfoTest(void *parameters) - { - loopTestParameters *params=((loopTestParameters *)parameters); - area_info ai; - int area1; - - try{ - while (1) - { - snooze(params->initialSnooze); - //error ("Creating %s area\n",params->name); - area1=createFillAndTest(params->areaSize,params->name); - snooze(params->holdSnooze); - - vm.getAreaInfo(area1,&ai); - error ("Area info : \n"); - error ("name : %s\n",ai.name); - error ("size : %ld\n",ai.size); - error ("lock : %ld\n",ai.lock); - error ("team : %ld\n",ai.team); - error ("ram_size : %ld\n",ai.ram_size); - error ("in_count : %ld\n",ai.in_count); - error ("out_count : %ld\n",ai.out_count); - error ("copy_count : %ld\n",ai.copy_count); - error ("address : %p\n",ai.address); - - error ("Freeing %s area\n",params->name); - vm.freeArea(area1); - snooze(params->loopSnooze); - } - } - catch (const char *t) - { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) - { - error ("Exception thrown!\n"); - exit(1); - } - } - -int32 mmapTest (void *parameters) - { - try{ - void *map; - loopTestParameters *params=((loopTestParameters *)parameters); - int size=params->areaSize; // Note that this is in bytes, not in pages - while (1) - { - int fd = open ("OBOS_mmap",O_RDWR|O_CREAT,0x777); - error ("Opened file, fd = %d\n",fd); - snooze(params->initialSnooze); - error ("Creating %s mmap\n",params->name); - snooze(params->holdSnooze); - map=vm.mmap(NULL,size,PROT_WRITE|PROT_READ,MAP_SHARED,fd,0); - error ("mmap address = %p\n",map); - for (int i=0;iloopSnooze); - vm.munmap(map,size); - close(fd); - error ("Closed file, fd = %d\n",fd); - } - } - catch (const char *t) - { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) - { - error ("Exception thrown!\n"); - exit(1); - } - } - -int32 cloneTest (void *parameters) - { - loopTestParameters *params=((loopTestParameters *)parameters); - int area1,area2; - void *cloneAddr=NULL; - try { - while (1) - { - snooze(params->initialSnooze); - // error ("Creating %s area, size = %d\n",params->name,params->areaSize); - area1=createFillAndTest(params->areaSize,params->name); - // error ("cloning, create done \n"); - area2=vm.cloneArea(area1,"Clone1",&cloneAddr); - for (int i=0;iareaSize*PAGE_SIZE;i++) - if (i%256!=readByte((int32)cloneAddr,i)) - error ("ERROR! Clone Byte at offset %d of %p does not match: expected: %d, found: %d\n",i,cloneAddr,i%256,readByte((int32)cloneAddr,i)); - // error ("Snoozing, compare done \n"); - snooze(params->holdSnooze); - // error ("Freeing %s area\n",params->name); - vm.freeArea(area2); - vm.freeArea(area1); - snooze(params->loopSnooze); - } - } - catch (...) - { - error ("Exception thrown!\n"); - exit(1); - } - } - -int main(int argc,char **argv) -{ - loopTestParameters area1Params={"area1",1000000,2,100000,100000}; - loopTestParameters area2Params={"area2",1000000,2,200000,100000}; - loopTestParameters area3Params={"area3",1000000,2,300000,200000}; - loopTestParameters info1Params={"info1",500000,2,400000,30000}; - loopTestParameters mmap1Params={"mmap",500000,8192,400000,1000000}; - loopTestParameters clone1Params={"clone1",200000,2,300000,400000}; - - error ("Starting Threads!\n"); - //resume_thread(loop1=spawn_thread(loopTest,"area test 1",0,&area1Params)); - //resume_thread(loop2=spawn_thread(loopTest,"area test 2",0,&area2Params)); - //resume_thread(loop3=spawn_thread(loopTest,"area test 3",0,&area3Params)); - resume_thread(info1=spawn_thread(getInfoTest,"info test 1",0,&info1Params)); - //resume_thread(mmap1=spawn_thread(mmapTest,"mmap test 1",0,&mmap1Params)); - //resume_thread(clone1=spawn_thread(cloneTest,"clone test 1",0,&clone1Params)); - - snooze(1000000000); - - return 0; -} diff --git a/src/tests/system/vm2/testSetup.C b/src/tests/system/vm2/testSetup.C deleted file mode 100644 index 5e1fbae8dc..0000000000 --- a/src/tests/system/vm2/testSetup.C +++ /dev/null @@ -1,30 +0,0 @@ -#include "vmInterface.h" -#include -#include -#include -#include -#include - -vmInterface *vm; - -int main(int argc,char **argv) -{ - try { - vm = new vmInterface (90); - - while (1) - snooze(1000000); - } - catch (const char *t) - { - error ("Exception thrown! %s\n",t); - exit(1); - } - catch (...) - { - error ("Unknown Exception thrown!\n"); - exit(1); - } - - return 0; -} diff --git a/src/tests/system/vm2/testsToDo b/src/tests/system/vm2/testsToDo deleted file mode 100644 index 7d05ed2728..0000000000 --- a/src/tests/system/vm2/testsToDo +++ /dev/null @@ -1,74 +0,0 @@ -Tests that need to be created, by interface function - -createArea - - improve some of the successful tests. - -freeArea - - successful tests - -getAreaInfo - - successful tests - -getNextAreaInfo - - on first area - - on last area - -getAreaByName - - more successful tests - -getAreaByAddress - - more successful tests - -cloneArea - - invalid area to clone - - all others as with createArea - -resizeArea - - make it smaller - - make it larger - - with unknown area - -setAreaProtection - - on unknown area - - to read only - - to write only - - to r/w - -mmap - - size of 0, -1, etc - - different flag combinations - - non-existant FD - - offset outside of file - -munmap - - to an address that doesn't exist - - for an invalid length - -writeCachedBlock - - non-existant FD - - offset outside of file - - NULL data - -readCachedBlock - - non-existant FD - - offset outside of file - - NULL data - -get_memory_map - - NULL address - - numBytes=0 - - physical entry table NULL - - numEntries = 0 - -lock_memory - - address of NULL - - numBytes = 0 - - various flags - -unlock_memory - - address of NULL - - numBytes = 0 - - various flags - -map_physical_memory - - same as createArea