📄 fs-base-test.c
字号:
{ "A/D/H/chi", "This is the file 'chi'.\n" }, { "A/D/H/psi", "This is the file 'psi'.\n" }, { "A/D/H/omega", "This is the file 'omega'.\n" } }; /* Check nodes revision ID is gone. */ SVN_ERR(svn_fs_node_id(&iota_id, txn_root, "iota", pool)); SVN_ERR(svn_fs_node_id(&gamma_id, txn_root, "A/D/gamma", pool)); SVN_ERR(check_entry_present(txn_root, "", "iota", pool)); SVN_ERR(check_id_present(fs, iota_id, pool)); SVN_ERR(check_id_present(fs, gamma_id, pool)); /* Try deleting mutable files. */ SVN_ERR(svn_fs_delete(txn_root, "iota", pool)); SVN_ERR(svn_fs_delete(txn_root, "A/D/gamma", pool)); SVN_ERR(check_entry_absent(txn_root, "", "iota", pool)); SVN_ERR(check_entry_absent(txn_root, "A/D", "gamma", pool)); SVN_ERR(check_id_absent(fs, iota_id, pool)); SVN_ERR(check_id_absent(fs, gamma_id, pool)); /* Validate the tree. */ SVN_ERR(svn_test__validate_tree(txn_root, expected_entries, 18, pool)); } /* Abort transaction. */ SVN_ERR(svn_fs_abort_txn(txn, pool)); /* 2. Delete mutable directory. */ /* Prepare a txn to receive the greek tree. */ 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)); { const svn_fs_id_t *A_id, *mu_id, *B_id, *lambda_id, *E_id, *alpha_id, *beta_id, *F_id, *C_id, *D_id, *gamma_id, *H_id, *chi_id, *psi_id, *omega_id, *G_id, *pi_id, *rho_id, *tau_id; /* Check nodes revision ID is gone. */ SVN_ERR(svn_fs_node_id(&A_id, txn_root, "/A", pool)); SVN_ERR(check_entry_present(txn_root, "", "A", pool)); SVN_ERR(svn_fs_node_id(&mu_id, txn_root, "/A/mu", pool)); SVN_ERR(check_entry_present(txn_root, "A", "mu", pool)); SVN_ERR(svn_fs_node_id(&B_id, txn_root, "/A/B", pool)); SVN_ERR(check_entry_present(txn_root, "A", "B", pool)); SVN_ERR(svn_fs_node_id(&lambda_id, txn_root, "/A/B/lambda", pool)); SVN_ERR(check_entry_present(txn_root, "A/B", "lambda", pool)); SVN_ERR(svn_fs_node_id(&E_id, txn_root, "/A/B/E", pool)); SVN_ERR(check_entry_present(txn_root, "A/B", "E", pool)); SVN_ERR(svn_fs_node_id(&alpha_id, txn_root, "/A/B/E/alpha", pool)); SVN_ERR(check_entry_present(txn_root, "A/B/E", "alpha", pool)); SVN_ERR(svn_fs_node_id(&beta_id, txn_root, "/A/B/E/beta", pool)); SVN_ERR(check_entry_present(txn_root, "A/B/E", "beta", pool)); SVN_ERR(svn_fs_node_id(&F_id, txn_root, "/A/B/F", pool)); SVN_ERR(check_entry_present(txn_root, "A/B", "F", pool)); 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(svn_fs_node_id(&D_id, txn_root, "/A/D", pool)); SVN_ERR(check_entry_present(txn_root, "A", "D", pool)); 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(svn_fs_node_id(&H_id, txn_root, "/A/D/H", pool)); SVN_ERR(check_entry_present(txn_root, "A/D", "H", pool)); SVN_ERR(svn_fs_node_id(&chi_id, txn_root, "/A/D/H/chi", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/H", "chi", pool)); SVN_ERR(svn_fs_node_id(&psi_id, txn_root, "/A/D/H/psi", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/H", "psi", pool)); SVN_ERR(svn_fs_node_id(&omega_id, txn_root, "/A/D/H/omega", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/H", "omega", pool)); 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(svn_fs_node_id(&pi_id, txn_root, "/A/D/G/pi", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/G", "pi", pool)); SVN_ERR(svn_fs_node_id(&rho_id, txn_root, "/A/D/G/rho", pool)); SVN_ERR(check_entry_present(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", "tau", pool)); /* Try deleting a mutable empty dir. */ SVN_ERR(svn_fs_delete(txn_root, "A/C", pool)); SVN_ERR(svn_fs_delete(txn_root, "A/B/F", pool)); SVN_ERR(check_entry_absent(txn_root, "A", "C", pool)); SVN_ERR(check_entry_absent(txn_root, "A/B", "F", pool)); SVN_ERR(check_id_absent(fs, C_id, pool)); SVN_ERR(check_id_absent(fs, F_id, pool)); /* Now delete a mutable non-empty dir. */ SVN_ERR(svn_fs_delete(txn_root, "A", pool)); SVN_ERR(check_entry_absent(txn_root, "", "A", pool)); SVN_ERR(check_id_absent(fs, A_id, pool)); SVN_ERR(check_id_absent(fs, mu_id, pool)); SVN_ERR(check_id_absent(fs, B_id, pool)); SVN_ERR(check_id_absent(fs, lambda_id, pool)); SVN_ERR(check_id_absent(fs, E_id, pool)); SVN_ERR(check_id_absent(fs, alpha_id, pool)); SVN_ERR(check_id_absent(fs, beta_id, pool)); SVN_ERR(check_id_absent(fs, D_id, pool)); SVN_ERR(check_id_absent(fs, gamma_id, pool)); SVN_ERR(check_id_absent(fs, H_id, pool)); SVN_ERR(check_id_absent(fs, chi_id, pool)); SVN_ERR(check_id_absent(fs, psi_id, pool)); SVN_ERR(check_id_absent(fs, omega_id, pool)); SVN_ERR(check_id_absent(fs, G_id, pool)); SVN_ERR(check_id_absent(fs, pi_id, pool)); SVN_ERR(check_id_absent(fs, rho_id, pool)); SVN_ERR(check_id_absent(fs, tau_id, pool)); /* Validate the tree. */ { static svn_test__tree_entry_t expected_entries[] = { /* path, contents (0 = dir) */ { "iota", "This is the file 'iota'.\n" } }; SVN_ERR(svn_test__validate_tree(txn_root, expected_entries, 1, pool)); } } /* Abort transaction. */ SVN_ERR(svn_fs_abort_txn(txn, pool)); /* 3. Delete mutable directory with immutable nodes. */ /* Prepare a txn to receive the greek tree. */ 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)); /* Commit the greek tree. */ SVN_ERR(svn_fs_commit_txn(NULL, &new_rev, txn, pool)); /* Create new transaction. */ SVN_ERR(svn_fs_begin_txn(&txn, fs, new_rev, pool)); SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); { const svn_fs_id_t *A_id, *mu_id, *B_id, *lambda_id, *E_id, *alpha_id, *beta_id, *F_id, *C_id, *D_id, *gamma_id, *H_id, *chi_id, *psi_id, *omega_id, *G_id, *pi_id, *rho_id, *tau_id, *sigma_id; /* Create A/D/G/sigma. This makes all components of A/D/G mutable. */ SVN_ERR(svn_fs_make_file(txn_root, "A/D/G/sigma", pool)); SVN_ERR(svn_test__set_file_contents(txn_root, "A/D/G/sigma", "This is another file 'sigma'.\n", pool)); /* Check that mutable node-revision-IDs are removed and immutable ones still exist. */ SVN_ERR(svn_fs_node_id(&A_id, txn_root, "/A", pool)); SVN_ERR(check_entry_present(txn_root, "", "A", pool)); SVN_ERR(svn_fs_node_id(&mu_id, txn_root, "/A/mu", pool)); SVN_ERR(check_entry_present(txn_root, "A", "mu", pool)); SVN_ERR(svn_fs_node_id(&B_id, txn_root, "/A/B", pool)); SVN_ERR(check_entry_present(txn_root, "A", "B", pool)); SVN_ERR(svn_fs_node_id(&lambda_id, txn_root, "/A/B/lambda", pool)); SVN_ERR(check_entry_present(txn_root, "A/B", "lambda", pool)); SVN_ERR(svn_fs_node_id(&E_id, txn_root, "/A/B/E", pool)); SVN_ERR(check_entry_present(txn_root, "A/B", "E", pool)); SVN_ERR(svn_fs_node_id(&alpha_id, txn_root, "/A/B/E/alpha", pool)); SVN_ERR(check_entry_present(txn_root, "A/B/E", "alpha", pool)); SVN_ERR(svn_fs_node_id(&beta_id, txn_root, "/A/B/E/beta", pool)); SVN_ERR(check_entry_present(txn_root, "A/B/E", "beta", pool)); SVN_ERR(svn_fs_node_id(&F_id, txn_root, "/A/B/F", pool)); SVN_ERR(check_entry_present(txn_root, "A/B", "F", pool)); 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(svn_fs_node_id(&D_id, txn_root, "/A/D", pool)); SVN_ERR(check_entry_present(txn_root, "A", "D", pool)); 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(svn_fs_node_id(&H_id, txn_root, "/A/D/H", pool)); SVN_ERR(check_entry_present(txn_root, "A/D", "H", pool)); SVN_ERR(svn_fs_node_id(&chi_id, txn_root, "/A/D/H/chi", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/H", "chi", pool)); SVN_ERR(svn_fs_node_id(&psi_id, txn_root, "/A/D/H/psi", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/H", "psi", pool)); SVN_ERR(svn_fs_node_id(&omega_id, txn_root, "/A/D/H/omega", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/H", "omega", pool)); 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(svn_fs_node_id(&pi_id, txn_root, "/A/D/G/pi", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/G", "pi", pool)); SVN_ERR(svn_fs_node_id(&rho_id, txn_root, "/A/D/G/rho", pool)); SVN_ERR(check_entry_present(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", "tau", pool)); SVN_ERR(svn_fs_node_id(&sigma_id, txn_root, "/A/D/G/sigma", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/G", "sigma", pool)); /* Delete "A" */ SVN_ERR(svn_fs_delete(txn_root, "A", pool)); SVN_ERR(check_entry_absent(txn_root, "", "A", pool)); SVN_ERR(check_id_absent(fs, A_id, pool)); SVN_ERR(check_id_present(fs, mu_id, pool)); SVN_ERR(check_id_present(fs, B_id, pool)); SVN_ERR(check_id_present(fs, lambda_id, pool)); SVN_ERR(check_id_present(fs, E_id, pool)); SVN_ERR(check_id_present(fs, alpha_id, pool)); SVN_ERR(check_id_present(fs, beta_id, pool)); SVN_ERR(check_id_present(fs, F_id, pool)); SVN_ERR(check_id_present(fs, C_id, pool)); SVN_ERR(check_id_absent(fs, D_id, pool)); SVN_ERR(check_id_present(fs, gamma_id, pool)); SVN_ERR(check_id_present(fs, H_id, pool)); SVN_ERR(check_id_present(fs, chi_id, pool)); SVN_ERR(check_id_present(fs, psi_id, pool)); SVN_ERR(check_id_present(fs, omega_id, pool)); SVN_ERR(check_id_absent(fs, G_id, 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(check_id_absent(fs, sigma_id, pool)); /* Validate the tree. */ { static svn_test__tree_entry_t expected_entries[] = { /* path, contents (0 = dir) */ { "iota", "This is the file 'iota'.\n" } }; SVN_ERR(svn_test__validate_tree(txn_root, expected_entries, 1, pool)); } } /* Abort transaction. */ SVN_ERR(svn_fs_abort_txn(txn, pool)); /* 4. Delete immutable file. */ /* Create new transaction. */ SVN_ERR(svn_fs_begin_txn(&txn, fs, new_rev, pool)); SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); { const svn_fs_id_t *iota_id, *gamma_id; /* Check nodes revision ID is present. */ SVN_ERR(svn_fs_node_id(&iota_id, txn_root, "iota", pool)); SVN_ERR(svn_fs_node_id(&gamma_id, txn_root, "A/D/gamma", pool)); SVN_ERR(check_entry_present(txn_root, "", "iota", pool)); SVN_ERR(check_entry_present(txn_root, "A/D", "gamma", pool)); SVN_ERR(check_id_present(fs, iota_id, pool)); SVN_ERR(check_id_present(fs, gamma_id, pool)); /* Delete some files. */ SVN_ERR(svn_fs_delete(txn_root, "iota", pool)); SVN_ERR(svn_fs_delete(txn_root, "A/D/gamma", pool)); SVN_ERR(check_entry_absent(txn_root, "", "iota", pool)); SVN_ERR(check_entry_absent(txn_root, "A/D", "iota", pool)); SVN_ERR(check_id_present(fs, iota_id, pool)); SVN_ERR(check_id_present(fs, gamma_id, pool)); /* Validate the tree. */ { 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/B/F", 0 }, { "A/C", 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 }, { "A/D/H/chi", "This is the file 'chi'.\n" }, { "A/D/H/psi", "This is the file 'psi'.\n" }, { "A/D/H/omega", "This is the file 'omega'.\n" } }; SVN_ERR(svn_test__validate_tree(txn_root, expected_entries, 18, pool)); } } /* Abort transaction. */ SVN_ERR(svn_fs_abort_txn(txn, pool)); /* 5. Delete immutable directory. */ /* Create new transaction. */ SVN_ERR(svn_fs_begin_txn(&txn, fs, new_rev, pool)); SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); { const svn_fs_id_t *A_id, *mu_id, *B_id, *lambda_id, *E_id, *alpha_id, *beta_id, *F_id, *C_id, *D_id, *gamma_id, *H_id, *chi_id, *psi_id, *omega_id, *G_id, *pi_id, *rho_id, *tau_id; /* Check nodes revision ID is present. */ SVN_ERR(svn_fs_node_id(&A_id, txn_root, "/A", pool)); SVN_ERR(check_entry_present(txn_root, "", "A", pool)); SVN_ERR(svn_fs_node_id(&mu_id, txn_root, "/A/mu", pool)); SVN_ERR(check_entry_present(txn_root, "A", "mu", pool)); SVN_ERR(svn_fs_node_id(&B_id, txn_root, "/A/B", pool)); SVN_ERR(check_entry_present(txn_root, "A", "B", pool)); SVN_ERR(svn_fs_node_id(&lambda_id, txn_root, "/A/B/lambda", pool)); SVN_ERR(check_entry_present(txn_root, "A/B", "lambda", pool)); SVN_ERR(svn_fs_node_id(&E_id, txn_root, "/A/B/E", pool)); SVN_ERR(check_entry_present(txn_root, "A/B", "E", pool)); SVN_ERR(svn_fs_node_id(&alpha_id, txn_root, "/A/B/E/alpha", pool)); SVN_ERR(check_entry_present(txn_root, "A/B/E", "alpha", pool)); SVN_ERR(svn_fs_node_id(&beta_id, txn_root, "/A/B/E/beta", pool)); SVN_ERR(check_entry_present(txn_root, "A/B/E", "beta", pool)); SVN_ERR(svn_fs_node_id(&F_id, txn_root, "/A/B/F", pool)); SVN_ERR(check_entry_present(txn_root, "A/B", "F", pool)); 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(svn_fs_node_id(&D_id, txn_root, "/A/D", pool)); SVN_ERR(check_entry_present(txn_root, "A", "D", pool)); 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(svn_fs_node_id(&H_id, txn_root, "/A/D/H", pool)); SVN_ERR(check_entry_present(txn_root, "A/D", "H", pool)); SVN_ERR(svn_fs_node_id(&chi_id, txn_root, "/A/D/H/chi", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/H", "chi", pool)); SVN_ERR(svn_fs_node_id(&psi_id, txn_root, "/A/D/H/psi", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/H", "psi", pool)); SVN_ERR(svn_fs_node_id(&omega_id, txn_root, "/A/D/H/omega", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/H", "omega", pool)); 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(svn_fs_node_id(&pi_id, txn_root, "/A/D/G/pi", pool)); SVN_ERR(check_entry_present(txn_root, "A/D/G", "pi", pool)); SVN_ERR(svn_fs_node_id(&rho_id, txn_root, "/A/D/G/rho", pool)); SVN_ERR(check_entry_present(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", "tau", pool)); /* Delete "A" */ SVN_ERR(svn_fs_delete(txn_root, "A", pool)); SVN_ERR(check_entry_absent(txn_root, "", "A", pool)); SVN_ERR(check_id_present(fs, A_id, pool)); SVN_ERR(check_id_present(fs, mu_id, pool)); SVN_ERR(check_id_present(fs, B_id, pool)); SVN_ERR(check_id_present(fs, lambda_id, pool)); SVN_ERR(check_id_present(fs, E_id, pool)); SVN_ERR(check_id_present(fs, alpha_id, pool)); SVN_ERR(check_id_present(fs, beta_id, pool)); SVN_ERR(check_id_present(fs, F_id, pool)); SVN_ERR(check_id_present(fs, C_id, pool)); SVN_ERR(check_id_present(fs, D_id, pool)); SVN_ERR(check_id_present(fs, gamma_id, pool)); SVN_ERR(check_id_present(fs, H_id, pool)); SVN_ERR(check_id_present(fs, chi_id, pool)); SVN_ERR(check_id_present(fs, psi_id, pool)); SVN_ERR(check_id_present(fs, omega_id, pool)); SVN_ERR(check_id_present(fs, G_id, 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)); /* Validate the tree. */ { static svn_test__tree_entry_t expected_entries[] = { /* path, contents (0 = dir) */ { "iota", "This is the file 'iota'.\n" } }; SVN_ERR(svn_test__validate_tree(txn_root, expected_entries, 1, pool)); } } return SVN_NO_ERROR;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -