serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1700731 - in /serf/trunk/test: test_auth.c test_buckets.c test_context.c test_serf.h test_ssl.c test_util.c
Date Wed, 02 Sep 2015 08:40:00 GMT
Author: lgo
Date: Wed Sep  2 08:40:00 2015
New Revision: 1700731

URL: http://svn.apache.org/r1700731
Log:
In the test suite, introduce a new helper function to log errors test suite
errors.

* test/test_serf.h
  (test__report_suite_error): New function declaration.
  (REPORT_TEST_SUITE_ERROR): New macro, logs error at the current code line
      and returns SERF_ERROR_ISSUE_IN_TESTSUITE as status code.

* test/test_util.c
  (dummy_authn_callback,
   run_client_and_mock_servers_loops): Use the new macro to report an error.
  (test__report_suite_error): New function, logs where in the test suite code
      an error was raised.

* test/test_auth.c
* test/test_buckets.c
* test/test_context.c
* test/test_ssl.c
  (*): Replace all uses of SERF_ERROR_ISSUE_IN_TESTSUITE with the new macro.

Modified:
    serf/trunk/test/test_auth.c
    serf/trunk/test/test_buckets.c
    serf/trunk/test/test_context.c
    serf/trunk/test/test_serf.h
    serf/trunk/test/test_ssl.c
    serf/trunk/test/test_util.c

Modified: serf/trunk/test/test_auth.c
URL: http://svn.apache.org/viewvc/serf/trunk/test/test_auth.c?rev=1700731&r1=1700730&r2=1700731&view=diff
==============================================================================
--- serf/trunk/test/test_auth.c (original)
+++ serf/trunk/test/test_auth.c Wed Sep  2 08:40:00 2015
@@ -37,7 +37,7 @@ authn_callback_expect_not_called(char **
     tb->result_flags |= TEST_RESULT_AUTHNCB_CALLED;
 
     /* Should not have been called. */
-    return SERF_ERROR_ISSUE_IN_TESTSUITE;
+    return REPORT_TEST_SUITE_ERROR();
 }
 
 /* Tests that authn fails if all authn schemes are disabled. */
@@ -120,12 +120,12 @@ basic_authn_callback(char **username,
     tb->result_flags |= TEST_RESULT_AUTHNCB_CALLED;
 
     if (code != 401)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Basic", authn_type) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp(apr_psprintf(pool, "<http://localhost:%d> Test Suite",
                             tb->serv_port), realm) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     *username = "serf";
     *password = "serftest";
@@ -223,12 +223,12 @@ digest_authn_callback(char **username,
     tb->result_flags |= TEST_RESULT_AUTHNCB_CALLED;
 
     if (code != 401)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Digest", authn_type) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp(apr_psprintf(pool, "<http://localhost:%d> Test Suite",
                             tb->serv_port), realm) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     *username = "serf";
     *password = "serftest";
