static void test_init_twice() { assert_true( init_messenger( "/tmp" ) ); assert_true( init_messenger( "/tmp" ) ); finalize_messenger(); }
static void test_finalize_twice() { init_messenger( "/tmp" ); assert_true( finalize_messenger() ); assert_false( finalize_messenger() ); }
void init_chibach( int *argc, char ***argv ) { assert( argc != NULL ); assert( argv != NULL ); chibach_log = NULL; initialized = false; chibach_started = false; run_as_daemon = false; chibach_name = xstrdup( basename( *argv[ 0 ] ) ); parse_argv( argc, argv ); set_chibach_home(); set_chibach_tmp(); check_chibach_tmp(); if ( run_as_daemon ) { init_log( get_chibach_name(), get_chibach_log(), LOGGING_TYPE_FILE ); } else { init_log( get_chibach_name(), get_chibach_log(), LOGGING_TYPE_FILE | LOGGING_TYPE_STDOUT ); } ignore_sigpipe(); set_exit_handler(); set_usr1_handler(); init_stat(); init_timer(); init_messenger( get_chibach_tmp() ); if ( datapath_id != 0 ) { init_openflow_switch_interface( datapath_id, controller.ip, controller.port ); } initialized = true; }
static void test_send_then_message_requested_and_replied_callback_is_called() { init_messenger( "/tmp" ); const char service_name[] = "Say HELLO"; expect_value( callback_req_hello, tag, 43556 ); expect_string( callback_req_hello, data, "HELLO" ); expect_value( callback_req_hello, len, 6 ); add_message_requested_callback( service_name, callback_req_hello ); expect_value( callback_rep_hello_end, tag, 65534 ); expect_string( callback_rep_hello_end, data, "OLLEH" ); expect_value( callback_rep_hello_end, len, 6 ); expect_value( callback_rep_hello_end, user_data, NULL ); add_message_replied_callback( service_name, callback_rep_hello_end ); send_request_message( service_name, service_name, 43556, "HELLO", strlen( "HELLO" ) + 1, NULL ); start_messenger(); start_event_handler(); delete_message_replied_callback( service_name, callback_rep_hello_end ); delete_message_requested_callback( service_name, callback_req_hello ); delete_send_queue( lookup_hash_entry( send_queues, service_name ) ); finalize_messenger(); }
static void test_add_1_message_requested_and_replied_callback_each_prints_no_error_message() { init_messenger( "/tmp" ); const char service_name[] = "Some Service"; check_warn = true; assert_true( add_message_requested_callback( service_name, callback_req_hello ) ); assert_true( add_message_replied_callback( service_name, callback_rep_hello_end ) ); check_warn = false; finalize_messenger(); }
static void test_send_then_message_received_callback_is_called() { init_messenger( "/tmp" ); will_return_count( mock_clock_gettime, 0, -1 ); const char service_name[] = "Say HELLO"; expect_value( callback_hello, tag, 43556 ); expect_string( callback_hello, data, "HELLO" ); expect_value( callback_hello, len, 6 ); add_message_received_callback( service_name, callback_hello ); send_message( service_name, 43556, "HELLO", strlen( "HELLO" ) + 1 ); start_messenger(); delete_message_received_callback( service_name, callback_hello ); delete_send_queue( lookup_hash_entry( send_queues, service_name ) ); finalize_messenger(); }
static void test_double_add_message_replied_callback_prints_error_message() { init_messenger( "/tmp" ); const char service_name[] = "Some Service"; char expected_mes[ 1024+1 ] = {}; snprintf( expected_mes, 1024, "Multiple message_requested/replied handler is not supported. ( service_name = %s, message_type = %#x, callback = %p )", service_name, MESSAGE_TYPE_REPLY, callback_rep_hello2 ); check_warn = true; assert_true( add_message_replied_callback( service_name, callback_rep_hello_end ) ); expect_string( mock_warn_check, message, expected_mes ); assert_true( add_message_replied_callback( service_name, callback_rep_hello2 ) ); check_warn = false; finalize_messenger(); }
static void test_init_and_finalize() { assert_true( init_messenger( "/tmp" ) ); assert_true( finalize_messenger() ); }
int main(int argc,char **argv) { INFO(char *dbg="Main(init): "); native_startup(argc, argv); /*** init modules ***/ INFO(printf("%sSharedMemory\n",dbg)); init_sharedmem(&dope); INFO(printf("%sTimer\n",dbg)); init_timer(&dope); INFO(printf("%sTick\n",dbg)); init_tick(&dope); INFO(printf("%sRelax\n",dbg)); init_relax(&dope); INFO(printf("%sKeymap\n",dbg)); init_keymap(&dope); INFO(printf("%sThread\n",dbg)); init_thread(&dope); INFO(printf("%sCache\n",dbg)); init_cache(&dope); INFO(printf("%sHashTable\n",dbg)); init_hashtable(&dope); INFO(printf("%sApplication Manager\n",dbg)); init_appman(&dope); INFO(printf("%sTokenizer\n",dbg)); init_tokenizer(&dope); INFO(printf("%sMessenger\n",dbg)); init_messenger(&dope); INFO(printf("%sScript\n",dbg)); init_script(&dope); INFO(printf("%sClipping\n",dbg)); init_clipping(&dope); INFO(printf("%sScreen Driver\n",dbg)); init_scrdrv(&dope); INFO(printf("%sInput\n",dbg)); init_input(&dope); INFO(printf("%sViewManager\n",dbg)); init_viewman(&dope); INFO(printf("%sConvertFNT\n",dbg)); init_conv_fnt(&dope); INFO(printf("%sFontManager\n",dbg)); init_fontman(&dope); INFO(printf("%sGfxScreen16\n",dbg)); init_gfxscr16(&dope); INFO(printf("%sGfxImage16\n",dbg)); init_gfximg16(&dope); INFO(printf("%sGfxImage32\n",dbg)); init_gfximg32(&dope); INFO(printf("%sGfxImageYUV420\n",dbg)); init_gfximgyuv420(&dope); INFO(printf("%sGfx\n",dbg)); init_gfx(&dope); INFO(printf("%sRedrawManager\n",dbg)); init_redraw(&dope); INFO(printf("%sUserState\n",dbg)); init_userstate(&dope); INFO(printf("%sWidgetManager\n",dbg)); init_widman(&dope); INFO(printf("%sScope\n",dbg)); init_scope(&dope); INFO(printf("%sButton\n",dbg)); init_button(&dope); INFO(printf("%sEntry\n",dbg)); init_entry(&dope); INFO(printf("%sVariable\n",dbg)); init_variable(&dope); INFO(printf("%sLabel\n",dbg)); init_label(&dope); INFO(printf("%sLoadDisplay\n",dbg)); init_loaddisplay(&dope); INFO(printf("%sBackground\n",dbg)); init_background(&dope); INFO(printf("%sScrollbar\n",dbg)); init_scrollbar(&dope); INFO(printf("%sScale\n",dbg)); init_scale(&dope); INFO(printf("%sFrame\n",dbg)); init_frame(&dope); INFO(printf("%sContainer\n",dbg)); init_container(&dope); INFO(printf("%sGrid\n",dbg)); init_grid(&dope); INFO(printf("%sWinLayout\n",dbg)); init_winlayout(&dope); INFO(printf("%sWindow\n",dbg)); init_window(&dope); INFO(printf("%sScreen\n",dbg)); init_screen(&dope); INFO(printf("%sScheduler\n",dbg)); if (config_don_scheduler) { // init_don_scheduler(&dope); printf("NOOOOOOOOOOOOOOOOOOO\n"); } else init_simple_scheduler(&dope); INFO(printf("%sVScreenServer\n",dbg)); init_vscr_server(&dope); INFO(printf("%sVScreen\n",dbg)); init_vscreen(&dope); INFO(printf("%sVTextScreen\n",dbg)); init_vtextscreen(&dope); INFO(printf("%sServer\n",dbg)); init_server(&dope); INFO(printf("%screate screen\n",dbg)); { static GFX_CONTAINER *scr_ds; gfx = pool_get("Gfx 1.0"); screen = pool_get("Screen 1.0"); userstate = pool_get("UserState 1.0"); scr_ds = gfx->alloc_scr("default"); curr_scr = screen->create(); curr_scr->scr->set_gfx(curr_scr, scr_ds); userstate->set_max_mx(gfx->get_width(scr_ds)); userstate->set_max_my(gfx->get_height(scr_ds)); } INFO(printf("%sstarting server\n",dbg)); if ((server = pool_get("Server 1.0"))) server->start(); INFO(printf("%sstarting scheduler\n",dbg)); if ((sched = pool_get("Scheduler 1.0"))) sched->process_mainloop(); return 0; }