예제 #1
0
파일: shell_test.c 프로젝트: ryochack/emkit
TEST(shell, start)
{
	char test_chars[] = {
		'0', '1', '2', '3', '4', '5', '6', '7',
		'8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
		'\n', 0
	};
	char *p = test_chars;

	s_handle = shell_create(s_pool, POOL_SIZE,
			stub_putc, stub_getc, stub_exec, NULL);
	TEST_ASSERT_NOT_NULL( s_handle );
	TEST_ASSERT_UNLESS( shell_set_prompt(s_handle, "") );

	pthread_create(&s_thread, NULL, thread_shell, NULL);

	while (*p) {
		while (s_txc);
		s_txc = *p++;
	}

	pthread_mutex_lock(&s_mutex);
	pthread_cond_wait(&s_cv, &s_mutex);
	pthread_mutex_unlock(&s_mutex);

	TEST_ASSERT_EQUAL_STRING_LEN(test_chars, s_rxbuf, strlen(test_chars));
	/* excludes new line code */
	TEST_ASSERT_EQUAL_STRING_LEN(test_chars, s_result_line, strlen(test_chars) - 1);

	TEST_ASSERT_UNLESS( shell_destroy(s_handle) );
	s_txc = '\n';

	pthread_join(s_thread, NULL);
}
예제 #2
0
파일: shell_test.c 프로젝트: ryochack/emkit
TEST(shell, hook)
{
	char test_chars[] = {
		'a', '\n', 0
	};
	char *p;

	// OK hook
	s_error = 1;
	p = test_chars;
	s_handle = shell_create(s_pool, POOL_SIZE,
			stub_putc, stub_getc, stub_exec_ok, stub_post_hook);
	TEST_ASSERT_NOT_NULL( s_handle );
	pthread_create(&s_thread, NULL, thread_shell, NULL);
	while (*p) {
		while (s_txc);
		s_txc = *p++;
	}

	pthread_mutex_lock(&s_mutex);
	pthread_cond_wait(&s_cv, &s_mutex);
	pthread_mutex_unlock(&s_mutex);
	TEST_ASSERT_EQUAL_INT32( 0, s_error );
	TEST_ASSERT_UNLESS( shell_destroy(s_handle) );
	s_txc = '\n';
	pthread_join(s_thread, NULL);


	// NG hook
	s_error = 0;
	p = test_chars;
	s_handle = shell_create(s_pool, POOL_SIZE,
			stub_putc, stub_getc, stub_exec_ng, stub_post_hook);
	TEST_ASSERT_NOT_NULL( s_handle );
	pthread_create(&s_thread, NULL, thread_shell, NULL);
	while (*p) {
		while (s_txc);
		s_txc = *p++;
	}
	pthread_mutex_lock(&s_mutex);
	pthread_cond_wait(&s_cv, &s_mutex);
	pthread_mutex_unlock(&s_mutex);
	TEST_ASSERT_EQUAL_INT32( -1, s_error );
	TEST_ASSERT_UNLESS( shell_destroy(s_handle) );
	s_txc = '\n';
	pthread_join(s_thread, NULL);
}
예제 #3
0
파일: shell_test.c 프로젝트: ryochack/emkit
TEST(shell, destroy)
{
	s_handle = shell_create(s_pool, POOL_SIZE,
			stub_putc, stub_getc, stub_exec, NULL);
	TEST_ASSERT_NOT_NULL( s_handle );
	TEST_ASSERT_UNLESS( shell_destroy(s_handle) );
	TEST_ASSERT( shell_start(s_handle) );
}
예제 #4
0
파일: shell_test.c 프로젝트: ryochack/emkit
TEST(shell, set_prompt)
{
	s_handle = shell_create(s_pool, POOL_SIZE,
			stub_putc, stub_getc, stub_exec, NULL);
	TEST_ASSERT_NOT_NULL( s_handle );
	TEST_ASSERT( shell_set_prompt(s_handle, NULL) );
	TEST_ASSERT_UNLESS( shell_set_prompt(s_handle, "hoge") );
	TEST_ASSERT_UNLESS( shell_set_prompt(s_handle, "") );
}
예제 #5
0
KPROXY_API f8_bool kproxy_init(int leakDetect)
{
	ITcpAdapter *a;	

	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	_CrtSetBreakAlloc(leakDetect);
	
	/* initialize and start kernel */
	ex_init();
	
	/* KERN_F_ENABLE_INPUT */

	x_buffer = (char *)__malloc__(LARGE_BUF_SIZE);
	x_buf_len = LARGE_BUF_SIZE;
	b_ShellExit = __false;	

	__new__(ITcpAdapter, a);
	proxy_adapter = __ucast__(ITcpAdapter, IKAdapter, a);

	sections = ke_get_blk(proxy_adapter->kernel, 0);
	assert(sections->uuid == BLK_ID_ROOT);

	create_resource(&sections->uuid);
	create_f8_uuid(&sections->h.uuid);
	create_resource(&sections->h.uuid);

	memset(fileName, 0 , sizeof(fileName));

	g_shell = shell_create(commands);
	
	reset_reg_map();
	init_blklib();
	init_clipboard();

	g_bDirty = __false;


	init_network(RTK_INIT_AS_SERVER, 0);
	vbus = connect_vbus(0xf8, VBUS_CONNECT_AS_SERVER, sr, 0);
	
	return __true;
}
예제 #6
0
파일: shell_app.c 프로젝트: ryochack/emkit
int main(int argc, char **argv) {
	handle_t sh_hdl;

	command_init(myputc);
	sh_hdl = shell_create(shell_work_memory, sizeof(shell_work_memory),
			myputc, mygetc, myexecute, myhook);
	if (!sh_hdl) {
		fprintf(stderr, "Shell Handle is NULL!\n");
		return -1;
	}
	cmd_hdl = command_create(command_work_memory, sizeof(command_work_memory));
	if (!cmd_hdl) {
		fprintf(stderr, "Command Handle is NULL!\n");
		return -1;
	}

	command_add(cmd_hdl, "hello", cmd_hello, NULL);
	command_add(cmd_hdl, "goodbye", cmd_goodbye, NULL);

	shell_start(sh_hdl);

	return 0;
}
예제 #7
0
__bool init_server_shell(void)
{
	g_shell	= shell_create(_valid_cmds);
	return __true;
}
예제 #8
0
파일: shell_test.c 프로젝트: ryochack/emkit
TEST(shell, create)
{
	s_handle = shell_create(s_pool, POOL_SIZE,
			stub_putc, stub_getc, stub_exec, NULL);
	TEST_ASSERT_NOT_NULL( s_handle );
}