Mark many merge tests as skip-against-old-server.
[svn.git] / subversion / tests / libsvn_subr / error-test.c
bloba37b2a878db31281590b35ac532bead6c98da646
1 /*
2 * error-test.c -- test the error functions
4 * ====================================================================
5 * Copyright (c) 2006 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 #include <stdio.h>
20 #include <string.h>
21 #include <apr_general.h>
23 #include "svn_error_codes.h"
24 #include "svn_error.h"
26 #include "../svn_test.h"
28 static svn_error_t *
29 test_error_root_cause(const char **msg,
30 svn_boolean_t msg_only,
31 svn_test_opts_t *opts,
32 apr_pool_t *pool)
34 apr_status_t secondary_err_codes[] = { SVN_ERR_STREAM_UNRECOGNIZED_DATA,
35 SVN_ERR_STREAM_MALFORMED_DATA };
36 apr_status_t root_cause_err_code = SVN_ERR_STREAM_UNEXPECTED_EOF;
37 int i;
38 svn_error_t *err, *root_err;
40 *msg = "test svn_error_root_cause";
42 if (msg_only)
43 return SVN_NO_ERROR;
45 /* Nest several errors. */
46 err = svn_error_create(root_cause_err_code, NULL, "root cause");
47 for (i = 0; i < 2; i++)
48 err = svn_error_create(secondary_err_codes[i], err, NULL);
50 /* Verify that the error is detected at the proper location in the
51 error chain. */
52 root_err = svn_error_root_cause(err);
53 if (root_err == NULL)
55 svn_error_clear(err);
56 return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
57 "svn_error_root_cause failed to locate any "
58 "root error in the chain");
61 for (i = 0; i < 2; i++)
63 if (root_err->apr_err == secondary_err_codes[i])
65 svn_error_clear(err);
66 return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
67 "svn_error_root_cause returned the "
68 "wrong error from the chain");
72 if (root_err->apr_err != root_cause_err_code)
74 svn_error_clear(err);
75 return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
76 "svn_error_root_cause failed to locate the "
77 "correct error from teh chain");
80 svn_error_clear(err);
81 return SVN_NO_ERROR;
85 /* The test table. */
87 struct svn_test_descriptor_t test_funcs[] =
89 SVN_TEST_NULL,
90 SVN_TEST_PASS(test_error_root_cause),
91 SVN_TEST_NULL