diff --git a/src/tests/system/kernel/Jamfile b/src/tests/system/kernel/Jamfile index 85a3f41e8a..8a6ed11566 100644 --- a/src/tests/system/kernel/Jamfile +++ b/src/tests/system/kernel/Jamfile @@ -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 ; diff --git a/src/tests/system/kernel/port_close_test_1.cpp b/src/tests/system/kernel/port_close_test_1.cpp new file mode 100644 index 0000000000..fcdbc1de86 --- /dev/null +++ b/src/tests/system/kernel/port_close_test_1.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2006, Marcus Overhagen, + * Distributed under the terms of the MIT License. + */ + + +#include +#include +#include + +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; +} diff --git a/src/tests/system/kernel/port_close_test_2.cpp b/src/tests/system/kernel/port_close_test_2.cpp new file mode 100644 index 0000000000..ad692f98b1 --- /dev/null +++ b/src/tests/system/kernel/port_close_test_2.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2006, Marcus Overhagen, + * Distributed under the terms of the MIT License. + */ + + +#include +#include +#include + +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; +}