diff --git a/src/kernel/vm2/tests/Jamfile b/src/kernel/vm2/tests/Jamfile index df090e7666..2de91efff0 100644 --- a/src/kernel/vm2/tests/Jamfile +++ b/src/kernel/vm2/tests/Jamfile @@ -9,3 +9,4 @@ 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 ; diff --git a/src/kernel/vm2/tests/mmapTest3.C b/src/kernel/vm2/tests/mmapTest3.C new file mode 100644 index 0000000000..26e40b6554 --- /dev/null +++ b/src/kernel/vm2/tests/mmapTest3.C @@ -0,0 +1,57 @@ +#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/kernel/vm2/tests/testsToDo b/src/kernel/vm2/tests/testsToDo new file mode 100644 index 0000000000..e8fb76fc48 --- /dev/null +++ b/src/kernel/vm2/tests/testsToDo @@ -0,0 +1,93 @@ +Tests that need to be created, by interface function + +createArea + - NULL name + - Huge name + - 0 page count + - page count larger than VM + - page count larger than physical memory + - specified address (EXACT) + - base address (BASE) + - kernel address (ANY_KERNEL) + - clone (CLONE) - should fail + - FULL_LOCK + - CONTIGUOUS + - LAZY_LOCK + - NO_LOCK + - LOMEM + +freeArea + - on invalid area + - twice on same area + +getAreaInfo + - on non-existant area + - with NULL pointer + +getNextAreaInfo + - on first area + - on last area + +getAreaByName + - with NULL + - with unknown name + - with valid name + +getAreaByAddress + - with good address + - with bad address + - with NULL address + +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