Added more mmap tests, and a file indicating what tests are yet to be done.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2503 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a0e033784d
commit
d89abe1f52
@ -9,3 +9,4 @@ BinCommand simpleTest : simpleTest.C : root be libvm.so ;
|
|||||||
BinCommand setup : testSetup.C : root be libvm.so ;
|
BinCommand setup : testSetup.C : root be libvm.so ;
|
||||||
BinCommand mmapTest1 : mmapTest1.C : root be libvm.so ;
|
BinCommand mmapTest1 : mmapTest1.C : root be libvm.so ;
|
||||||
BinCommand mmapTest2 : mmapTest2.C : root be libvm.so ;
|
BinCommand mmapTest2 : mmapTest2.C : root be libvm.so ;
|
||||||
|
BinCommand mmapTest3 : mmapTest3.C : root be libvm.so ;
|
||||||
|
57
src/kernel/vm2/tests/mmapTest3.C
Normal file
57
src/kernel/vm2/tests/mmapTest3.C
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#include "vmInterface.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <mman.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
93
src/kernel/vm2/tests/testsToDo
Normal file
93
src/kernel/vm2/tests/testsToDo
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user