rem: thread_wait_on_thread(t, NULL);
add: wait_for_thread(t, NULL);
context: port_test(){	char testdata[5];	thread_id t;	int res;	int32 dummy;	int32 dummy2;	strcpy(testdata, "abcd");	dprintf("porttest: create_port()\n");	test_p1 = create_port(1,    "test port #1");	test_p2 = create_port(10,   "test port #2");	test_p3 = create_port(1024, "test port #3");	test_p4 = create_port(1024, "test port #4");	dprintf("porttest: find_port()\n");	dprintf("'test port #1' has id %ld (should be %ld)\n", find_port("test port #1"), test_p1);	dprintf("porttest: write_port() on 1, 2 and 3\n");	write_port(test_p1, 1, &testdata, sizeof(testdata));	write_port(test_p2, 666, &testdata, sizeof(testdata));	write_port(test_p3, 999, &testdata, sizeof(testdata));	dprintf("porttest: port_count(test_p1) = %ld\n", port_count(test_p1));	dprintf("porttest: write_port() on 1 with timeout of 1 sec (blocks 1 sec)\n");	write_port_etc(test_p1, 1, &testdata, sizeof(testdata), B_TIMEOUT, 1000000);	dprintf("porttest: write_port() on 2 with timeout of 1 sec (wont block)\n");	res = write_port_etc(test_p2, 777, &testdata, sizeof(testdata), B_TIMEOUT, 1000000);	dprintf("porttest: res=%d, %s\n", res, res == 0 ? "ok" : "BAD");	dprintf("porttest: read_port() on empty port 4 with timeout of 1 sec (blocks 1 sec)\n");	res = read_port_etc(test_p4, &dummy, &dummy2, sizeof(dummy2), B_TIMEOUT, 1000000);	dprintf("porttest: res=%d, %s\n", res, res == B_TIMED_OUT ? "ok" : "BAD");	dprintf("porttest: spawning thread for port 1\n");	t = spawn_kernel_thread(port_test_thread_func, "port_test", B_NORMAL_PRIORITY, NULL);	resume_thread(t);	dprintf("porttest: write\n");	write_port(test_p1, 1, &testdata, sizeof(testdata));	// now we can write more (no blocking)	dprintf("porttest: write #2\n");	write_port(test_p1, 2, &testdata, sizeof(testdata));	dprintf("porttest: write #3\n");	write_port(test_p1, 3, &testdata, sizeof(testdata));	dprintf("porttest: waiting on spawned thread\n");	thread_wait_on_thread(t, NULL);	dprintf("porttest: close p1\n");	close_port(test_p2);	dprintf("porttest: attempt write p1 after close\n");	res = write_port(test_p2, 4, &testdata, sizeof(testdata));	dprintf("porttest: write_port ret %d\n", res);	dprintf("porttest: testing delete p2\n");	delete_port(test_p2);	dprintf("porttest: end test main thread\n");	}