Author: stsp
Date: Thu Apr 4 11:20:48 2013
New Revision: 1464448
URL: http://svn.apache.org/r1464448
Log:
Add a new regression test which checks whether error codes are unique.
* build.conf: Add the new test to the build.
* subversion/tests/libsvn_subr: Add 'error-code-test' to svn:ignore.
* subversion/tests/libsvn_subr/error-code-test.c: New.
Added:
subversion/trunk/subversion/tests/libsvn_subr/error-code-test.c (with
props)
Modified:
subversion/trunk/build.conf
subversion/trunk/subversion/tests/libsvn_subr/ (props changed)
Modified: subversion/trunk/build.conf
URL:
http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1464448&r1=1464447&r2=1464448&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Thu Apr 4 11:20:48 2013
@@ -808,6 +808,14 @@ sources = error-test.c
install = test
libs = libsvn_test libsvn_subr apriconv apr
+[error-code-test]
+description = Test error library
+type = exe
+path = subversion/tests/libsvn_subr
+sources = error-code-test.c
+install = test
+libs = libsvn_test libsvn_subr apriconv apr
+
[hashdump-test]
description = Test hashfile format for props
type = exe
Propchange: subversion/trunk/subversion/tests/libsvn_subr/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Apr 4 11:20:48 2013
@@ -13,6 +13,7 @@ compat-test
config-test
crypto-test
error-test
+error-code-test
hashdump-test
hashdump.out
hashdump2.out
Added: subversion/trunk/subversion/tests/libsvn_subr/error-code-test.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/error-code-test.c?rev=1464448&view=auto
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/error-code-test.c (added)
+++ subversion/trunk/subversion/tests/libsvn_subr/error-code-test.c Thu Apr 4
11:20:48 2013
@@ -0,0 +1,81 @@
+/*
+ * error-code-test.c -- tests for error codes
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <apr_general.h>
+
+#include "svn_error.h"
+
+typedef struct err_defn {
+ svn_errno_t errcode;
+ const char *errdesc;
+} err_defn;
+
+/* To understand what is going on here, read svn_error_codes.h. */
+#define SVN_ERROR_BUILD_ARRAY
+#include "svn_error_codes.h"
+
+#include "../svn_test.h"
+
+#define NUM_ERRORS (sizeof(error_table)/sizeof(error_table[0]))
+
+static svn_error_t *
+check_error_codes_unique(apr_pool_t *pool)
+{
+ int i;
+ struct err_defn e = error_table[0];
+
+ /* Ensure error codes a strictly monotonically increasing. */
+ for (i = 1; i < NUM_ERRORS; i++)
+ {
+ struct err_defn e2 = error_table[i++];
+
+ /* Don't fail the test if there is an odd number of errors.
+ * The error array's sentinel has an error code of zero. */
+ if (i == NUM_ERRORS - 1 && e2.errcode == 0)
+ break;
+
+ /* SVN_ERR_WC_NOT_DIRECTORY is an alias for SVN_ERR_WC_NOT_WORKING_COPY
+ * and shares the same error code. */
+ if (e.errcode != SVN_ERR_WC_NOT_DIRECTORY &&
+ e.errcode >= e2.errcode)
+ return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
+ "Error 0x%x (%s) is not < 0x%x (%s)\n",
+ e.errcode, e.errdesc, e2.errcode, e2.errdesc);
+ e = e2;
+ }
+
+ return SVN_NO_ERROR;
+}
+
+
+/* The test table. */
+
+struct svn_test_descriptor_t test_funcs[] =
+ {
+ SVN_TEST_NULL,
+ SVN_TEST_PASS2(check_error_codes_unique,
+ "check that error codes are unique"),
+ SVN_TEST_NULL
+ };
Propchange: subversion/trunk/subversion/tests/libsvn_subr/error-code-test.c
------------------------------------------------------------------------------
svn:eol-style = native