From da9b743b20f15d5961a5d02f308ec515078e581c Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Wed, 8 Mar 2006 14:22:56 +0000 Subject: [PATCH] modified tests. The results on BeOS R5 do not match the BeBook description. $ /boot/home/develop/haiku/generated/objects/haiku/x86/debug_1/tests/system/kernel/port_close_test_1 created port 2269 write port result 0x00000000 (No Error) write port result 0x00000000 (No Error) close port result 0x00000000 (No Error) write port result 0x80001200 (Bad port ID) port_buffer_size -2147479552 (0x80001000) (Bad semaphore ID) read port code 1234, size 10 (0x0000000a) (Unknown Error (10)) port_buffer_size -2147479552 (0x80001000) (Bad semaphore ID) read port code 5678, size 20 (0x00000014) (Unknown Error (20)) should block now port_buffer_size -2147479552 (0x80001000) (Bad semaphore ID) $ /boot/home/develop/haiku/generated/objects/haiku/x86/debug_1/tests/system/kernel/port_close_test_2 created port 2270 write port result 0x00000000 (No Error) write port result 0x00000000 (No Error) close port result 0x00000000 (No Error) write port result 0x80001200 (Bad port ID) port_buffer_size -2147479552 (0x80001000) (Bad semaphore ID) read port code 1234, size 10 (0x0000000a) (Unknown Error (10)) port_buffer_size -2147479552 (0x80001000) (Bad semaphore ID) read port code 5678, size 20 (0x00000014) (Unknown Error (20)) should block now read port code 5678, size -2147479040 (0x80001200) (Bad port ID) $ /boot/home/develop/haiku/generated/objects/haiku/x86/debug_1/tests/system/kernel/port_delete_test created port 2271 write port result 0x00000000 (No Error) write port result 0x00000000 (No Error) delete port result 0x00000000 (No Error) everything should fail now write port result 0x80001200 (Bad port ID) port_buffer_size -2147479040 (0x80001200) (Bad port ID) read port code 0, size -2147479040 (0x80001200) (Bad port ID) $ git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16645 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/system/kernel/Jamfile | 4 ++ src/tests/system/kernel/port_close_test_1.cpp | 10 ++-- src/tests/system/kernel/port_close_test_2.cpp | 10 ++-- src/tests/system/kernel/port_delete_test.cpp | 49 +++++++++++++++++++ 4 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 src/tests/system/kernel/port_delete_test.cpp diff --git a/src/tests/system/kernel/Jamfile b/src/tests/system/kernel/Jamfile index 8a6ed11566..1f58d2ef04 100644 --- a/src/tests/system/kernel/Jamfile +++ b/src/tests/system/kernel/Jamfile @@ -11,6 +11,10 @@ SimpleTest port_close_test_2 : port_close_test_2.cpp ; +SimpleTest port_delete_test : + port_delete_test.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 index fcdbc1de86..23b2b48c2f 100644 --- a/src/tests/system/kernel/port_close_test_1.cpp +++ b/src/tests/system/kernel/port_close_test_1.cpp @@ -37,25 +37,25 @@ main() // 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); + printf("port_buffer_size %ld (0x%08lx) (%s)\n", size, size, strerror(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("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size)); // 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); + printf("port_buffer_size %ld (0x%08lx) (%s)\n", size, size, strerror(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("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size)); 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); + printf("port_buffer_size %ld (0x%08lx) (%s)\n", size, size, strerror(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 index ad692f98b1..4b3983ddab 100644 --- a/src/tests/system/kernel/port_close_test_2.cpp +++ b/src/tests/system/kernel/port_close_test_2.cpp @@ -37,25 +37,25 @@ main() // 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); + printf("port_buffer_size %ld (0x%08lx) (%s)\n", size, size, strerror(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("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size)); // 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); + printf("port_buffer_size %ld (0x%08lx) (%s)\n", size, size, strerror(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("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size)); 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)); + printf("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size)); return 0; } diff --git a/src/tests/system/kernel/port_delete_test.cpp b/src/tests/system/kernel/port_delete_test.cpp new file mode 100644 index 0000000000..25700a5c7f --- /dev/null +++ b/src/tests/system/kernel/port_delete_test.cpp @@ -0,0 +1,49 @@ +/* + * 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 = delete_port(id); + printf("delete port result 0x%08lx (%s)\n", s, strerror(s)); + + printf("everything should fail now\n"); + + // 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 (0x%08lx) (%s)\n", size, size, strerror(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 code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size)); + + return 0; +}