PlatformParker() { int status; status = os::Solaris::cond_init(_cond); assert_status(status == 0, status, "cond_init"); status = os::Solaris::mutex_init(_mutex); assert_status(status == 0, status, "mutex_init"); }
PlatformParker() { int status; status = pthread_cond_init (_cond, NULL); assert_status(status == 0, status, "cond_init"); status = pthread_mutex_init (_mutex, NULL); assert_status(status == 0, status, "mutex_init"); }
PlatformParker() { int status; status = pthread_cond_init(&_cond[REL_INDEX], os::Linux::condAttr()); assert_status(status == 0, status, "cond_init rel"); status = pthread_cond_init(&_cond[ABS_INDEX], NULL); assert_status(status == 0, status, "cond_init abs"); status = pthread_mutex_init(_mutex, NULL); assert_status(status == 0, status, "mutex_init"); _cur_index = -1; // mark as unused }
PlatformEvent() { int status; status = os::Solaris::cond_init(_cond); assert_status(status == 0, status, "cond_init"); status = os::Solaris::mutex_init(_mutex); assert_status(status == 0, status, "mutex_init"); _Event = 0 ; _nParked = 0 ; _pipev[0] = _pipev[1] = -1 ; }
PlatformEvent() { int status; status = pthread_cond_init(_cond, os::Linux::condAttr()); assert_status(status == 0, status, "cond_init"); status = pthread_mutex_init(_mutex, NULL); assert_status(status == 0, status, "mutex_init"); _Event = 0; _nParked = 0; _Assoc = NULL; }
void test_stash_apply__with_default(void) { cl_git_pass(git_stash_apply(repo, 0, NULL)); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_WT_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_WT_MODIFIED); assert_status(repo, "when", GIT_STATUS_WT_NEW); }
void test_stash_save__can_keep_index(void) { cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_KEEP_INDEX)); assert_status("what", GIT_STATUS_INDEX_MODIFIED); assert_status("how", GIT_STATUS_INDEX_MODIFIED); assert_status("who", GIT_STATUS_CURRENT); assert_status("when", GIT_STATUS_WT_NEW); assert_status("just.ignore", GIT_STATUS_IGNORED); }
/* * test_events() uses poll(), select(), and kevent() to query the status of * fifo file descriptors and determine whether they match expected state * based on earlier semantic tests: specifically, whether or not poll/select/ * kevent will correctly inform on readable/writable state following I/O. * * It would be nice to also test status changes as a result of closing of one * or another fifo endpoint. */ static void test_events_outofbox(void) { int kqueue_fd, reader_fd, writer_fd; makefifo("testfifo", __func__); if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) { warn("test_events_outofbox: openfifo: testfifo"); cleanfifo2("testfifo", -1, -1); exit(-1); } kqueue_fd = kqueue(); if (kqueue_fd < 0) { warn("%s: kqueue", __func__); cleanfifo2("testfifo", reader_fd, writer_fd); exit(-1); } if (kqueue_setup(kqueue_fd, reader_fd, __func__) < 0) { cleanfifo3("testfifo", reader_fd, writer_fd, kqueue_fd); exit(-1); } if (kqueue_setup(kqueue_fd, writer_fd, __func__) < 0) { cleanfifo3("testfifo", reader_fd, writer_fd, kqueue_fd); exit(-1); } /* * Make sure that fresh, out-of-the-box fifo file descriptors have * good initial states. The reader_fd should have no active state, * since it will not be readable (no data in pipe), writable (it's * a read-only descriptor), and there's no reason for error yet. */ if (assert_status(reader_fd, kqueue_fd, NOT_READABLE, NOT_WRITABLE, NOT_EXCEPTION, __func__, "create", "reader_fd") < 0) { cleanfifo3("testfifo", reader_fd, writer_fd, kqueue_fd); exit(-1); } /* * Make sure that fresh, out-of-the-box fifo file descriptors have * good initial states. The writer_fd should be ready to write. */ if (assert_status(writer_fd, kqueue_fd, NOT_READABLE, WRITABLE, NOT_EXCEPTION, __func__, "create", "writer_fd") < 0) { cleanfifo3("testfifo", reader_fd, writer_fd, kqueue_fd); exit(-1); } cleanfifo3("testfifo", reader_fd, writer_fd, kqueue_fd); }
void test_stash_apply__conflict_workdir_with_default(void) { cl_git_rewritefile("stash/what", "ciao\n"); cl_git_fail_with(git_stash_apply(repo, 0, NULL), GIT_ECONFLICT); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_WT_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_CURRENT); assert_status(repo, "when", GIT_STATUS_WT_NEW); }
void test_stash_apply__conflict_untracked_with_default(void) { git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT; cl_git_mkfile("stash/when", "nothing\n"); cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_ECONFLICT); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_CURRENT); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_CURRENT); assert_status(repo, "when", GIT_STATUS_WT_NEW); }
void test_stash_apply__with_reinstate_index(void) { git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT; opts.flags = GIT_STASH_APPLY_REINSTATE_INDEX; cl_git_pass(git_stash_apply(repo, 0, &opts)); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_WT_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_INDEX_MODIFIED); assert_status(repo, "when", GIT_STATUS_WT_NEW); }
void test_stash_save__including_untracked_without_any_untracked_file_creates_an_empty_tree(void) { cl_git_pass(p_unlink("stash/when")); assert_status("what", GIT_STATUS_WT_MODIFIED | GIT_STATUS_INDEX_MODIFIED); assert_status("how", GIT_STATUS_INDEX_MODIFIED); assert_status("who", GIT_STATUS_WT_MODIFIED); assert_status("when", GIT_ENOTFOUND); assert_status("just.ignore", GIT_STATUS_IGNORED); cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); assert_object_oid("stash^3^{tree}", EMPTY_TREE, GIT_OBJ_TREE); }
void test_stash_apply__uses_reflog_like_indices_2(void) { git_oid oid; cl_git_mkfile("stash/untracked", "untracked\n"); cl_git_pass(git_stash_save(&oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); assert_status(repo, "untracked", GIT_ENOTFOUND); // stash@{0} is the newest stash we made immediately above cl_git_pass(git_stash_apply(repo, 0, NULL)); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "untracked", GIT_STATUS_WT_NEW); }
void test_stash_save__skip_submodules(void) { git_repository *untracked_repo; cl_git_pass(git_repository_init(&untracked_repo, "stash/untracked_repo", false)); cl_git_mkfile("stash/untracked_repo/content", "stuff"); git_repository_free(untracked_repo); assert_status(repo, "untracked_repo/", GIT_STATUS_WT_NEW); cl_git_pass(git_stash_save( &stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); assert_status(repo, "untracked_repo/", GIT_STATUS_WT_NEW); }
void test_stash_apply__fails_with_uncommitted_changes_in_index(void) { cl_git_rewritefile("stash/who", "nothing\n"); cl_git_pass(git_index_add_bypath(repo_index, "who")); cl_git_pass(git_index_write(repo_index)); cl_git_fail_with(git_stash_apply(repo, 0, NULL), GIT_EUNCOMMITTED); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_CURRENT); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_INDEX_MODIFIED); assert_status(repo, "when", GIT_ENOTFOUND); assert_status(repo, "why", GIT_ENOTFOUND); }
void test_stash_apply__conflict_workdir_with_reinstate_index(void) { git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT; opts.flags = GIT_STASH_APPLY_REINSTATE_INDEX; cl_git_rewritefile("stash/what", "ciao\n"); cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_ECONFLICT); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_WT_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_CURRENT); assert_status(repo, "when", GIT_STATUS_WT_NEW); }
// Initialization - create the door, locks, and other initialization int SolarisAttachListener::init() { if (create_door()) { return -1; } int status = os::Solaris::mutex_init(&_mutex); assert_status(status==0, status, "mutex_init"); status = ::sema_init(&_wakeup, 0, NULL, NULL); assert_status(status==0, status, "sema_init"); set_head(NULL); set_tail(NULL); return 0; }
void test_stash_save__ignored_directory(void) { cl_git_pass(p_mkdir("stash/ignored_directory", 0777)); cl_git_pass(p_mkdir("stash/ignored_directory/sub", 0777)); cl_git_mkfile("stash/ignored_directory/sub/some_file", "stuff"); assert_status(repo, "ignored_directory/sub/some_file", GIT_STATUS_WT_NEW); cl_git_pass(git_ignore_add_rule(repo, "ignored_directory/")); assert_status(repo, "ignored_directory/sub/some_file", GIT_STATUS_IGNORED); cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)); cl_assert(!git_path_exists("stash/ignored_directory/sub/some_file")); cl_assert(!git_path_exists("stash/ignored_directory/sub")); cl_assert(!git_path_exists("stash/ignored_directory")); }
void test_stash_apply__merges_new_file(void) { const git_index_entry *ancestor, *our, *their; cl_git_mkfile("stash/where", "committed before stash\n"); cl_git_pass(git_index_add_bypath(repo_index, "where")); cl_repo_commit_from_index(NULL, repo, signature, 0, "Other commit"); cl_git_pass(git_stash_apply(repo, 0, NULL)); cl_assert_equal_i(1, git_index_has_conflicts(repo_index)); assert_status(repo, "what", GIT_STATUS_INDEX_MODIFIED); cl_git_pass(git_index_conflict_get(&ancestor, &our, &their, repo_index, "where")); /* unmerged */ assert_status(repo, "who", GIT_STATUS_INDEX_MODIFIED); assert_status(repo, "when", GIT_STATUS_WT_NEW); assert_status(repo, "why", GIT_STATUS_INDEX_NEW); }
int main(int argc, char **argv) { char *user, *pass; pid_t pid; char *script = NULL; dico_set_program_name(argv[0]); while (--argc) { char *arg = *++argv; if (strncmp(arg, "-script=", 8) == 0) script = arg + 8; else if (strcmp(arg, "--") == 0) { --argc; ++argv; break; } else if (arg[0] == '-') { dico_log(L_ERR, 0, "unknown option %s", arg); return 1; } else break; } if (argc < 3) { dico_log(L_ERR, 0, "usage: %s user pass command [args...]", dico_program_name); return 1; } user = argv[0]; pass = argv[1]; argc -= 2; argv += 2; iostr = run_command(argc, argv, &pid); if (!iostr) return 1; dico_stream_set_buffer(iostr, dico_buffer_line, DICO_MAX_BUFFER); dict_read_reply(); assert_status("220"); get_msgid(); apop_auth(user, pass); if (script) { FILE *fp = fopen(script, "r"); if (!fp) { dico_log(L_ERR, errno, "cannot open %s", script); exit(1); } writer(fp); printer(); } return 0; }
void test_stash_apply__conflict_index_with_reinstate_index(void) { git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT; opts.flags = GIT_STASH_APPLY_REINSTATE_INDEX; cl_git_rewritefile("stash/who", "nothing\n"); cl_git_pass(git_index_add_bypath(repo_index, "who")); cl_git_pass(git_index_write(repo_index)); cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_ECONFLICT); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_CURRENT); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_INDEX_MODIFIED); assert_status(repo, "when", GIT_ENOTFOUND); }
void test_stash_apply__conflict_index_with_default(void) { const git_index_entry *ancestor; const git_index_entry *our; const git_index_entry *their; cl_git_rewritefile("stash/who", "nothing\n"); cl_git_pass(git_index_add_bypath(repo_index, "who")); cl_git_pass(git_index_write(repo_index)); cl_git_pass(git_stash_apply(repo, 0, NULL)); cl_assert_equal_i(git_index_has_conflicts(repo_index), 1); assert_status(repo, "what", GIT_STATUS_INDEX_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); cl_git_pass(git_index_conflict_get(&ancestor, &our, &their, repo_index, "who")); /* unmerged */ assert_status(repo, "when", GIT_STATUS_WT_NEW); }
void test_stash_apply__conflict_commit_with_reinstate_index(void) { git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT; const git_index_entry *ancestor; const git_index_entry *our; const git_index_entry *their; opts.flags = GIT_STASH_APPLY_REINSTATE_INDEX; cl_git_rewritefile("stash/what", "ciao\n"); cl_git_pass(git_index_add_bypath(repo_index, "what")); cl_repo_commit_from_index(NULL, repo, signature, 0, "Other commit"); cl_git_pass(git_stash_apply(repo, 0, &opts)); cl_assert_equal_i(git_index_has_conflicts(repo_index), 1); cl_git_pass(git_index_conflict_get(&ancestor, &our, &their, repo_index, "what")); /* unmerged */ assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_INDEX_MODIFIED); assert_status(repo, "when", GIT_STATUS_WT_NEW); }
void test_stash_apply__executes_notify_cb(void) { git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT; struct seen_paths seen_paths = {0}; opts.checkout_options.notify_cb = checkout_notify; opts.checkout_options.notify_flags = GIT_CHECKOUT_NOTIFY_ALL; opts.checkout_options.notify_payload = &seen_paths; cl_git_pass(git_stash_apply(repo, 0, &opts)); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_WT_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_WT_MODIFIED); assert_status(repo, "when", GIT_STATUS_WT_NEW); cl_assert_equal_b(true, seen_paths.what); cl_assert_equal_b(false, seen_paths.how); cl_assert_equal_b(true, seen_paths.who); cl_assert_equal_b(true, seen_paths.when); }
void test_stash_save__deleted_in_index_modified_in_workdir(void) { git_index *index; git_repository_index(&index, repo); cl_git_pass(git_index_remove_bypath(index, "who")); cl_git_pass(git_index_write(index)); assert_status(repo, "who", GIT_STATUS_WT_NEW | GIT_STATUS_INDEX_DELETED); cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_DEFAULT)); assert_blob_oid("stash@{0}^0:who", "a0400d4954659306a976567af43125a0b1aa8595"); assert_blob_oid("stash@{0}^2:who", NULL); git_index_free(index); }
void test_stash_apply__initialize(void) { git_oid oid; cl_git_pass(git_signature_new(&signature, "nulltoken", "*****@*****.**", 1323847743, 60)); /* Wed Dec 14 08:29:03 2011 +0100 */ cl_git_pass(git_repository_init(&repo, "stash", 0)); cl_git_pass(git_repository_index(&repo_index, repo)); cl_git_mkfile("stash/what", "hello\n"); cl_git_mkfile("stash/how", "small\n"); cl_git_mkfile("stash/who", "world\n"); cl_git_pass(git_index_add_bypath(repo_index, "what")); cl_git_pass(git_index_add_bypath(repo_index, "how")); cl_git_pass(git_index_add_bypath(repo_index, "who")); cl_repo_commit_from_index(NULL, repo, signature, 0, "Initial commit"); cl_git_rewritefile("stash/what", "goodbye\n"); cl_git_rewritefile("stash/who", "funky world\n"); cl_git_mkfile("stash/when", "tomorrow\n"); cl_git_pass(git_index_add_bypath(repo_index, "who")); /* Pre-stash state */ assert_status(repo, "what", GIT_STATUS_WT_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_INDEX_MODIFIED); assert_status(repo, "when", GIT_STATUS_WT_NEW); cl_git_pass(git_stash_save(&oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); /* Post-stash state */ assert_status(repo, "what", GIT_STATUS_CURRENT); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_CURRENT); assert_status(repo, "when", GIT_ENOTFOUND); git_index_free(repo_index); }
void test_stash_apply__uses_reflog_like_indices_1(void) { git_oid oid; cl_git_mkfile("stash/untracked", "untracked\n"); cl_git_pass(git_stash_save(&oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); assert_status(repo, "untracked", GIT_ENOTFOUND); // stash@{1} is the oldest (first) stash we made cl_git_pass(git_stash_apply(repo, 1, NULL)); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_WT_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_WT_MODIFIED); assert_status(repo, "when", GIT_STATUS_WT_NEW); assert_status(repo, "why", GIT_STATUS_INDEX_NEW); assert_status(repo, "where", GIT_STATUS_INDEX_NEW); }
static void apop_auth(const char *user, const char *pass) { int i; struct md5_ctx md5context; unsigned char md5digest[16]; char buf[sizeof(md5digest) * 2 + 1]; char *p; md5_init_ctx(&md5context); md5_process_bytes(msgid, strlen(msgid), &md5context); md5_process_bytes(pass, strlen(pass), &md5context); md5_finish_ctx(&md5context, md5digest); for (i = 0, p = buf; i < 16; i++, p += 2) sprintf(p, "%02x", md5digest[i]); *p = 0; stream_printf(iostr, "AUTH %s %s\r\n", user, buf); dict_read_reply(); assert_status("230"); }
void test_stash_apply__with_default(void) { git_buf where = GIT_BUF_INIT; cl_git_pass(git_stash_apply(repo, 0, NULL)); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_WT_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_WT_MODIFIED); assert_status(repo, "when", GIT_STATUS_WT_NEW); assert_status(repo, "why", GIT_STATUS_INDEX_NEW); assert_status(repo, "where", GIT_STATUS_INDEX_NEW); cl_git_pass(git_futils_readbuffer(&where, "stash/where")); cl_assert_equal_s("....\n", where.ptr); git_buf_free(&where); }
void test_stash_apply__with_reinstate_index(void) { git_buf where = GIT_BUF_INIT; git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT; opts.flags = GIT_STASH_APPLY_REINSTATE_INDEX; cl_git_pass(git_stash_apply(repo, 0, &opts)); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_WT_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_INDEX_MODIFIED); assert_status(repo, "when", GIT_STATUS_WT_NEW); assert_status(repo, "why", GIT_STATUS_INDEX_NEW); assert_status(repo, "where", GIT_STATUS_INDEX_NEW | GIT_STATUS_WT_MODIFIED); cl_git_pass(git_futils_readbuffer(&where, "stash/where")); cl_assert_equal_s("....\n", where.ptr); git_buf_free(&where); }