more tests for port functionality
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16648 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
457c814fdc
commit
7f832a1ddb
@ -15,6 +15,42 @@ SimpleTest port_delete_test :
|
||||
port_delete_test.cpp
|
||||
;
|
||||
|
||||
SimpleTest port_wakeup_test_1 :
|
||||
port_wakeup_test_1.cpp
|
||||
;
|
||||
|
||||
SimpleTest port_wakeup_test_2 :
|
||||
port_wakeup_test_2.cpp
|
||||
;
|
||||
|
||||
SimpleTest port_wakeup_test_3 :
|
||||
port_wakeup_test_3.cpp
|
||||
;
|
||||
|
||||
SimpleTest port_wakeup_test_4 :
|
||||
port_wakeup_test_4.cpp
|
||||
;
|
||||
|
||||
SimpleTest port_wakeup_test_5 :
|
||||
port_wakeup_test_5.cpp
|
||||
;
|
||||
|
||||
SimpleTest port_wakeup_test_6 :
|
||||
port_wakeup_test_6.cpp
|
||||
;
|
||||
|
||||
SimpleTest port_wakeup_test_7 :
|
||||
port_wakeup_test_7.cpp
|
||||
;
|
||||
|
||||
SimpleTest port_wakeup_test_8 :
|
||||
port_wakeup_test_8.cpp
|
||||
;
|
||||
|
||||
SimpleTest port_wakeup_test_9 :
|
||||
port_wakeup_test_9.cpp
|
||||
;
|
||||
|
||||
SimpleTest transfer_area_test :
|
||||
transfer_area_test.cpp
|
||||
;
|
||||
|
@ -13,7 +13,7 @@ main()
|
||||
{
|
||||
port_id id;
|
||||
status_t s;
|
||||
size_t size;
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
char data[100];
|
||||
|
@ -13,7 +13,7 @@ main()
|
||||
{
|
||||
port_id id;
|
||||
status_t s;
|
||||
size_t size;
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
char data[100];
|
||||
|
@ -13,7 +13,7 @@ main()
|
||||
{
|
||||
port_id id;
|
||||
status_t s;
|
||||
size_t size;
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
char data[100];
|
||||
|
60
src/tests/system/kernel/port_wakeup_test_1.cpp
Normal file
60
src/tests/system/kernel/port_wakeup_test_1.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* A full port can't be written to. Thus the write from thread should block, until main thread reads.
|
||||
*
|
||||
*/
|
||||
|
||||
port_id id;
|
||||
char data[100];
|
||||
|
||||
int32
|
||||
test_thread(void *)
|
||||
{
|
||||
status_t s;
|
||||
|
||||
printf("write port...\n");
|
||||
s = write_port(id, 0x5678, data, 20);
|
||||
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
status_t s;
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
id = create_port(1, "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));
|
||||
|
||||
printf("write should block for 5 seconds now, as port is full\n");
|
||||
|
||||
thread_id thread = spawn_thread(test_thread, "test thread", B_NORMAL_PRIORITY, NULL);
|
||||
resume_thread(thread);
|
||||
snooze(5000000);
|
||||
|
||||
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
|
||||
printf("read port...\n");
|
||||
size = read_port(id, &code, data, sizeof(data));
|
||||
printf("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size));
|
||||
|
||||
printf("waiting for thread to terminate\n");
|
||||
wait_for_thread(thread, &s);
|
||||
|
||||
return 0;
|
||||
}
|
64
src/tests/system/kernel/port_wakeup_test_2.cpp
Normal file
64
src/tests/system/kernel/port_wakeup_test_2.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* A full port can't be written to. Thus the write from thread should block, until main thread reads.
|
||||
*
|
||||
*/
|
||||
|
||||
port_id id;
|
||||
char data[100];
|
||||
|
||||
int32
|
||||
test_thread(void *)
|
||||
{
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
|
||||
printf("read port...\n");
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
status_t s;
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
id = create_port(1, "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));
|
||||
|
||||
size = read_port(id, &code, data, sizeof(data));
|
||||
printf("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size));
|
||||
|
||||
printf("read should block for 5 seconds now, as port is empty\n");
|
||||
|
||||
thread_id thread = spawn_thread(test_thread, "test thread", B_NORMAL_PRIORITY, NULL);
|
||||
resume_thread(thread);
|
||||
snooze(5000000);
|
||||
|
||||
printf("write port...\n");
|
||||
s = write_port(id, 0x5678, data, 20);
|
||||
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
printf("waiting for thread to terminate\n");
|
||||
wait_for_thread(thread, &s);
|
||||
|
||||
return 0;
|
||||
}
|
63
src/tests/system/kernel/port_wakeup_test_3.cpp
Normal file
63
src/tests/system/kernel/port_wakeup_test_3.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* A full port can't be written to. Thus the write from thread should block, until main thread reads.
|
||||
*
|
||||
*/
|
||||
|
||||
port_id id;
|
||||
char data[100];
|
||||
|
||||
int32
|
||||
test_thread(void *)
|
||||
{
|
||||
ssize_t size;
|
||||
|
||||
// BeBook: does block when port is empty, and unblocks when port is written to or deleted
|
||||
printf("port_buffer_size...\n");
|
||||
size = port_buffer_size(id);
|
||||
printf("port_buffer_size size %ld (0x%08lx) (%s)\n", size, size, strerror(size));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
status_t s;
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
id = create_port(1, "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));
|
||||
|
||||
size = read_port(id, &code, data, sizeof(data));
|
||||
printf("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size));
|
||||
|
||||
printf("port_buffer_size should block for 5 seconds now, as port is empty\n");
|
||||
|
||||
thread_id thread = spawn_thread(test_thread, "test thread", B_NORMAL_PRIORITY, NULL);
|
||||
resume_thread(thread);
|
||||
snooze(5000000);
|
||||
|
||||
printf("write port...\n");
|
||||
s = write_port(id, 0x5678, data, 20);
|
||||
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
printf("waiting for thread to terminate\n");
|
||||
wait_for_thread(thread, &s);
|
||||
|
||||
return 0;
|
||||
}
|
57
src/tests/system/kernel/port_wakeup_test_4.cpp
Normal file
57
src/tests/system/kernel/port_wakeup_test_4.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* A full port can't be written to. Thus the write from thread should block, until main thread reads.
|
||||
*
|
||||
*/
|
||||
|
||||
port_id id;
|
||||
char data[100];
|
||||
|
||||
int32
|
||||
test_thread(void *)
|
||||
{
|
||||
status_t s;
|
||||
|
||||
printf("write port...\n");
|
||||
s = write_port(id, 0x5678, data, 20);
|
||||
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
status_t s;
|
||||
|
||||
id = create_port(1, "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));
|
||||
|
||||
printf("write should block for 5 seconds now, as port is full, until port is closed\n");
|
||||
|
||||
thread_id thread = spawn_thread(test_thread, "test thread", B_NORMAL_PRIORITY, NULL);
|
||||
resume_thread(thread);
|
||||
snooze(5000000);
|
||||
|
||||
printf("close port...\n");
|
||||
s = close_port(id);
|
||||
printf("close port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
printf("waiting for thread to terminate\n");
|
||||
wait_for_thread(thread, &s);
|
||||
|
||||
return 0;
|
||||
}
|
57
src/tests/system/kernel/port_wakeup_test_5.cpp
Normal file
57
src/tests/system/kernel/port_wakeup_test_5.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* A full port can't be written to. Thus the write from thread should block, until main thread reads.
|
||||
*
|
||||
*/
|
||||
|
||||
port_id id;
|
||||
char data[100];
|
||||
|
||||
int32
|
||||
test_thread(void *)
|
||||
{
|
||||
status_t s;
|
||||
|
||||
printf("write port...\n");
|
||||
s = write_port(id, 0x5678, data, 20);
|
||||
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
status_t s;
|
||||
|
||||
id = create_port(1, "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));
|
||||
|
||||
printf("write should block for 5 seconds now, as port is full, until port is deleted\n");
|
||||
|
||||
thread_id thread = spawn_thread(test_thread, "test thread", B_NORMAL_PRIORITY, NULL);
|
||||
resume_thread(thread);
|
||||
snooze(5000000);
|
||||
|
||||
printf("delete port...\n");
|
||||
s = delete_port(id);
|
||||
printf("delete port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
printf("waiting for thread to terminate\n");
|
||||
wait_for_thread(thread, &s);
|
||||
|
||||
return 0;
|
||||
}
|
63
src/tests/system/kernel/port_wakeup_test_6.cpp
Normal file
63
src/tests/system/kernel/port_wakeup_test_6.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* A full port can't be written to. Thus the write from thread should block, until main thread reads.
|
||||
*
|
||||
*/
|
||||
|
||||
port_id id;
|
||||
char data[100];
|
||||
|
||||
int32
|
||||
test_thread(void *)
|
||||
{
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
printf("read port...\n");
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
status_t s;
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
id = create_port(1, "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));
|
||||
|
||||
size = read_port(id, &code, data, sizeof(data));
|
||||
printf("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size));
|
||||
|
||||
printf("read should block for 5 seconds now, as port is empty, until port is closed\n");
|
||||
|
||||
thread_id thread = spawn_thread(test_thread, "test thread", B_NORMAL_PRIORITY, NULL);
|
||||
resume_thread(thread);
|
||||
snooze(5000000);
|
||||
|
||||
printf("close port...\n");
|
||||
s = close_port(id);
|
||||
printf("close port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
printf("waiting for thread to terminate\n");
|
||||
wait_for_thread(thread, &s);
|
||||
|
||||
return 0;
|
||||
}
|
63
src/tests/system/kernel/port_wakeup_test_7.cpp
Normal file
63
src/tests/system/kernel/port_wakeup_test_7.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* A full port can't be written to. Thus the write from thread should block, until main thread reads.
|
||||
*
|
||||
*/
|
||||
|
||||
port_id id;
|
||||
char data[100];
|
||||
|
||||
int32
|
||||
test_thread(void *)
|
||||
{
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
printf("read port...\n");
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
status_t s;
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
id = create_port(1, "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));
|
||||
|
||||
size = read_port(id, &code, data, sizeof(data));
|
||||
printf("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size));
|
||||
|
||||
printf("read should block for 5 seconds now, as port is empty, until port is deleted\n");
|
||||
|
||||
thread_id thread = spawn_thread(test_thread, "test thread", B_NORMAL_PRIORITY, NULL);
|
||||
resume_thread(thread);
|
||||
snooze(5000000);
|
||||
|
||||
printf("delete port...\n");
|
||||
s = delete_port(id);
|
||||
printf("delete port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
printf("waiting for thread to terminate\n");
|
||||
wait_for_thread(thread, &s);
|
||||
|
||||
return 0;
|
||||
}
|
62
src/tests/system/kernel/port_wakeup_test_8.cpp
Normal file
62
src/tests/system/kernel/port_wakeup_test_8.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* A full port can't be written to. Thus the write from thread should block, until main thread reads.
|
||||
*
|
||||
*/
|
||||
|
||||
port_id id;
|
||||
char data[100];
|
||||
|
||||
int32
|
||||
test_thread(void *)
|
||||
{
|
||||
ssize_t size;
|
||||
|
||||
printf("port_buffer_size...\n");
|
||||
size = port_buffer_size(id);
|
||||
printf("port_buffer_size size %ld (0x%08lx) (%s)\n", size, size, strerror(size));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
status_t s;
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
id = create_port(1, "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));
|
||||
|
||||
size = read_port(id, &code, data, sizeof(data));
|
||||
printf("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size));
|
||||
|
||||
printf("port_buffer_size should block for 5 seconds now, as port is empty, until port is closed\n");
|
||||
|
||||
thread_id thread = spawn_thread(test_thread, "test thread", B_NORMAL_PRIORITY, NULL);
|
||||
resume_thread(thread);
|
||||
snooze(5000000);
|
||||
|
||||
printf("close port...\n");
|
||||
s = close_port(id);
|
||||
printf("close port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
printf("waiting for thread to terminate\n");
|
||||
wait_for_thread(thread, &s);
|
||||
|
||||
return 0;
|
||||
}
|
62
src/tests/system/kernel/port_wakeup_test_9.cpp
Normal file
62
src/tests/system/kernel/port_wakeup_test_9.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2006, Marcus Overhagen, <marcus@overhagen.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* A full port can't be written to. Thus the write from thread should block, until main thread reads.
|
||||
*
|
||||
*/
|
||||
|
||||
port_id id;
|
||||
char data[100];
|
||||
|
||||
int32
|
||||
test_thread(void *)
|
||||
{
|
||||
ssize_t size;
|
||||
|
||||
printf("port_buffer_size...\n");
|
||||
size = port_buffer_size(id);
|
||||
printf("port_buffer_size size %ld (0x%08lx) (%s)\n", size, size, strerror(size));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
status_t s;
|
||||
ssize_t size;
|
||||
int32 code;
|
||||
|
||||
id = create_port(1, "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));
|
||||
|
||||
size = read_port(id, &code, data, sizeof(data));
|
||||
printf("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size));
|
||||
|
||||
printf("port_buffer_size should block for 5 seconds now, as port is empty, until port is deleted\n");
|
||||
|
||||
thread_id thread = spawn_thread(test_thread, "test thread", B_NORMAL_PRIORITY, NULL);
|
||||
resume_thread(thread);
|
||||
snooze(5000000);
|
||||
|
||||
printf("delete port...\n");
|
||||
s = delete_port(id);
|
||||
printf("delete port result 0x%08lx (%s)\n", s, strerror(s));
|
||||
|
||||
printf("waiting for thread to terminate\n");
|
||||
wait_for_thread(thread, &s);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user