apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: rev 76137 - apr/apr-util/trunk/test
Date Wed, 17 Nov 2004 14:53:10 GMT
Author: jorton
Date: Wed Nov 17 06:53:09 2004
New Revision: 76137

Modified:
   apr/apr-util/trunk/test/testbuckets.c
Log:
Exercise apr_brigade_insert_file and file bucket seeking:

* test/testbuckets.c (make_test_file, test_manyfile): New functions.


Modified: apr/apr-util/trunk/test/testbuckets.c
==============================================================================
--- apr/apr-util/trunk/test/testbuckets.c	(original)
+++ apr/apr-util/trunk/test/testbuckets.c	Wed Nov 17 06:53:09 2004
@@ -333,6 +333,49 @@
     apr_file_remove(TIF_FNAME, p);
 }
 
+/* Make a test file named FNAME, and write CONTENTS to it. */
+static apr_file_t *make_test_file(abts_case *tc, const char *fname,
+                                  const char *contents)
+{
+    apr_file_t *f;
+
+    ABTS_ASSERT(tc, "create test file",
+                apr_file_open(&f, fname,
+                              APR_READ|APR_WRITE|APR_TRUNCATE|APR_CREATE,
+                              APR_OS_DEFAULT, p) == APR_SUCCESS);
+    
+    ABTS_ASSERT(tc, "write test file contents",
+                apr_file_puts(contents, f) == APR_SUCCESS);
+
+    return f;
+}
+
+static void test_manyfile(abts_case *tc, void *data)
+{
+    apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
+    apr_bucket_brigade *bb = apr_brigade_create(p, ba);
+    apr_file_t *f;
+
+    f = make_test_file(tc, "manyfile.bin",
+                       "world" "hello" "brave" " ,\n");
+
+    apr_brigade_insert_file(bb, f, 5, 5, p);
+    apr_brigade_insert_file(bb, f, 16, 1, p);
+    apr_brigade_insert_file(bb, f, 15, 1, p);
+    apr_brigade_insert_file(bb, f, 10, 5, p);
+    apr_brigade_insert_file(bb, f, 15, 1, p);
+    apr_brigade_insert_file(bb, f, 0, 5, p);
+    apr_brigade_insert_file(bb, f, 17, 1, p);
+
+    /* can you tell what it is yet? */
+    flatten_match(tc, "file seek test", bb,
+                  "hello, brave world\n");
+
+    apr_file_close(f);
+    apr_brigade_destroy(bb);
+    apr_bucket_alloc_destroy(ba);
+}
+
 abts_suite *testbuckets(abts_suite *suite)
 {
     suite = ADD_SUITE(suite);
@@ -345,6 +388,7 @@
     abts_run_test(suite, test_splitline, NULL);
     abts_run_test(suite, test_splits, NULL);
     abts_run_test(suite, test_insertfile, NULL);
+    abts_run_test(suite, test_manyfile, NULL);
 
     return suite;
 }

Mime
View raw message