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

📄 fs-test.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Create a file, a directory, and a file in that directory! */static svn_error_t *create_greek_tree_transaction(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;  *msg = "make The Official Subversion Test Tree";  if (msg_only)    return SVN_NO_ERROR;  /* Prepare a txn to receive the greek tree. */  SVN_ERR(svn_test__create_fs(&fs, "test-repo-create-greek-tree-txn",                              opts->fs_type, pool));  SVN_ERR(svn_fs_begin_txn(&txn, fs, 0, pool));  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));  /* Create and verify the greek tree. */  SVN_ERR(svn_test__create_greek_tree(txn_root, pool));  return SVN_NO_ERROR;}/* Verify that entry KEY is present in ENTRIES, and that its value is   an svn_fs_dirent_t whose name and id are not null. */static svn_error_t *verify_entry(apr_hash_t *entries, const char *key){  svn_fs_dirent_t *ent = apr_hash_get(entries, key,                                       APR_HASH_KEY_STRING);  if (ent == NULL)    return svn_error_createf      (SVN_ERR_FS_GENERAL, NULL,       "didn't find dir entry for \"%s\"", key);  if ((ent->name == NULL) && (ent->id == NULL))    return svn_error_createf      (SVN_ERR_FS_GENERAL, NULL,       "dir entry for \"%s\" has null name and null id", key);    if (ent->name == NULL)    return svn_error_createf      (SVN_ERR_FS_GENERAL, NULL,       "dir entry for \"%s\" has null name", key);    if (ent->id == NULL)    return svn_error_createf      (SVN_ERR_FS_GENERAL, NULL,       "dir entry for \"%s\" has null id", key);    if (strcmp(ent->name, key) != 0)     return svn_error_createf     (SVN_ERR_FS_GENERAL, NULL,      "dir entry for \"%s\" contains wrong name (\"%s\")", key, ent->name);          return SVN_NO_ERROR;}static svn_error_t *list_directory(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;  apr_hash_t *entries;  *msg = "fill a directory, then list it";  if (msg_only)    return SVN_NO_ERROR;  SVN_ERR(svn_test__create_fs(&fs, "test-repo-list-dir",                              opts->fs_type, pool));  SVN_ERR(svn_fs_begin_txn(&txn, fs, 0, pool));  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));    /* We create this tree   *   *         /q   *         /A/x   *         /A/y   *         /A/z   *         /B/m   *         /B/n   *         /B/o   *   * then list dir A.  It should have 3 files: "x", "y", and "z", no   * more, no less.   */  /* Create the tree. */  SVN_ERR(svn_fs_make_file(txn_root, "q", pool));  SVN_ERR(svn_fs_make_dir(txn_root, "A", pool));  SVN_ERR(svn_fs_make_file(txn_root, "A/x", pool));  SVN_ERR(svn_fs_make_file(txn_root, "A/y", pool));  SVN_ERR(svn_fs_make_file(txn_root, "A/z", pool));  SVN_ERR(svn_fs_make_dir(txn_root, "B", pool));  SVN_ERR(svn_fs_make_file(txn_root, "B/m", pool));  SVN_ERR(svn_fs_make_file(txn_root, "B/n", pool));  SVN_ERR(svn_fs_make_file(txn_root, "B/o", pool));  /* Get A's entries. */  SVN_ERR(svn_fs_dir_entries(&entries, txn_root, "A", pool));  /* Make sure exactly the right set of entries is present. */  if (apr_hash_count(entries) != 3)    {      return svn_error_create(SVN_ERR_FS_GENERAL, NULL,                              "unexpected number of entries in dir");    }  else    {      SVN_ERR(verify_entry(entries, "x"));      SVN_ERR(verify_entry(entries, "y"));      SVN_ERR(verify_entry(entries, "z"));    }  return SVN_NO_ERROR;}static svn_error_t *revision_props(const char **msg,               svn_boolean_t msg_only,               svn_test_opts_t *opts,               apr_pool_t *pool){  svn_fs_t *fs;  apr_hash_t *proplist;  svn_string_t *value;  int i;  svn_string_t s1;  const char *initial_props[4][2] = {     { "color", "red" },    { "size", "XXL" },    { "favorite saturday morning cartoon", "looney tunes" },    { "auto", "Green 1997 Saturn SL1" }    };  const char *final_props[4][2] = {     { "color", "violet" },    { "flower", "violet" },    { "favorite saturday morning cartoon", "looney tunes" },    { "auto", "Red 2000 Chevrolet Blazer" }    };  *msg = "set and get some revision properties";  if (msg_only)    return SVN_NO_ERROR;  /* Open the fs */  SVN_ERR(svn_test__create_fs(&fs, "test-repo-rev-props",                              opts->fs_type, pool));  /* Set some properties on the revision. */  for (i = 0; i < 4; i++)    {      SET_STR(&s1, initial_props[i][1]);      SVN_ERR(svn_fs_change_rev_prop(fs, 0, initial_props[i][0], &s1, pool));    }  /* Change some of the above properties. */  SET_STR(&s1, "violet");  SVN_ERR(svn_fs_change_rev_prop(fs, 0, "color", &s1, pool));  SET_STR(&s1, "Red 2000 Chevrolet Blazer");  SVN_ERR(svn_fs_change_rev_prop(fs, 0, "auto", &s1, pool));  /* Remove a property altogether */  SVN_ERR(svn_fs_change_rev_prop(fs, 0, "size", NULL, pool));  /* Copy a property's value into a new property. */  SVN_ERR(svn_fs_revision_prop(&value, fs, 0, "color", pool));  s1.data = value->data;  s1.len = value->len;  SVN_ERR(svn_fs_change_rev_prop(fs, 0, "flower", &s1, pool));  /* Obtain a list of all current properties, and make sure it matches     the expected values. */  SVN_ERR(svn_fs_revision_proplist(&proplist, fs, 0, pool));  {    svn_string_t *prop_value;    if (apr_hash_count(proplist) < 4 )      return svn_error_createf        (SVN_ERR_FS_GENERAL, NULL,         "too few revision properties found");    /* Loop through our list of expected revision property name/value       pairs. */    for (i = 0; i < 4; i++)      {        /* For each expected property: */        /* Step 1.  Find it by name in the hash of all rev. props           returned to us by svn_fs_revision_proplist.  If it can't be           found, return an error. */        prop_value = apr_hash_get(proplist,                                   final_props[i][0],                                  APR_HASH_KEY_STRING);        if (! prop_value)          return svn_error_createf            (SVN_ERR_FS_GENERAL, NULL,             "unable to find expected revision property");        /* Step 2.  Make sure the value associated with it is the same           as what was expected, else return an error. */        if (strcmp(prop_value->data, final_props[i][1]))          return svn_error_createf            (SVN_ERR_FS_GENERAL, NULL,             "revision property had an unexpected value");      }  }  return SVN_NO_ERROR;}static svn_error_t *transaction_props(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;  apr_hash_t *proplist;  svn_string_t *value;  svn_revnum_t after_rev;  int i;  svn_string_t s1;  const char *initial_props[4][2] = {     { "color", "red" },    { "size", "XXL" },    { "favorite saturday morning cartoon", "looney tunes" },    { "auto", "Green 1997 Saturn SL1" }    };  const char *final_props[5][2] = {     { "color", "violet" },    { "flower", "violet" },    { "favorite saturday morning cartoon", "looney tunes" },    { "auto", "Red 2000 Chevrolet Blazer" },    { SVN_PROP_REVISION_DATE, "<some datestamp value>" }    };  *msg = "set/get txn props, commit, validate new rev props";  if (msg_only)    return SVN_NO_ERROR;  /* Open the fs */  SVN_ERR(svn_test__create_fs(&fs, "test-repo-txn-props",                              opts->fs_type, pool));  SVN_ERR(svn_fs_begin_txn(&txn, fs, 0, pool));  /* Set some properties on the revision. */  for (i = 0; i < 4; i++)    {      SET_STR(&s1, initial_props[i][1]);      SVN_ERR(svn_fs_change_txn_prop(txn, initial_props[i][0], &s1, pool));    }  /* Change some of the above properties. */  SET_STR(&s1, "violet");  SVN_ERR(svn_fs_change_txn_prop(txn, "color", &s1, pool));  SET_STR(&s1, "Red 2000 Chevrolet Blazer");  SVN_ERR(svn_fs_change_txn_prop(txn, "auto", &s1, pool));  /* Remove a property altogether */  SVN_ERR(svn_fs_change_txn_prop(txn, "size", NULL, pool));  /* Copy a property's value into a new property. */  SVN_ERR(svn_fs_txn_prop(&value, txn, "color", pool));  s1.data = value->data;  s1.len = value->len;  SVN_ERR(svn_fs_change_txn_prop(txn, "flower", &s1, pool));  /* Obtain a list of all current properties, and make sure it matches     the expected values. */  SVN_ERR(svn_fs_txn_proplist(&proplist, txn, pool));  {    svn_string_t *prop_value;    /* All transactions get a datestamp property at their inception,       so we expect *5*, not 4 properties. */    if (apr_hash_count(proplist) != 5 )      return svn_error_createf        (SVN_ERR_FS_GENERAL, NULL,         "unexpected number of transaction properties were found");    /* Loop through our list of expected revision property name/value       pairs. */    for (i = 0; i < 5; i++)      {        /* For each expected property: */        /* Step 1.  Find it by name in the hash of all rev. props           returned to us by svn_fs_revision_proplist.  If it can't be           found, return an error. */        prop_value = apr_hash_get(proplist,                                   final_props[i][0],                                  APR_HASH_KEY_STRING);        if (! prop_value)          return svn_error_createf            (SVN_ERR_FS_GENERAL, NULL,             "unable to find expected transaction property");        /* Step 2.  Make sure the value associated with it is the same           as what was expected, else return an error. */        if (strcmp(final_props[i][0], SVN_PROP_REVISION_DATE))          if (strcmp(prop_value->data, final_props[i][1]))            return svn_error_createf              (SVN_ERR_FS_GENERAL, NULL,               "transaction property had an unexpected value");      }  }    /* Commit the transaction. */  SVN_ERR(test_commit_txn(&after_rev, txn, NULL, pool));  if (after_rev != 1)    return svn_error_createf      (SVN_ERR_FS_GENERAL, NULL,       "committed transaction got wrong revision number");  /* Obtain a list of all properties on the new revision, and make     sure it matches the expected values.  If you're wondering, the     expected values should be the exact same set of properties that     existed on the transaction just prior to its being committed. */  SVN_ERR(svn_fs_revision_proplist(&proplist, fs, after_rev, pool));  {    svn_string_t *prop_value;    if (apr_hash_count(proplist) < 5 )      return svn_error_createf        (SVN_ERR_FS_GENERAL, NULL,         "unexpected number of revision properties were found");    /* Loop through our list of expected revision property name/value       pairs. */    for (i = 0; i < 5; i++)      {        /* For each expected property: */

⌨️ 快捷键说明

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