void test_searpc__initialize (void) { searpc_server_init (register_marshals); searpc_create_service ("test"); searpc_server_register_function ("test", get_substring, "get_substring", searpc_signature_string__string_int()); searpc_server_register_function ("test", get_maman_bar, "get_maman_bar", searpc_signature_object__string()); searpc_server_register_function ("test", get_maman_bar_list, "get_maman_bar_list", searpc_signature_objlist__string_int()); searpc_server_register_function ("test", simple_json_rpc, "simple_json_rpc", searpc_signature_json__string_int()); searpc_server_register_function ("test", count_json_kvs, "count_json_kvs", searpc_signature_json__json()); /* sample client */ client = searpc_client_new(); client->send = sample_send; client->arg = "test"; client->async_send = sample_async_send; client->async_arg = "test_async"; SearpcNamedPipeServer *pipe_server = searpc_create_named_pipe_server(pipe_path); cl_must_pass_(searpc_named_pipe_server_start(pipe_server), "named pipe server failed to start"); #if defined(WIN32) // Wait for the server thread to start Sleep(1000); #endif client_with_pipe_transport = do_create_client_with_pipe_transport(); }
static SearpcClient * do_create_client_with_pipe_transport() { SearpcNamedPipeClient *pipe_client = searpc_create_named_pipe_client(pipe_path); cl_must_pass_(searpc_named_pipe_client_connect(pipe_client), "named pipe client failed to connect"); return searpc_client_with_named_pipe_transport(pipe_client, "test"); }
static void fs_copy(const char *_source, const char *dest) { char *argv[5]; char *source; size_t source_len; source = strdup(_source); source_len = strlen(source); if (source[source_len - 1] == '/') source[source_len - 1] = 0; argv[0] = "/bin/cp"; argv[1] = "-R"; argv[2] = source; argv[3] = (char *)dest; argv[4] = NULL; cl_must_pass_( shell_out(argv), "Failed to copy test fixtures to sandbox" ); free(source); }
static void fs_rm(const char *source) { char *argv[4]; argv[0] = "/bin/rm"; argv[1] = "-Rf"; argv[2] = (char *)source; argv[3] = NULL; cl_must_pass_( shell_out(argv), "Failed to cleanup the sandbox" ); }
void test_attr_repo__get_one(void) { const char *value; struct { const char *file; const char *attr; const char *expected; } test_cases[] = { { "root_test1", "repoattr", GIT_ATTR_TRUE }, { "root_test1", "rootattr", GIT_ATTR_TRUE }, { "root_test1", "missingattr", NULL }, { "root_test1", "subattr", NULL }, { "root_test1", "negattr", NULL }, { "root_test2", "repoattr", GIT_ATTR_TRUE }, { "root_test2", "rootattr", GIT_ATTR_FALSE }, { "root_test2", "missingattr", NULL }, { "root_test2", "multiattr", GIT_ATTR_FALSE }, { "root_test3", "repoattr", GIT_ATTR_TRUE }, { "root_test3", "rootattr", NULL }, { "root_test3", "multiattr", "3" }, { "root_test3", "multi2", NULL }, { "sub/subdir_test1", "repoattr", GIT_ATTR_TRUE }, { "sub/subdir_test1", "rootattr", GIT_ATTR_TRUE }, { "sub/subdir_test1", "missingattr", NULL }, { "sub/subdir_test1", "subattr", "yes" }, { "sub/subdir_test1", "negattr", GIT_ATTR_FALSE }, { "sub/subdir_test1", "another", NULL }, { "sub/subdir_test2.txt", "repoattr", GIT_ATTR_TRUE }, { "sub/subdir_test2.txt", "rootattr", GIT_ATTR_TRUE }, { "sub/subdir_test2.txt", "missingattr", NULL }, { "sub/subdir_test2.txt", "subattr", "yes" }, { "sub/subdir_test2.txt", "negattr", GIT_ATTR_FALSE }, { "sub/subdir_test2.txt", "another", "zero" }, { "sub/subdir_test2.txt", "reposub", GIT_ATTR_TRUE }, { "sub/sub/subdir.txt", "another", "one" }, { "sub/sub/subdir.txt", "reposubsub", GIT_ATTR_TRUE }, { "sub/sub/subdir.txt", "reposub", NULL }, { "does-not-exist", "foo", "yes" }, { "sub/deep/file", "deepdeep", GIT_ATTR_TRUE }, { NULL, NULL, NULL } }, *scan; for (scan = test_cases; scan->file != NULL; scan++) { git_buf b = GIT_BUF_INIT; git_buf_printf(&b, "%s:%s == expect %s", scan->file, scan->attr, scan->expected); cl_must_pass_( git_attr_get(g_repo, scan->file, scan->attr, &value) == GIT_SUCCESS, b.ptr); git_buf_printf(&b, ", got %s", value); if (scan->expected == NULL || scan->expected == GIT_ATTR_TRUE || scan->expected == GIT_ATTR_FALSE) { cl_assert_(scan->expected == value, b.ptr); } else { cl_assert_strequal(scan->expected, value); } git_buf_free(&b); } cl_git_pass(git_attr_cache__is_cached(g_repo, ".git/info/attributes")); cl_git_pass(git_attr_cache__is_cached(g_repo, ".gitattributes")); cl_git_pass(git_attr_cache__is_cached(g_repo, "sub/.gitattributes")); }