Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 75808 invoked from network); 17 May 2009 15:56:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 May 2009 15:56:45 -0000 Received: (qmail 82919 invoked by uid 500); 17 May 2009 15:56:45 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 82843 invoked by uid 500); 17 May 2009 15:56:44 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 82834 invoked by uid 99); 17 May 2009 15:56:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 May 2009 15:56:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 May 2009 15:56:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E57BA23888DD; Sun, 17 May 2009 15:56:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r775682 - in /apr/apr/trunk/test: Makefile.in abts_tests.h testhooks.c testutil.h Date: Sun, 17 May 2009 15:56:15 -0000 To: commits@apr.apache.org From: trawick@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090517155615.E57BA23888DD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: trawick Date: Sun May 17 15:56:15 2009 New Revision: 775682 URL: http://svn.apache.org/viewvc?rev=775682&view=rev Log: start a test bucket for apr hooks note that a failing assertion for an interesting predecessor issue is commented out for now Added: apr/apr/trunk/test/testhooks.c (with props) Modified: apr/apr/trunk/test/Makefile.in apr/apr/trunk/test/abts_tests.h apr/apr/trunk/test/testutil.h Modified: apr/apr/trunk/test/Makefile.in URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/Makefile.in?rev=775682&r1=775681&r2=775682&view=diff ============================================================================== --- apr/apr/trunk/test/Makefile.in (original) +++ apr/apr/trunk/test/Makefile.in Sun May 17 15:56:15 2009 @@ -34,7 +34,7 @@ testxlate.lo testdbd.lo testrmm.lo testldap.lo testmd4.lo \ teststrmatch.lo testpass.lo testcrypto.lo testqueue.lo \ testbuckets.lo testxml.lo testdbm.lo testuuid.lo testmd5.lo \ - testreslist.lo testbase64.lo + testreslist.lo testbase64.lo testhooks.lo OTHER_PROGRAMS = \ sendfile@EXEEXT@ \ Modified: apr/apr/trunk/test/abts_tests.h URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/abts_tests.h?rev=775682&r1=775681&r2=775682&view=diff ============================================================================== --- apr/apr/trunk/test/abts_tests.h (original) +++ apr/apr/trunk/test/abts_tests.h Sun May 17 15:56:15 2009 @@ -39,6 +39,7 @@ {testglobalmutex}, #endif {testhash}, + {testhooks}, {testipsub}, {testlock}, {testcond}, Added: apr/apr/trunk/test/testhooks.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testhooks.c?rev=775682&view=auto ============================================================================== --- apr/apr/trunk/test/testhooks.c (added) +++ apr/apr/trunk/test/testhooks.c Sun May 17 15:56:15 2009 @@ -0,0 +1,123 @@ +/* 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 "abts.h" +#include "testutil.h" +#include "apr_hooks.h" + +#define TEST_DECLARE(type) type + +APR_DECLARE_EXTERNAL_HOOK(test,TEST,int, toyhook, (char *x, apr_size_t s)) + +APR_HOOK_STRUCT( + APR_HOOK_LINK(toyhook) +) + +APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(test,TEST,int, toyhook, + (char *x, apr_size_t s), (x, s), 0, -1) + +static void safe_concat(char *buf, apr_size_t buf_size, const char *append) +{ + if (strlen(buf) + strlen(append) + 1 <= buf_size) { + strcat(buf, append); + } +} + +static int toyhook_1(char *x, apr_size_t buf_size) +{ + safe_concat(x, buf_size, "1"); + return 0; +} + +static int toyhook_2(char *x, apr_size_t buf_size) +{ + safe_concat(x, buf_size, "2"); + return 0; +} + +static int toyhook_3(char *x, apr_size_t buf_size) +{ + safe_concat(x, buf_size, "3"); + return 0; +} + +static int toyhook_4(char *x, apr_size_t buf_size) +{ + safe_concat(x, buf_size, "4"); + return 0; +} + +static int toyhook_5(char *x, apr_size_t buf_size) +{ + safe_concat(x, buf_size, "5"); + return 0; +} + +static void test_basic_ordering(abts_case *tc, void *data) +{ + char buf[6] = {0}; + + apr_hook_global_pool = p; + apr_hook_deregister_all(); + + apr_hook_debug_current = "foo"; + test_hook_toyhook(toyhook_5, NULL, NULL, APR_HOOK_MIDDLE + 2); + test_hook_toyhook(toyhook_1, NULL, NULL, APR_HOOK_MIDDLE - 2); + test_hook_toyhook(toyhook_3, NULL, NULL, APR_HOOK_MIDDLE); + test_hook_toyhook(toyhook_2, NULL, NULL, APR_HOOK_MIDDLE - 1); + test_hook_toyhook(toyhook_4, NULL, NULL, APR_HOOK_MIDDLE + 1); + + apr_hook_sort_all(); + + test_run_toyhook(buf, sizeof buf); + + ABTS_STR_EQUAL(tc, "12345", buf); +} + +static void test_pred_ordering(abts_case *tc, void *data) +{ + char buf[10] = {0}; + static const char *hook2_predecessors[] = {"1", NULL}; + static const char *hook3_predecessors[] = {"2", NULL}; + + apr_hook_global_pool = p; + apr_hook_deregister_all(); + + apr_hook_debug_current = "1"; + test_hook_toyhook(toyhook_1, NULL, NULL, APR_HOOK_MIDDLE); + apr_hook_debug_current = "3"; + test_hook_toyhook(toyhook_3, hook3_predecessors, NULL, APR_HOOK_MIDDLE); + apr_hook_debug_current = "2"; + test_hook_toyhook(toyhook_2, hook2_predecessors, NULL, APR_HOOK_MIDDLE); + apr_hook_debug_current = "2"; + test_hook_toyhook(toyhook_2, hook2_predecessors, NULL, APR_HOOK_MIDDLE); + + apr_hook_sort_all(); + + test_run_toyhook(buf, sizeof buf); + + /* FAILS ABTS_STR_EQUAL(tc, "1223", buf); */ +} + +abts_suite *testhooks(abts_suite *suite) +{ + suite = ADD_SUITE(suite); + + abts_run_test(suite, test_basic_ordering, NULL); + abts_run_test(suite, test_pred_ordering, NULL); + + return suite; +} Propchange: apr/apr/trunk/test/testhooks.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: apr/apr/trunk/test/testutil.h URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testutil.h?rev=775682&r1=775681&r2=775682&view=diff ============================================================================== --- apr/apr/trunk/test/testutil.h (original) +++ apr/apr/trunk/test/testutil.h Sun May 17 15:56:15 2009 @@ -74,6 +74,7 @@ abts_suite *testgetopt(abts_suite *suite); abts_suite *testglobalmutex(abts_suite *suite); abts_suite *testhash(abts_suite *suite); +abts_suite *testhooks(abts_suite *suite); abts_suite *testipsub(abts_suite *suite); abts_suite *testlock(abts_suite *suite); abts_suite *testcond(abts_suite *suite);