⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs-base-test.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
    SVN_ERR(svn_fs_node_id(&t1_tau_id, txn1_root, "/A/D/G/tau", pool));    SVN_ERR(svn_fs_node_id(&t2_tau_id, txn2_root, "/A/D/G/tau", pool));    /* Abort just txn2. */    SVN_ERR(svn_fs_abort_txn(txn2, pool));    /* Now test that all the nodes in txn2 at the time of the abort     * are gone, but all of the ones in txn1 are still there.      */    /* Check that every node rev in t2 has vanished from the fs. */    SVN_ERR(check_id_absent(fs, t2_root_id, pool));    SVN_ERR(check_id_absent(fs, t2_iota_id, pool));    SVN_ERR(check_id_absent(fs, t2_A_id, pool));    SVN_ERR(check_id_absent(fs, t2_mu_id, pool));    SVN_ERR(check_id_absent(fs, t2_B_id, pool));    SVN_ERR(check_id_absent(fs, t2_lambda_id, pool));    SVN_ERR(check_id_absent(fs, t2_E_id, pool));    SVN_ERR(check_id_absent(fs, t2_alpha_id, pool));    SVN_ERR(check_id_absent(fs, t2_beta_id, pool));    SVN_ERR(check_id_absent(fs, t2_F_id, pool));    SVN_ERR(check_id_absent(fs, t2_C_id, pool));    SVN_ERR(check_id_absent(fs, t2_D_id, pool));    SVN_ERR(check_id_absent(fs, t2_gamma_id, pool));    SVN_ERR(check_id_absent(fs, t2_H_id, pool));    SVN_ERR(check_id_absent(fs, t2_chi_id, pool));    SVN_ERR(check_id_absent(fs, t2_psi_id, pool));    SVN_ERR(check_id_absent(fs, t2_omega_id, pool));    SVN_ERR(check_id_absent(fs, t2_G_id, pool));    SVN_ERR(check_id_absent(fs, t2_pi_id, pool));    SVN_ERR(check_id_absent(fs, t2_rho_id, pool));    SVN_ERR(check_id_absent(fs, t2_tau_id, pool));        /* Check that every node rev in t1 is still in the fs. */    SVN_ERR(check_id_present(fs, t1_root_id, pool));    SVN_ERR(check_id_present(fs, t1_iota_id, pool));    SVN_ERR(check_id_present(fs, t1_A_id, pool));    SVN_ERR(check_id_present(fs, t1_mu_id, pool));    SVN_ERR(check_id_present(fs, t1_B_id, pool));    SVN_ERR(check_id_present(fs, t1_lambda_id, pool));    SVN_ERR(check_id_present(fs, t1_E_id, pool));    SVN_ERR(check_id_present(fs, t1_alpha_id, pool));    SVN_ERR(check_id_present(fs, t1_beta_id, pool));    SVN_ERR(check_id_present(fs, t1_F_id, pool));    SVN_ERR(check_id_present(fs, t1_C_id, pool));    SVN_ERR(check_id_present(fs, t1_D_id, pool));    SVN_ERR(check_id_present(fs, t1_gamma_id, pool));    SVN_ERR(check_id_present(fs, t1_H_id, pool));    SVN_ERR(check_id_present(fs, t1_chi_id, pool));    SVN_ERR(check_id_present(fs, t1_psi_id, pool));    SVN_ERR(check_id_present(fs, t1_omega_id, pool));    SVN_ERR(check_id_present(fs, t1_G_id, pool));    SVN_ERR(check_id_present(fs, t1_pi_id, pool));    SVN_ERR(check_id_present(fs, t1_rho_id, pool));    SVN_ERR(check_id_present(fs, t1_tau_id, pool));  }  /* Test that txn2 itself is gone, by trying to open it. */  {    svn_fs_txn_t *txn2_again;    svn_error_t *err;    err = svn_fs_open_txn(&txn2_again, fs, txn2_name, pool);    if (err && (err->apr_err != SVN_ERR_FS_NO_SUCH_TRANSACTION))      {        return svn_error_create          (SVN_ERR_FS_GENERAL, err,           "opening non-existent txn got wrong error");      }    else if (! err)      {        return svn_error_create          (SVN_ERR_FS_GENERAL, NULL,           "opening non-existent txn failed to get error");      }    svn_error_clear(err);  }  /* Test that txn names are not recycled, by opening a new txn.  */  {    svn_fs_txn_t *txn3;    const char *txn3_name;    SVN_ERR(svn_fs_begin_txn(&txn3, fs, 0, pool));    SVN_ERR(svn_fs_txn_name(&txn3_name, txn3, pool));    if ((strcmp(txn3_name, txn2_name) == 0)        || (strcmp(txn3_name, txn1_name) == 0))      {        return svn_error_createf          (SVN_ERR_FS_GENERAL, NULL,           "txn name \"%s\" was recycled", txn3_name);      }  }  /* Test that aborting a txn that's already committed fails. */  {    svn_fs_txn_t *txn4;    const char *txn4_name;    svn_revnum_t new_rev;    const char *conflict;    svn_error_t *err;    SVN_ERR(svn_fs_begin_txn(&txn4, fs, 0, pool));    SVN_ERR(svn_fs_txn_name(&txn4_name, txn4, pool));    SVN_ERR(svn_fs_commit_txn(&conflict, &new_rev, txn4, pool));    err = svn_fs_abort_txn(txn4, pool);    if (! err)      return svn_error_create        (SVN_ERR_FS_GENERAL, NULL,         "expected error trying to abort a committed txn; got none");    else if (err->apr_err != SVN_ERR_FS_TRANSACTION_NOT_MUTABLE)      return svn_error_create        (SVN_ERR_FS_GENERAL, err,         "got an unexpected error trying to abort a committed txn");    else      svn_error_clear(err);  }  return SVN_NO_ERROR;}/* This tests deleting of mutable nodes.  We build a tree in a * transaction, then try to delete various items in the tree.  We * never commit the tree, so every entry being deleted points to a  * mutable node.  *  * ### todo: this test was written before commits worked.  It might * now be worthwhile to combine it with delete(). */static svn_error_t *delete_mutables(const char **msg,                svn_boolean_t msg_only,                svn_test_opts_t *opts,                apr_pool_t *pool){  svn_fs_t *fs;  svn_fs_txn_t *txn;  svn_fs_root_t *txn_root;  svn_error_t *err;  *msg = "delete mutable nodes from directories";  if (msg_only)    return SVN_NO_ERROR;  /* Prepare a txn to receive the greek tree. */  SVN_ERR(svn_test__create_fs(&fs, "test-repo-del-from-dir",                              "bdb", pool));  SVN_ERR(svn_fs_begin_txn(&txn, fs, 0, pool));  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));    /* Create the greek tree. */  SVN_ERR(svn_test__create_greek_tree(txn_root, pool));  /* Baby, it's time to test like you've never tested before.  We do   * the following, in this order:   *   *    1. Delete a single file somewhere, succeed.   *    2. Delete two files of three, then make sure the third remains.   *    3. Delete the third and last file.   *    4. Try again to delete the dir, succeed.   *    5. Delete one of the natively empty dirs, succeed.   *    6. Try to delete root, fail.   *    7. Try to delete a top-level file, succeed.   *   * Specifically, that's:   *   *    1. Delete A/D/gamma.   *    2. Delete A/D/G/pi, A/D/G/rho.   *    3. Delete A/D/G/tau.   *    4. Try again to delete A/D/G, succeed.   *    5. Delete A/C.   *    6. Try to delete /, fail.   *    7. Try to delete iota, succeed.   *   * Before and after each deletion or attempted deletion, we probe   * the affected directory, to make sure everything is as it should   * be.   */  /* 1 */  {    const svn_fs_id_t *gamma_id;    SVN_ERR(svn_fs_node_id(&gamma_id, txn_root, "A/D/gamma", pool));    SVN_ERR(check_entry_present(txn_root, "A/D", "gamma", pool));    SVN_ERR(check_id_present(fs, gamma_id, pool));    SVN_ERR(svn_fs_delete(txn_root, "A/D/gamma", pool));    SVN_ERR(check_entry_absent(txn_root, "A/D", "gamma", pool));    SVN_ERR(check_id_absent(fs, gamma_id, pool));  }  /* 2 */  {    const svn_fs_id_t *pi_id, *rho_id, *tau_id;    SVN_ERR(svn_fs_node_id(&pi_id, txn_root, "A/D/G/pi", pool));    SVN_ERR(svn_fs_node_id(&rho_id, txn_root, "A/D/G/rho", pool));    SVN_ERR(svn_fs_node_id(&tau_id, txn_root, "A/D/G/tau", pool));    SVN_ERR(check_entry_present(txn_root, "A/D/G", "pi", pool));    SVN_ERR(check_entry_present(txn_root, "A/D/G", "rho", pool));    SVN_ERR(check_entry_present(txn_root, "A/D/G", "tau", pool));    SVN_ERR(check_id_present(fs, pi_id, pool));    SVN_ERR(check_id_present(fs, rho_id, pool));    SVN_ERR(check_id_present(fs, tau_id, pool));    SVN_ERR(svn_fs_delete(txn_root, "A/D/G/pi", pool));    SVN_ERR(check_entry_absent(txn_root, "A/D/G", "pi", pool));    SVN_ERR(check_entry_present(txn_root, "A/D/G", "rho", pool));    SVN_ERR(check_entry_present(txn_root, "A/D/G", "tau", pool));    SVN_ERR(check_id_absent(fs, pi_id, pool));    SVN_ERR(check_id_present(fs, rho_id, pool));    SVN_ERR(check_id_present(fs, tau_id, pool));    SVN_ERR(svn_fs_delete(txn_root, "A/D/G/rho", pool));    SVN_ERR(check_entry_absent(txn_root, "A/D/G", "pi", pool));    SVN_ERR(check_entry_absent(txn_root, "A/D/G", "rho", pool));    SVN_ERR(check_entry_present(txn_root, "A/D/G", "tau", pool));    SVN_ERR(check_id_absent(fs, pi_id, pool));    SVN_ERR(check_id_absent(fs, rho_id, pool));    SVN_ERR(check_id_present(fs, tau_id, pool));  }  /* 3 */  {    const svn_fs_id_t *tau_id;    SVN_ERR(svn_fs_node_id(&tau_id, txn_root, "A/D/G/tau", pool));    SVN_ERR(check_entry_present(txn_root, "A/D/G", "tau", pool));    SVN_ERR(check_id_present(fs, tau_id, pool));    SVN_ERR(svn_fs_delete(txn_root, "A/D/G/tau", pool));    SVN_ERR(check_entry_absent(txn_root, "A/D/G", "tau", pool));    SVN_ERR(check_id_absent(fs, tau_id, pool));  }  /* 4 */  {    const svn_fs_id_t *G_id;    SVN_ERR(svn_fs_node_id(&G_id, txn_root, "A/D/G", pool));    SVN_ERR(check_entry_present(txn_root, "A/D", "G", pool));    SVN_ERR(check_id_present(fs, G_id, pool));    SVN_ERR(svn_fs_delete(txn_root, "A/D/G", pool));        /* succeed */    SVN_ERR(check_entry_absent(txn_root, "A/D", "G", pool));    SVN_ERR(check_id_absent(fs, G_id, pool));  }  /* 5 */  {    const svn_fs_id_t *C_id;    SVN_ERR(svn_fs_node_id(&C_id, txn_root, "A/C", pool));    SVN_ERR(check_entry_present(txn_root, "A", "C", pool));    SVN_ERR(check_id_present(fs, C_id, pool));    SVN_ERR(svn_fs_delete(txn_root, "A/C", pool));    SVN_ERR(check_entry_absent(txn_root, "A", "C", pool));    SVN_ERR(check_id_absent(fs, C_id, pool));  }  /* 6 */  {    const svn_fs_id_t *root_id;    SVN_ERR(svn_fs_node_id(&root_id, txn_root, "", pool));    err = svn_fs_delete(txn_root, "", pool);    if (err && (err->apr_err != SVN_ERR_FS_ROOT_DIR))      {        return svn_error_createf          (SVN_ERR_FS_GENERAL, err,           "deleting root directory got wrong error");      }    else if (! err)      {        return svn_error_createf          (SVN_ERR_FS_GENERAL, NULL,           "deleting root directory failed to get error");      }    svn_error_clear(err);    SVN_ERR(check_id_present(fs, root_id, pool));  }  /* 7 */  {    const svn_fs_id_t *iota_id;    SVN_ERR(svn_fs_node_id(&iota_id, txn_root, "iota", pool));    SVN_ERR(check_entry_present(txn_root, "", "iota", pool));    SVN_ERR(check_id_present(fs, iota_id, pool));    SVN_ERR(svn_fs_delete(txn_root, "iota", pool));    SVN_ERR(check_entry_absent(txn_root, "", "iota", pool));    SVN_ERR(check_id_absent(fs, iota_id, pool));  }  return SVN_NO_ERROR;}/* This tests deleting in general. *  * ### todo: this test was written after (and independently of) * delete_mutables().  It might be worthwhile to combine them. */static svn_error_t *delete(const char **msg,       svn_boolean_t msg_only,       svn_test_opts_t *opts,       apr_pool_t *pool){  svn_fs_t *fs;  svn_fs_txn_t *txn;  svn_fs_root_t *txn_root;  svn_revnum_t new_rev;  *msg = "delete nodes tree";  if (msg_only)    return SVN_NO_ERROR;  /* This function tests 5 cases:   *   * 1. Delete mutable file.   * 2. Delete mutable directory.   * 3. Delete mutable directory with immutable nodes.   * 4. Delete immutable file.   * 5. Delete immutable directory.   */  /* Prepare a txn to receive the greek tree. */  SVN_ERR(svn_test__create_fs(&fs, "test-repo-del-tree",                              "bdb", pool));  SVN_ERR(svn_fs_begin_txn(&txn, fs, 0, pool));  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));  /* Create the greek tree. */  SVN_ERR(svn_test__create_greek_tree(txn_root, pool));  /* 1. Delete mutable file. */  {    const svn_fs_id_t *iota_id, *gamma_id;    static svn_test__tree_entry_t expected_entries[] = {      /* path, contents (0 = dir) */      { "A",           0 },      { "A/mu",        "This is the file 'mu'.\n" },      { "A/B",         0 },      { "A/B/lambda",  "This is the file 'lambda'.\n" },      { "A/B/E",       0 },      { "A/B/E/alpha", "This is the file 'alpha'.\n" },      { "A/B/E/beta",  "This is the file 'beta'.\n" },      { "A/C",         0 },      { "A/B/F",       0 },      { "A/D",         0 },      { "A/D/G",       0 },      { "A/D/G/pi",    "This is the file 'pi'.\n" },      { "A/D/G/rho",   "This is the file 'rho'.\n" },      { "A/D/G/tau",   "This is the file 'tau'.\n" },      { "A/D/H",       0 },

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -