예제 #1
0
void wi_test_error(void) {
    wi_string_t     *string;
    wi_boolean_t    result;
    
    result = wi_filesystem_file_exists_at_path(WI_STR("/non/existing/path"), NULL);
    
    WI_TEST_ASSERT_FALSE(result, "");
    WI_TEST_ASSERT_EQUALS(wi_error_domain(), WI_ERROR_DOMAIN_ERRNO, "");
    WI_TEST_ASSERT_EQUALS(wi_error_code(), ENOENT, "");
    WI_TEST_ASSERT_EQUAL_INSTANCES(wi_error_string(), WI_STR("No such file or directory"), "");
    
    string = wi_string_with_format(WI_STR("%m"));

    WI_TEST_ASSERT_EQUAL_INSTANCES(string, WI_STR("No such file or directory"), "");
}
예제 #2
0
void wi_test_fsevents(void) {
#ifdef WI_PTHREADS
	wi_string_t			*directory;
	
	wi_test_fsevents_fsevents = wi_fsevents_init(wi_fsevents_alloc());
	
	if(!wi_test_fsevents_fsevents) {
		if(wi_error_domain() != WI_ERROR_DOMAIN_LIBWIRED && wi_error_code() != WI_ERROR_FSEVENTS_NOTSUPP)
			WI_TEST_ASSERT_NOT_NULL(wi_test_fsevents_fsevents, "%m");
		
		return;
	}
	
	directory = wi_fs_temporary_path_with_template(WI_STR("/tmp/libwired-fsevents.XXXXXXXX"));
	
	wi_fs_create_directory(directory, 0700);
	
	wi_fsevents_add_path(wi_test_fsevents_fsevents, directory);
	wi_fsevents_set_callback(wi_test_fsevents_fsevents, wi_test_fsevents_callback);
	
	wi_test_fsevents_lock = wi_condition_lock_init_with_condition(wi_condition_lock_alloc(), 0);
	
	if(!wi_thread_create_thread(wi_test_fsevents_thread, NULL))
		WI_TEST_FAIL("%m");
	
	wi_thread_sleep(0.1);
	
	wi_string_write_to_file(WI_STR("foo"), wi_string_by_appending_path_component(directory, WI_STR("file")));
	
	wi_condition_lock_lock_when_condition(wi_test_fsevents_lock, 1, 0.0);
	
	if(!wi_test_fsevents_path)
		WI_TEST_FAIL("No fsevents callback received");
	else
		WI_TEST_ASSERT_EQUAL_INSTANCES(wi_test_fsevents_path, directory, "");
	
	wi_condition_lock_unlock(wi_test_fsevents_lock);

	wi_fs_delete_path(directory);
	
	wi_release(wi_test_fsevents_lock);
	wi_release(wi_test_fsevents_fsevents);
	wi_release(wi_test_fsevents_path);
#endif
}
예제 #3
0
파일: server.c 프로젝트: asvitkine/phxd
void wd_reply_error(void) {
	if(wi_error_domain() == WI_ERROR_DOMAIN_ERRNO)
		wd_reply_errno(wi_error_code());
	else
		wd_reply(500, WI_STR("Command Failed"));
}