Test to quickly reproduce bug #2471.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26247 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-07-04 15:20:43 +00:00
parent af637076ad
commit 063a092f93
2 changed files with 61 additions and 0 deletions

View File

@ -15,6 +15,8 @@ SimpleTest lock_node_test :
: be
;
SimpleTest page_fault_cache_merge_test : page_fault_cache_merge_test.cpp ;
SimpleTest port_close_test_1 : port_close_test_1.cpp ;
SimpleTest port_close_test_2 : port_close_test_2.cpp ;

View File

@ -0,0 +1,59 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
#include <OS.h>
static const int kAreaPagesCount = 4 * 1024; // 16 MB
int
main()
{
while (true) {
uint8* address;
area_id area = create_area("test area", (void**)&address, B_ANY_ADDRESS,
kAreaPagesCount * B_PAGE_SIZE, B_NO_LOCK,
B_READ_AREA | B_WRITE_AREA);
if (area < 0) {
fprintf(stderr, "Creating the area failed: %s", strerror(area));
exit(1);
}
// touch half of the pages
for (int i = 0; i < kAreaPagesCount / 2; i++)
address[i * B_PAGE_SIZE] = 42;
// fork
pid_t child = fork();
if (child < 0) {
perror("fork() failed");
exit(1);
}
if (child == 0) {
// child
// delete the copied area
delete_area(area_for(address));
exit(0);
}
// parent
// touch the other half of the pages
for (int i = kAreaPagesCount / 2; i < kAreaPagesCount; i++)
address[i * B_PAGE_SIZE] = 42;
int status;
while (wait(&status) != child);
delete_area(area);
}
return 0;
}