added tests for kernel ports

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16644 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marcus Overhagen 2006-03-08 14:07:28 +00:00
parent a0795c6fe3
commit 89107618d5
3 changed files with 130 additions and 0 deletions

View File

@ -3,6 +3,14 @@ SubDir HAIKU_TOP src tests system kernel ;
UsePrivateHeaders kernel ;
UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ;
SimpleTest port_close_test_1 :
port_close_test_1.cpp
;
SimpleTest port_close_test_2 :
port_close_test_2.cpp
;
SimpleTest transfer_area_test :
transfer_area_test.cpp
;

View File

@ -0,0 +1,61 @@
/*
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
* Distributed under the terms of the MIT License.
*/
#include <OS.h>
#include <stdio.h>
#include <string.h>
int
main()
{
port_id id;
status_t s;
size_t size;
int32 code;
char data[100];
id = create_port(10, "test port");
printf("created port %ld\n", id);
s = write_port(id, 0x1234, data, 10);
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
s = write_port(id, 0x5678, data, 20);
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
s = close_port(id);
printf("close port result 0x%08lx (%s)\n", s, strerror(s));
// BeBook: does return B_BAD_PORT_ID if port was closed
s = write_port(id, 0x5678, data, 20);
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
size = port_buffer_size(id);
printf("port_buffer_size %ld\n", size);
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
size = read_port(id, &code, data, sizeof(data));
printf("read port size %ld, code %lx, result 0x%08lx (%s)\n", size, code, s, strerror(s));
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
size = port_buffer_size(id);
printf("port_buffer_size %ld\n", size);
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
size = read_port(id, &code, data, sizeof(data));
printf("read port size %ld, code %lx, result 0x%08lx (%s)\n", size, code, s, strerror(s));
printf("should block now\n");
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
size = port_buffer_size(id);
printf("port_buffer_size %ld\n", size);
return 0;
}

View File

@ -0,0 +1,61 @@
/*
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
* Distributed under the terms of the MIT License.
*/
#include <OS.h>
#include <stdio.h>
#include <string.h>
int
main()
{
port_id id;
status_t s;
size_t size;
int32 code;
char data[100];
id = create_port(10, "test port");
printf("created port %ld\n", id);
s = write_port(id, 0x1234, data, 10);
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
s = write_port(id, 0x5678, data, 20);
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
s = close_port(id);
printf("close port result 0x%08lx (%s)\n", s, strerror(s));
// BeBook: does return B_BAD_PORT_ID if port was closed
s = write_port(id, 0x5678, data, 20);
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
size = port_buffer_size(id);
printf("port_buffer_size %ld\n", size);
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
size = read_port(id, &code, data, sizeof(data));
printf("read port size %ld, code %lx, result 0x%08lx (%s)\n", size, code, s, strerror(s));
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
size = port_buffer_size(id);
printf("port_buffer_size %ld\n", size);
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
size = read_port(id, &code, data, sizeof(data));
printf("read port size %ld, code %lx, result 0x%08lx (%s)\n", size, code, s, strerror(s));
printf("should block now\n");
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
size = read_port(id, &code, data, sizeof(data));
printf("read port size %ld, code %lx, result 0x%08lx (%s)\n", size, code, s, strerror(s));
return 0;
}