summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2005-08-22 19:12:59 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2005-08-22 19:12:59 +0000
commit14114958380ce1be33b1e3a5111e4baa862fc4ee (patch)
treec95040d3a4c348d05e683d647953f9cdb07ee78d /test
parentdb0e54cd3ed6dfd85a1a2596a8e268d91f83a61d (diff)
downloadlibapr-14114958380ce1be33b1e3a5111e4baa862fc4ee.tar.gz
* file_io/unix/readwrite.c (apr_file_read, apr_file_gets): Handle the
apr_file_flush() return value when flushing buffered writes. * test/testfile.c (test_fail_read_flush): Add test case. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@239221 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/testfile.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/testfile.c b/test/testfile.c
index 47f61d521..9da6a6710 100644
--- a/test/testfile.c
+++ b/test/testfile.c
@@ -734,6 +734,42 @@ static void test_fail_write_flush(abts_case *tc, void *data)
apr_file_close(f);
}
+static void test_fail_read_flush(abts_case *tc, void *data)
+{
+ apr_file_t *f;
+ const char *fname = "data/testflush.dat";
+ apr_status_t rv;
+ char buf[2];
+
+ apr_file_remove(fname, p);
+
+ APR_ASSERT_SUCCESS(tc, "open test file",
+ apr_file_open(&f, fname,
+ APR_CREATE|APR_READ|APR_BUFFERED,
+ APR_UREAD|APR_UWRITE, p));
+
+ /* this write should be buffered. */
+ APR_ASSERT_SUCCESS(tc, "buffered write should succeed",
+ apr_file_puts("hello", f));
+
+ /* Now, trying a read should fail since the write must be flushed,
+ * and should fail with something other than EOF since the file is
+ * opened read-only. */
+ rv = apr_file_read_full(f, buf, 2, NULL);
+
+ ABTS_ASSERT(tc, "read should flush buffered write and fail",
+ rv != APR_SUCCESS && rv != APR_EOF);
+
+ /* Likewise for gets */
+ rv = apr_file_gets(buf, 2, f);
+
+ ABTS_ASSERT(tc, "gets should flush buffered write and fail",
+ rv != APR_SUCCESS && rv != APR_EOF);
+
+ apr_file_close(f);
+}
+
+
abts_suite *testfile(abts_suite *suite)
{
suite = ADD_SUITE(suite)
@@ -765,6 +801,7 @@ abts_suite *testfile(abts_suite *suite)
abts_run_test(suite, test_truncate, NULL);
abts_run_test(suite, test_bigfprintf, NULL);
abts_run_test(suite, test_fail_write_flush, NULL);
+ abts_run_test(suite, test_fail_read_flush, NULL);
return suite;
}