You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by iv...@apache.org on 2022/06/20 21:57:13 UTC
svn commit: r1902120 - in /apr/apr/branches/1.8.x: ./ test/testfile.c
Author: ivan
Date: Mon Jun 20 21:57:13 2022
New Revision: 1902120
URL: http://svn.apache.org/viewvc?rev=1902120&view=rev
Log:
On 1.8.x branch: Merge r1770471, r1770489 from trunk:
r1770471: Add test for apr_file_open(APR_FOPEN_APPEND).
r1770489: Follow-up to r1770471: resolve two compiler warnings in
testfile.c.
Modified:
apr/apr/branches/1.8.x/ (props changed)
apr/apr/branches/1.8.x/test/testfile.c
Propchange: apr/apr/branches/1.8.x/
------------------------------------------------------------------------------
Merged /apr/apr/trunk:r1770471,1770489
Modified: apr/apr/branches/1.8.x/test/testfile.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/test/testfile.c?rev=1902120&r1=1902119&r2=1902120&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/test/testfile.c (original)
+++ apr/apr/branches/1.8.x/test/testfile.c Mon Jun 20 21:57:13 2022
@@ -1254,6 +1254,74 @@ static void test_datasync_on_stream(abts
ABTS_TRUE(tc, rv == APR_SUCCESS || APR_STATUS_IS_EINVAL(rv));
}
+static void test_append(abts_case *tc, void *data)
+{
+ apr_file_t *f1;
+ apr_file_t *f2;
+ const char *fname = "data/testappend.dat";
+ apr_int32_t flags = APR_FOPEN_CREATE | APR_FOPEN_READ | APR_FOPEN_WRITE | APR_FOPEN_APPEND;
+ char buf[128];
+ apr_off_t offset;
+
+ apr_file_remove(fname, p);
+
+ /* Open test file with APR_FOPEN_APPEND, but without APR_FOPEN_XTHREAD. */
+ APR_ASSERT_SUCCESS(tc, "open test file",
+ apr_file_open(&f1, fname, flags, APR_FPROT_OS_DEFAULT, p));
+
+ /* Open test file with APR_FOPEN_APPEND and APR_FOPEN_XTHREAD. */
+ APR_ASSERT_SUCCESS(tc, "open test file",
+ apr_file_open(&f2, fname, flags | APR_FOPEN_XTHREAD, APR_FPROT_OS_DEFAULT, p));
+
+ APR_ASSERT_SUCCESS(tc, "write should succeed",
+ apr_file_puts("w1", f1));
+ offset = 0;
+ APR_ASSERT_SUCCESS(tc, "seek should succeed",
+ apr_file_seek(f1, APR_CUR, &offset));
+ ABTS_INT_EQUAL(tc, 2, (int) offset);
+
+ APR_ASSERT_SUCCESS(tc, "write should succeed",
+ apr_file_puts("w2", f2));
+ offset = 0;
+ APR_ASSERT_SUCCESS(tc, "seek should succeed",
+ apr_file_seek(f2, APR_CUR, &offset));
+ ABTS_INT_EQUAL(tc, 4, (int) offset);
+
+ APR_ASSERT_SUCCESS(tc, "write should succeed",
+ apr_file_puts("w3", f1));
+ offset = 0;
+ APR_ASSERT_SUCCESS(tc, "seek should succeed",
+ apr_file_seek(f1, APR_CUR, &offset));
+ ABTS_INT_EQUAL(tc, 6, (int) offset);
+
+ APR_ASSERT_SUCCESS(tc, "write should succeed",
+ apr_file_puts("w4", f2));
+
+ offset = 0;
+ APR_ASSERT_SUCCESS(tc, "seek should succeed",
+ apr_file_seek(f2, APR_CUR, &offset));
+ ABTS_INT_EQUAL(tc, 8, (int) offset);
+
+ /* Check file content file using F1. */
+ offset = 0;
+ APR_ASSERT_SUCCESS(tc, "seek should succeed",
+ apr_file_seek(f1, APR_SET, &offset));
+ memset(buf, 0, sizeof(buf));
+ apr_file_read_full(f1, buf, sizeof(buf), NULL);
+ ABTS_STR_EQUAL(tc, "w1w2w3w4", buf);
+
+ /* Check file content file using F2. */
+ offset = 0;
+ APR_ASSERT_SUCCESS(tc, "seek should succeed",
+ apr_file_seek(f2, APR_SET, &offset));
+ memset(buf, 0, sizeof(buf));
+ apr_file_read_full(f2, buf, sizeof(buf), NULL);
+ ABTS_STR_EQUAL(tc, "w1w2w3w4", buf);
+
+ apr_file_close(f1);
+ apr_file_close(f2);
+}
+
abts_suite *testfile(abts_suite *suite)
{
suite = ADD_SUITE(suite)
@@ -1298,8 +1366,7 @@ abts_suite *testfile(abts_suite *suite)
abts_run_test(suite, test_fail_read_flush, NULL);
abts_run_test(suite, test_buffer_set_get, NULL);
abts_run_test(suite, test_xthread, NULL);
- abts_run_test(suite, test_datasync_on_file, NULL);
- abts_run_test(suite, test_datasync_on_stream, NULL);
+ abts_run_test(suite, test_append, NULL);
return suite;
}
Re: svn commit: r1902120 - in /apr/apr/branches/1.8.x: ./ test/testfile.c
Posted by Ivan Zhakov via dev <de...@apr.apache.org>.
On Tue, 21 Jun 2022 at 17:57, Yann Ylavic <yl...@gmail.com> wrote:
> On Mon, Jun 20, 2022 at 11:57 PM <iv...@apache.org> wrote:
> >
> > Author: ivan
> > Date: Mon Jun 20 21:57:13 2022
> > New Revision: 1902120
> >
> > URL: http://svn.apache.org/viewvc?rev=1902120&view=rev
> >
> []
> > --- apr/apr/branches/1.8.x/test/testfile.c (original)
> > +++ apr/apr/branches/1.8.x/test/testfile.c Mon Jun 20 21:57:13 2022
> []
> > @@ -1298,8 +1366,7 @@ abts_suite *testfile(abts_suite *suite)
> > abts_run_test(suite, test_fail_read_flush, NULL);
> > abts_run_test(suite, test_buffer_set_get, NULL);
> > abts_run_test(suite, test_xthread, NULL);
> > - abts_run_test(suite, test_datasync_on_file, NULL);
> > - abts_run_test(suite, test_datasync_on_stream, NULL);
>
> Were these two removed intentionally? This causes the below warnings
> at least currently:
>
> testfile.c:1243:13: error: ‘test_datasync_on_stream’ defined but not
> used [-Werror=unused-function]
> testfile.c:1222:13: error: ‘test_datasync_on_file’ defined but not
> used [-Werror=unused-function]
>
> Hi Yann,
No, this change is unintentional. Just incorrect conflict resolution.
Should be fixed in r1902145.
--
Ivan Zhakov
Re: svn commit: r1902120 - in /apr/apr/branches/1.8.x: ./ test/testfile.c
Posted by Yann Ylavic <yl...@gmail.com>.
On Mon, Jun 20, 2022 at 11:57 PM <iv...@apache.org> wrote:
>
> Author: ivan
> Date: Mon Jun 20 21:57:13 2022
> New Revision: 1902120
>
> URL: http://svn.apache.org/viewvc?rev=1902120&view=rev
>
[]
> --- apr/apr/branches/1.8.x/test/testfile.c (original)
> +++ apr/apr/branches/1.8.x/test/testfile.c Mon Jun 20 21:57:13 2022
[]
> @@ -1298,8 +1366,7 @@ abts_suite *testfile(abts_suite *suite)
> abts_run_test(suite, test_fail_read_flush, NULL);
> abts_run_test(suite, test_buffer_set_get, NULL);
> abts_run_test(suite, test_xthread, NULL);
> - abts_run_test(suite, test_datasync_on_file, NULL);
> - abts_run_test(suite, test_datasync_on_stream, NULL);
Were these two removed intentionally? This causes the below warnings
at least currently:
testfile.c:1243:13: error: ‘test_datasync_on_stream’ defined but not
used [-Werror=unused-function]
testfile.c:1222:13: error: ‘test_datasync_on_file’ defined but not
used [-Werror=unused-function]
> + abts_run_test(suite, test_append, NULL);
>
> return suite;
> }
Regards;
Yann.