Return-Path: X-Original-To: apmail-apr-commits-archive@www.apache.org Delivered-To: apmail-apr-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ED6DA109EA for ; Wed, 13 Nov 2013 19:25:36 +0000 (UTC) Received: (qmail 73333 invoked by uid 500); 13 Nov 2013 19:25:36 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 73299 invoked by uid 500); 13 Nov 2013 19:25:36 -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 73292 invoked by uid 99); 13 Nov 2013 19:25:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Nov 2013 19:25:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Wed, 13 Nov 2013 19:25:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 647E22388A9B; Wed, 13 Nov 2013 19:25:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1541666 - /apr/apr/trunk/test/testmmap.c Date: Wed, 13 Nov 2013 19:25:13 -0000 To: commits@apr.apache.org From: trawick@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131113192513.647E22388A9B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: trawick Date: Wed Nov 13 19:25:12 2013 New Revision: 1541666 URL: http://svn.apache.org/r1541666 Log: Read the contents of the test datafile instead of hard-coding it in the source and relying on the line ending in the datafile to be the same as APR_EOL_STR. (Or, allow building and testing on Windows and Unix using the same release tarball.) Modified: apr/apr/trunk/test/testmmap.c Modified: apr/apr/trunk/test/testmmap.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testmmap.c?rev=1541666&r1=1541665&r2=1541666&view=diff ============================================================================== --- apr/apr/trunk/test/testmmap.c (original) +++ apr/apr/trunk/test/testmmap.c Wed Nov 13 19:25:12 2013 @@ -26,7 +26,6 @@ * length on a platform? */ #define PATH_LEN 255 -#define TEST_STRING "This is the MMAP data file."APR_EOL_STR #if !APR_HAS_MMAP static void not_implemented(abts_case *tc, void *data) @@ -36,6 +35,7 @@ static void not_implemented(abts_case *t #else +static char test_string[256]; /* read from the datafile */ static apr_mmap_t *themmap = NULL; static apr_file_t *thefile = NULL; static char *file1; @@ -69,6 +69,17 @@ static void test_file_close(abts_case *t ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } +static void read_expected_contents(abts_case *tc, void *data) +{ + apr_status_t rv; + apr_size_t nbytes = sizeof(test_string) - 1; + + rv = apr_file_read(thefile, test_string, &nbytes); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + test_string[nbytes] = '\0'; + thisfsize = strlen(test_string); +} + static void test_file_open(abts_case *tc, void *data) { apr_status_t rv; @@ -105,7 +116,7 @@ static void test_mmap_contents(abts_case ABTS_SIZE_EQUAL(tc, thisfsize, themmap->size); /* Must use nEquals since the string is not guaranteed to be NULL terminated */ - ABTS_STR_NEQUAL(tc, themmap->mm, TEST_STRING, thisfsize); + ABTS_STR_NEQUAL(tc, themmap->mm, test_string, thisfsize); } static void test_mmap_delete(abts_case *tc, void *data) @@ -127,7 +138,7 @@ static void test_mmap_offset(abts_case * ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* Must use nEquals since the string is not guaranteed to be NULL terminated */ - ABTS_STR_NEQUAL(tc, addr, TEST_STRING + 5, thisfsize-5); + ABTS_STR_NEQUAL(tc, addr, test_string + 5, thisfsize-5); } #endif @@ -136,10 +147,9 @@ abts_suite *testmmap(abts_suite *suite) suite = ADD_SUITE(suite) #if APR_HAS_MMAP - thisfsize = strlen(TEST_STRING); - abts_run_test(suite, create_filename, NULL); abts_run_test(suite, test_file_open, NULL); + abts_run_test(suite, read_expected_contents, NULL); abts_run_test(suite, test_get_filesize, NULL); abts_run_test(suite, test_mmap_create, NULL); abts_run_test(suite, test_mmap_contents, NULL);