Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 8148 invoked by uid 500); 31 Jan 2003 23:53:20 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 8047 invoked from network); 31 Jan 2003 23:53:19 -0000 Date: 31 Jan 2003 23:53:18 -0000 Message-ID: <20030131235318.75749.qmail@icarus.apache.org> From: bnicholes@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/test testmmap.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bnicholes 2003/01/31 15:53:18 Modified: test testmmap.c Log: Clean up the test by making sure that the test string is consistent and that it only tests that valid memory portion. Revision Changes Path 1.42 +11 -4 apr/test/testmmap.c Index: testmmap.c =================================================================== RCS file: /home/cvs/apr/test/testmmap.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- testmmap.c 1 Jan 2003 00:01:56 -0000 1.41 +++ testmmap.c 31 Jan 2003 23:53:18 -0000 1.42 @@ -64,6 +64,7 @@ * 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(CuTest *tc) @@ -77,17 +78,20 @@ static apr_file_t *thefile = NULL; static char *file1; static apr_finfo_t finfo; +static int fsize; static void create_filename(CuTest *tc) { char *oldfileptr; apr_filepath_get(&file1, 0, p); +#ifndef NETWARE #ifdef WIN32 CuAssertTrue(tc, file1[1] == ':'); #else CuAssertTrue(tc, file1[0] == '/'); #endif +#endif CuAssertTrue(tc, file1[strlen(file1) - 1] != '/'); oldfileptr = file1; @@ -115,7 +119,6 @@ static void test_get_filesize(CuTest *tc) { apr_status_t rv; - int fsize = strlen("This is the MMAP data file."APR_EOL_STR); rv = apr_file_info_get(&finfo, APR_FINFO_NORM, thefile); CuAssertIntEquals(tc, rv, APR_SUCCESS); @@ -133,12 +136,13 @@ static void test_mmap_contents(CuTest *tc) { - int fsize = strlen("This is the MMAP data file."APR_EOL_STR); CuAssertPtrNotNull(tc, themmap); CuAssertPtrNotNull(tc, themmap->mm); CuAssertIntEquals(tc, fsize, themmap->size); - CuAssertStrEquals(tc, themmap->mm, "This is the MMAP data file."APR_EOL_STR); + + /* Must use nEquals since the string is not guaranteed to be NULL terminated */ + CuAssertStrNEquals(tc, themmap->mm, TEST_STRING, fsize); } static void test_mmap_delete(CuTest *tc) @@ -157,13 +161,16 @@ CuAssertPtrNotNull(tc, themmap); rv = apr_mmap_offset(&addr, themmap, 5); - CuAssertStrEquals(tc, addr, "This is the MMAP data file."APR_EOL_STR + 5); + + /* Must use nEquals since the string is not guaranteed to be NULL terminated */ + CuAssertStrNEquals(tc, addr, TEST_STRING + 5, fsize-5); } #endif CuSuite *testmmap(void) { CuSuite *suite = CuSuiteNew("MMAP"); + fsize = strlen(TEST_STRING); #if APR_HAS_MMAP SUITE_ADD_TEST(suite, create_filename);