@@ -324,9 +324,9 @@ switched_realm_authn_callback(char **use
     tb->result_flags |= TEST_RESULT_AUTHNCB_CALLED;
 
     if (code != 401)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp(exp_realm, realm) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     if (strcmp(apr_psprintf(pool, "<http://localhost:%d> Test Suite",
                             tb->serv_port), realm) == 0) {

Modified: serf/trunk/test/test_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/test/test_buckets.c?rev=1700731&r1=1700730&r2=1700731&view=diff
==============================================================================
--- serf/trunk/test/test_buckets.c (original)
+++ serf/trunk/test/test_buckets.c Wed Sep  2 08:40:00 2015
@@ -55,7 +55,7 @@ static apr_status_t read_all(serf_bucket
             {
                 /* Buffer is not large enough to read all data */
                 data_len = buf_len - read;
-                status = SERF_ERROR_ISSUE_IN_TESTSUITE;
+                status = REPORT_TEST_SUITE_ERROR();
             }
             memcpy(buf + read, data, data_len);
             read += data_len;

Modified: serf/trunk/test/test_context.c
URL: http://svn.apache.org/viewvc/serf/trunk/test/test_context.c?rev=1700731&r1=1700730&r2=1700731&view=diff
==============================================================================
--- serf/trunk/test/test_context.c (original)
+++ serf/trunk/test/test_context.c Wed Sep  2 08:40:00 2015
@@ -797,7 +797,7 @@ static apr_status_t handle_response_time
     }
 
     if (serf_request_is_written(request) != APR_EBUSY) {
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     }
 
 

Modified: serf/trunk/test/test_serf.h
URL: http://svn.apache.org/viewvc/serf/trunk/test/test_serf.h?rev=1700731&r1=1700730&r2=1700731&view=diff
==============================================================================
--- serf/trunk/test/test_serf.h (original)
+++ serf/trunk/test/test_serf.h Wed Sep  2 08:40:00 2015
@@ -284,6 +284,12 @@ run_client_and_mock_servers_loops_expect
                                             handler_baton_t handler_ctx[],
                                             apr_pool_t *pool);
 
+/* Logs a test suite error with its code location, and return status 
+   SERF_ERROR_ISSUE_IN_TESTSUITE. */
+#define REPORT_TEST_SUITE_ERROR()\
+     test__report_suite_error(__FILE__, __LINE__)
+apr_status_t test__report_suite_error(const char *filename, long line);
+
 /* Logs a standard event, with filename & timestamp header */
 void test__log(int verbose_flag, const char *filename, const char *fmt, ...);
 

Modified: serf/trunk/test/test_ssl.c
URL: http://svn.apache.org/viewvc/serf/trunk/test/test_ssl.c?rev=1700731&r1=1700730&r2=1700731&view=diff
==============================================================================
--- serf/trunk/test/test_ssl.c (original)
+++ serf/trunk/test/test_ssl.c Wed Sep  2 08:40:00 2015
@@ -299,25 +299,25 @@ static apr_status_t validate_servercert(
     subject = serf_ssl_cert_subject(cert, pool);
     if (strcmp("localhost",
                apr_hash_get(subject, "CN", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Test Suite Server",
                apr_hash_get(subject, "OU", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("In Serf we trust, Inc.",
                apr_hash_get(subject, "O", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Mechelen",
                apr_hash_get(subject, "L", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Antwerp",
                apr_hash_get(subject, "ST", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("BE",
                apr_hash_get(subject, "C", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("serfserver@example.com",
                apr_hash_get(subject, "E", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     return APR_SUCCESS;
 }
@@ -329,25 +329,25 @@ static apr_status_t validate_cacert(cons
     subject = serf_ssl_cert_subject(cert, pool);
     if (strcmp("Serf CA",
                apr_hash_get(subject, "CN", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Test Suite CA",
                apr_hash_get(subject, "OU", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("In Serf we trust, Inc.",
                apr_hash_get(subject, "O", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Mechelen",
                apr_hash_get(subject, "L", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Antwerp",
                apr_hash_get(subject, "ST", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("BE",
                apr_hash_get(subject, "C", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("serfca@example.com",
                apr_hash_get(subject, "E", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     return APR_SUCCESS;
 }
@@ -359,25 +359,25 @@ static apr_status_t validate_rootcacert(
     subject = serf_ssl_cert_subject(cert, pool);
     if (strcmp("Serf Root CA",
                apr_hash_get(subject, "CN", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Test Suite Root CA",
                apr_hash_get(subject, "OU", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("In Serf we trust, Inc.",
                apr_hash_get(subject, "O", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Mechelen",
                apr_hash_get(subject, "L", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Antwerp",
                apr_hash_get(subject, "ST", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("BE",
                apr_hash_get(subject, "C", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("serfrootca@example.com",
                apr_hash_get(subject, "E", APR_HASH_KEY_STRING)) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     return APR_SUCCESS;
 }
@@ -395,7 +395,7 @@ ssl_server_cert_cb_expect_failures(void
     if (failures & expected_failures)
         return APR_SUCCESS;
     else
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 }
 
 static apr_status_t
@@ -407,7 +407,7 @@ ssl_server_cert_cb_expect_allok(void *ba
 
     /* No error expected, certificate is valid. */
     if (failures)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     else
         return APR_SUCCESS;
 }
@@ -419,7 +419,7 @@ ssl_server_cert_cb_reject(void *baton, i
     test_baton_t *tb = baton;
     tb->result_flags |= TEST_RESULT_SERVERCERTCB_CALLED;
 
-    return SERF_ERROR_ISSUE_IN_TESTSUITE;
+    return REPORT_TEST_SUITE_ERROR();
 }
 
 /* Validate that we can connect successfully to an https server. This
@@ -630,10 +630,10 @@ cert_chain_cb(void *baton,
     tb->result_flags |= TEST_RESULT_SERVERCERTCHAINCB_CALLED;
 
     if (failures)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     if (certs_len != 3)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     status = validate_rootcacert(certs[2], tb->pool);
     if (status)
@@ -938,7 +938,7 @@ static apr_status_t client_cert_pw_cb(vo
         return APR_SUCCESS;
     }
 
-    return SERF_ERROR_ISSUE_IN_TESTSUITE;
+    return REPORT_TEST_SUITE_ERROR();
 }
 
 static apr_status_t
@@ -1141,7 +1141,7 @@ ssl_server_cert_cb_log_failures(void *ba
     failure_list = tb->user_baton;
 
     if (depth + 1 > failure_list->nalloc) {
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     }
 
     failures_for_depth = &APR_ARRAY_IDX(failure_list, depth, int);
@@ -1309,12 +1309,12 @@ ssltunnel_basic_authn_callback(char **us
     tb->result_flags |= TEST_RESULT_AUTHNCB_CALLED;
 
     if (strcmp("Basic", authn_type) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     if (code == 401) {
         if (strcmp(apr_psprintf(pool, "<%s> Test Suite", tb->serv_url),
                    realm) != 0)
-            return SERF_ERROR_ISSUE_IN_TESTSUITE;
+            return REPORT_TEST_SUITE_ERROR();
 
         *username = "serf";
         *password = "serftest";
@@ -1322,12 +1322,12 @@ ssltunnel_basic_authn_callback(char **us
     else if (code == 407) {
         if (strcmp(apr_psprintf(pool, "<http://localhost:%u> Test Suite Proxy",
                                 tb->proxy_port), realm) != 0)
-            return SERF_ERROR_ISSUE_IN_TESTSUITE;
+            return REPORT_TEST_SUITE_ERROR();
 
         *username = "serfproxy";
         *password = "serftest";
     } else
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     test__log(TEST_VERBOSE, __FILE__, "ssltunnel_basic_authn_callback finished successfully.\n");
 
@@ -1452,12 +1452,12 @@ basic_authn_callback_2ndtry(char **usern
     tb->result_flags |= TEST_RESULT_AUTHNCB_CALLED;
 
     if (strcmp("Basic", authn_type) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     if (code == 401) {
         if (strcmp(apr_psprintf(pool, "<%s> Test Suite", tb->serv_url),
                    realm) != 0)
-            return SERF_ERROR_ISSUE_IN_TESTSUITE;
+            return REPORT_TEST_SUITE_ERROR();
 
         *username = "serf";
         *password = secondtry ? "serftest" : "wrongpwd";
@@ -1465,12 +1465,12 @@ basic_authn_callback_2ndtry(char **usern
     else if (code == 407) {
         if (strcmp(apr_psprintf(pool, "<http://localhost:%u> Test Suite Proxy",
                                 tb->proxy_port), realm) != 0)
-            return SERF_ERROR_ISSUE_IN_TESTSUITE;
+            return REPORT_TEST_SUITE_ERROR();
 
         *username = "serfproxy";
         *password = secondtry ? "serftest" : "wrongpwd";
     } else
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     test__log(TEST_VERBOSE, __FILE__, "ssltunnel_basic_authn_callback finished successfully.\n");
 
@@ -1579,12 +1579,12 @@ proxy_digest_authn_callback(char **usern
     tb->result_flags |= TEST_RESULT_AUTHNCB_CALLED;
 
     if (code != 407)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp("Digest", authn_type) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
     if (strcmp(apr_psprintf(pool, "<http://localhost:%u> Test Suite Proxy",
                             tb->proxy_port), realm) != 0)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 
     *username = "serf";
     *password = "serftest";
@@ -1830,7 +1830,7 @@ static apr_status_t handle_response_set_
        Not passing the response will make the application think the response
        get cancelled, and it will requeue it. */
     if (!response)
-        return SERF_ERROR_ISSUE_IN_TESTSUITE;
+        return REPORT_TEST_SUITE_ERROR();
 #endif
 
     tb->result_flags |= TEST_RESULT_HANDLE_RESPONSECB_CALLED;
@@ -1901,7 +1901,7 @@ ocsp_response_cb_expect_failures(void *b
         return APR_SUCCESS;
     }
 
-    return SERF_ERROR_ISSUE_IN_TESTSUITE;
+    return REPORT_TEST_SUITE_ERROR();
 }
 
 static void test_ssl_ocsp_response_error_and_override(CuTest *tc)

Modified: serf/trunk/test/test_util.c
URL: http://svn.apache.org/viewvc/serf/trunk/test/test_util.c?rev=1700731&r1=1700730&r2=1700731&view=diff
==============================================================================
--- serf/trunk/test/test_util.c (original)
+++ serf/trunk/test/test_util.c Wed Sep  2 08:40:00 2015
@@ -406,7 +406,7 @@ apr_status_t dummy_authn_callback(char *
 
     tb->result_flags |= TEST_RESULT_AUTHNCB_CALLED;
 
-    return SERF_ERROR_ISSUE_IN_TESTSUITE;
+    return REPORT_TEST_SUITE_ERROR();
 }
 
 /*****************************************************************************/
@@ -521,7 +521,7 @@ run_client_and_mock_servers_loops(test_b
             return APR_ETIMEDOUT;
 
         if (err == MOCKHTTP_TEST_FAILED)
-            return SERF_ERROR_ISSUE_IN_TESTSUITE;
+            return REPORT_TEST_SUITE_ERROR();
     }
     apr_pool_destroy(iter_pool);
     
@@ -638,6 +638,13 @@ void *test_teardown(void *baton)
     return NULL;
 }
 
+apr_status_t test__report_suite_error(const char *filename, long line)
+{
+    test__log(TEST_VERBOSE, __FILE__, "Error in test suite at line %ld\n", line);
+
+    return SERF_ERROR_ISSUE_IN_TESTSUITE;
+}
+
 /*****************************************************************************/
 /* Logging functions                                                         */
 /*****************************************************************************/



Mime
View raw message