int do_test_userland(const char *test_parm) { (void) test_parm; char testdata[5]; int res; int32_t code; strcpy(testdata, "abcd"); SHOW_INFO0( 0, "port_create()"); uland_port = port_create(1, "__regress_test_port"); test_check_ge(uland_port,0); SHOW_INFO0( 0, "port_write()"); res = port_write(uland_port, 1, &testdata, sizeof(testdata)); test_check_eq(res,0); testdata[0] = 0; SHOW_INFO0( 0, "port_read()"); res = port_read_etc(uland_port, &code, &testdata, sizeof(testdata), PORT_FLAG_TIMEOUT, 1000000); test_check_eq(res,5); test_check_eq(code,0xAA); test_check_eq( strcmp(testdata, "abcd"), 0); SHOW_INFO0( 0, "port_read() - wait for userland to finish"); res = port_read_etc(uland_port, &code, &testdata, sizeof(testdata), PORT_FLAG_TIMEOUT, 1000000); test_check_ge(res,0); test_check_eq(code,0x55); SHOW_INFO0( 0, "close port"); res = port_close(uland_port); test_check_ne(res,0); #if 0 SHOW_INFO0( 0, "delete port"); res = port_delete(test_p2); test_check_eq(res,0); #endif SHOW_INFO0( 0, "end test"); return 0; }
int do_test_misc(const char *test_parm) { (void) test_parm; char buf[BSIZE]; int rc; test_check_eq(getpagesize(),4096); test_check_eq(personality(0xffffffff), 0); { struct utsname phantom_uname; test_check_eq(uname(&phantom_uname), 0); printf("uland: uname sys '%s'\n\tnode %s\n\trel %s\n\tver %s\n\tmachine %s\n\tdomain %s\n", phantom_uname.sysname, phantom_uname.nodename, phantom_uname.release, phantom_uname.version, phantom_uname.machine, phantom_uname.domainname ); } rc = gethostname(buf, BSIZE); test_check_ge(rc,0); printf("uland: hostname %s\n", buf ); return 0; }
int do_test_timed_call(const char *test_parm) { (void) test_parm; printf("Testing timed call undo, must be no echoes:\n"); called = 0; phantom_request_timed_call( &t2, 0 ); phantom_undo_timed_call(&t2); hal_sleep_msec(200); // Twice the time test_check_eq(called, 0); #if DUMPQ //dump_timed_call_queue(); #endif called = 0; printf("Testing timed calls, wait for echoes:\n"); phantom_request_timed_call( &t1, 0 ); //test_check_false(called); // it is still possible for this test to fail with correct code! phantom_request_timed_call( &t2, 0 ); #if DUMPQ //dump_timed_call_queue(); #endif phantom_request_timed_call( &t3, 0 ); phantom_request_timed_call( &t4, 0 ); //TIMEDCALL_FLAG_AUTOFREE requires call to free from interrupt :( //phantom_request_timed_func( echo, msg, 5000, 0 ); phantom_request_timed_call( &t5, 0 ); #if DUMPQ dump_timed_call_queue(); #endif // We check for >= (ge) because hal_sleep... can cleep for more than asked, and timed // calls are usually quite on time hal_sleep_msec(6); test_check_ge(called, 1); hal_sleep_msec(200); // Have lag of 106 msec, OK? test_check_ge(called, 2); hal_sleep_msec(2000-100); // Still have lag of 106 msec test_check_ge(called, 3); hal_sleep_msec(5000-2000); // Have lag of 206 msec test_check_ge(called, 4); hal_sleep_msec(2500+10000-5000-2000); // Strange - need quite big lag here... test_check_ge(called, 5); printf("Done testing timed calls\n"); return 0; }