END_TEST START_TEST(test_git_update_new) { DESCRIBE_TEST; const char *url = "git://github.com/redjack/git-repo.git"; const char *commit = "master"; struct cork_path *work_tree = cork_path_new("/test/git-repo"); struct cork_path *git_dir = cork_path_new("/test/git-repo/.git"); bz_start_mocks(); bz_mock_file_exists("/test/git-repo", false); bz_mock_subprocess ("git clone --recursive --branch master " "git://github.com/redjack/git-repo.git /test/git-repo", NULL, NULL, 0); fail_if_error(bz_git_update(url, commit, git_dir, work_tree)); test_actions( "[1] Clone git://github.com/redjack/git-repo.git (master)\n" ); verify_commands_run( "$ [ -f /test/git-repo ]\n" "$ mkdir -p /test\n" "$ git clone --recursive --branch master " "git://github.com/redjack/git-repo.git /test/git-repo\n" ); }
static void test(void) { rtems_status_code sc; dev_t dev = 0; rtems_disk_device *dd; sc = rtems_disk_io_initialize(); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_disk_create_phys( dev, 1, BLOCK_COUNT, test_disk_ioctl, NULL, NULL ); rtems_test_assert(sc == RTEMS_SUCCESSFUL); dd = rtems_disk_obtain(dev); rtems_test_assert(dd != NULL); test_actions(dd); sc = rtems_disk_release(dd); rtems_test_assert(sc == RTEMS_SUCCESSFUL); sc = rtems_disk_delete(dev); rtems_test_assert(sc == RTEMS_SUCCESSFUL); }
int get_event_set(char *event_set, int wait) { int len; char link_path[BUF_SIZE]; char file_path[BUF_SIZE]; desc common_desc; common_desc = init_env(inot_dir, file_path, link_path); if ((common_desc.inot < 0) || (common_desc.file < 0) || \ (common_desc.dir < 0) || (common_desc.link < 0)) { common_close(&common_desc); return -1; } if(test_actions(inot_dir, file_path, link_path) < 0) { common_close(&common_desc); return -1; } if (wait) { do_wait(); } len = read_set(common_desc.inot, event_set); common_close(&common_desc); #ifdef NODEL if (! (fDelete(file_path) == 0 && fDelete(link_path) == 0 && fRemDir(inot_dir) == 0)) return -1; #endif return len; }
END_TEST START_TEST(test_git_update) { DESCRIBE_TEST; const char *url = "git://github.com/redjack/git-repo.git"; const char *commit = "master"; struct cork_path *work_tree = cork_path_new("/test/git-repo"); struct cork_path *git_dir = cork_path_new("/test/git-repo/.git"); bz_start_mocks(); bz_mock_file_exists("/test/git-repo", true); bz_mock_subprocess ("git --git-dir /test/git-repo/.git --work-tree /test/git-repo " "fetch origin", NULL, NULL, 0); bz_mock_subprocess ("git --git-dir /test/git-repo/.git --work-tree /test/git-repo " "reset --hard origin/master", NULL, NULL, 0); fail_if_error(bz_git_update(url, commit, git_dir, work_tree)); test_actions( "[1] Update git://github.com/redjack/git-repo.git (master)\n" ); verify_commands_run( "$ [ -f /test/git-repo ]\n" "$ git --git-dir /test/git-repo/.git --work-tree /test/git-repo " "fetch origin\n" "$ git --git-dir /test/git-repo/.git --work-tree /test/git-repo " "reset --hard origin/master\n" ); }
END_TEST START_TEST(test_git_clone_unneeded) { DESCRIBE_TEST; const char *url = "git://github.com/redjack/git-repo.git"; const char *commit = "master"; struct cork_path *path = cork_path_new("/test/git-repo"); bz_start_mocks(); bz_mock_file_exists("/test/git-repo", true); fail_if_error(bz_git_clone(url, commit, path)); test_actions("Nothing to do!\n"); verify_commands_run( "$ [ -f /test/git-repo ]\n" ); }
static void test_stage_package(struct bz_env *env, bool force, const char *expected_actions) { struct cork_path *source_dir = cork_path_new("/home/test/source"); struct bz_pdb *pdb; struct bz_builder *builder; fail_if_error(pdb = bz_arch_native_pdb()); bz_pdb_register(pdb); bz_mock_file_exists(cork_path_get(source_dir), true); bz_env_add_override(env, "source_dir", bz_path_value_new(source_dir)); bz_env_add_override(env, "force", bz_string_value_new(force? "1": "0")); bz_env_add_override(env, "verbose", bz_string_value_new("0")); fail_if_error(builder = bz_cmake_builder_new(env)); fail_if_error(bz_builder_stage(builder)); test_actions(expected_actions); bz_builder_free(builder); }
static void test_create_package(struct bz_env *env, bool force, const char *expected_actions) { struct cork_path *binary_package_dir = cork_path_new("."); struct cork_path *staging_dir = cork_path_new("/tmp/staging"); struct bz_pdb *pdb; struct bz_packager *packager; fail_if_error(pdb = bz_apt_native_pdb()); bz_pdb_register(pdb); mock_deb_arch("amd64"); bz_mock_file_exists(cork_path_get(staging_dir), true); bz_env_add_override(env, "binary_package_dir", bz_path_value_new(binary_package_dir)); bz_env_add_override(env, "staging_dir", bz_path_value_new(staging_dir)); bz_env_add_override(env, "force", bz_string_value_new(force? "1": "0")); bz_env_add_override(env, "verbose", bz_string_value_new("0")); fail_if_error(packager = bz_deb_packager_new(env)); fail_if_error(bz_packager_package(packager)); test_actions(expected_actions); bz_packager_free(packager); }
END_TEST /*----------------------------------------------------------------------- * Native package database */ /* Since we're mocking the subprocess commands for each of these test cases, the * tests can run on any platform; we don't need the DEBIAN packaging tools to * actually be installed. */ static void test_apt_pdb_dep(struct bz_pdb *pdb, const char *dep_str, const char *expected_actions) { struct bz_dependency *dep; struct bz_package *package; bz_mocked_actions_clear(); fail_if_error(dep = bz_dependency_from_string(dep_str)); fail_if_error(package = bz_pdb_satisfy_dependency(pdb, dep, NULL)); fail_if_error(bz_package_install(package)); test_actions(expected_actions); bz_dependency_free(dep); }
/* Return : None */ void kmap_process_key_event(pst_header_t pHeader, USBKCode code, int nMakeBreak, wchar_t * pBuf, int * pnBufLen,int * pFlags) { int nModNum; wchar_t aUNICodes[MAX_UNICODE_LEN]; int nUNICODELen; int nMaxLen = *pnBufLen; int isDeadKey = 0; int i,j; *pnBufLen = 0; if(NULL != pFlags) *pFlags = 0; /* Check if it is a compose sequence ignition */ /* we can be in one of three states: */ /* - regular state (0==header.pComp->nModState)&&(header.pComp -> nCurSect<0) */ /* - expectation state (one and only one bit of header.pComp->nModState is on)*/ /* - composition state (header.pComp -> nCurSect >= 0) */ if(!(nState & IGNORE_COMP) && (code >= KS_Control_L) && (code <= KS_RightGUI)) { /* Note: exclude Shift from combination starter. Otherwise there is no way to */ /* input capital letteres or any shifted keys */ if((code == KS_Shift_L) || (code == KS_Shift_R)) ; /* Just do nothing - shift keys don't impact composition's processing */ else if(pHeader -> pComp -> nCurSect >= 0) /* Already in composition state */ { if(nMakeBreak == KEY_PRESS) pHeader -> pComp -> nCurSect = -1; /* Kill it */ } else { BYTE mask = 1 << (code - KS_Control_L); int nSection = (code - KS_Control_L) % 4 + 1; if((pHeader -> pComp -> nModState) & mask) { if(nMakeBreak == KEY_RELEASE) /* set it on */ init_comp_state(pHeader, nSection); if(NULL != pFlags) *pFlags |= PFLAG_O_DEAD_KEY; /* Otherwise this is repeat press - just ignore it */ } else if(0 == pHeader -> pComp -> nModState) /* Set expectation state */ { if((nMakeBreak == KEY_PRESS) && (pHeader -> pComp -> sect[nSection].nComps > 0)) { int i, j = sizeof(anKeys); for(i = 0; i < j; ++i) { if(anKeys[i]) break; } if(i == j) /* There is no pressed keys now */ pHeader -> pComp -> nModState |= mask; /* set expectation state */ } } else pHeader -> pComp -> nModState = 0; /* Kill it */ } } else /* Any key kill expectation state */ pHeader -> pComp -> nModState = 0; /* Kill it */ /* In order to check possibility to switch to expectation state keep array of */ /* pressed/released keys: corresponding bit set to 1 (pressed) or to 0 (released) */ for(i = 0,j = sizeof(make_brake_exceptions)/sizeof(USBKCode); i < j; ++i) { if(make_brake_exceptions[i] == code) break; } if(i == j) //This is not an exception key that never produce Break { if(nMakeBreak) anKeys[code / 8] |= (1 << (code % 8)); else anKeys[code / 8] &= ~(1 << (code % 8)); } /* Check actions */ if(!(nState & IGNORE_ACTIONS)) for(nModNum = 0; nModNum < pHeader -> pMod -> nOfModifiers; ++nModNum) { if(pHeader -> pMod -> aModifiers[nModNum].modKey == code) { // This is one of modifiers // and it's state was changed ( if nMakeBreak == 1 and modifier already in // down state, no any action should be executed - this is key repeating if((0 == nMakeBreak) || !(pHeader -> pMod -> modState & (1LL << nModNum))) test_actions(pHeader, nModNum, nMakeBreak); break; } } /* Dont care about release any more */ if(KEY_RELEASE == nMakeBreak) return; /* Check if UNICODE sequence is generated */ kmap_get_unicode(pHeader, code, 0, aUNICodes, &nUNICODELen, &isDeadKey); if(isDeadKey != 0) { init_comp_state(pHeader, (KS_Alt_L - KS_Control_L) % 4 + 1); if(NULL != pFlags) *pFlags |= PFLAG_O_DEAD_KEY; } if(0 == nUNICODELen) /* nothing */ return; /* Process comosed sequences (if it is not a shift key) */ /* When we are in composite state, Shift keys only change modifiers */ if((code != KS_Shift_L) && (code != KS_Shift_R)) while(nUNICODELen > 0) { /* if we are in composition state, test new character */ if(pHeader -> pComp -> nCurSect < 0) break; check_comp_state(pHeader, aUNICodes, &nUNICODELen, pBuf, pnBufLen, nMaxLen); } if(nUNICODELen > 0) { int nCpyLen = nUNICODELen; if(nMaxLen - *pnBufLen < nUNICODELen) { nCpyLen = nMaxLen - *pnBufLen; if(verbosity > 0) fprintf(stderr, "Error (putKeybEvent): too short buffer\n"); } if(0 < nCpyLen) memcpy((void *)(pBuf + *pnBufLen), aUNICodes, nCpyLen * sizeof(wchar_t)); *pnBufLen += nCpyLen; } }