apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1541673 - in /apr/apr/branches/1.5.x: ./ test/testmmap.c
Date Wed, 13 Nov 2013 19:39:34 GMT
Author: trawick
Date: Wed Nov 13 19:39:34 2013
New Revision: 1541673

URL: http://svn.apache.org/r1541673
Log:
Merge r1541655 and 1541666 from trunk:

Fix message when !APR_HAS_MMAP

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/branches/1.5.x/   (props changed)
    apr/apr/branches/1.5.x/test/testmmap.c

Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1541655,1541666

Modified: apr/apr/branches/1.5.x/test/testmmap.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/test/testmmap.c?rev=1541673&r1=1541672&r2=1541673&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/test/testmmap.c (original)
+++ apr/apr/branches/1.5.x/test/testmmap.c Wed Nov 13 19:39:34 2013
@@ -26,16 +26,16 @@
  * 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)
 {
-    ABTS_NOT_IMPL(tc, "User functions");
+    ABTS_NOT_IMPL(tc, "MMAP functions");
 }
 
 #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);



Mime
View raw message