You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by jo...@apache.org on 2024/08/20 14:42:08 UTC
svn commit: r1920067 - in /apr/apr/branches/1.7.x: ./ test/abts.c test/abts.h test/testdir.c test/testfile.c
Author: jorton
Date: Tue Aug 20 14:42:07 2024
New Revision: 1920067
URL: http://svn.apache.org/viewvc?rev=1920067&view=rev
Log:
Merge r1877439, r1877441, r1877443 from trunk:
Make test work with thread support disabled.
Added support for recording skipped test cases.
testdir: Following up to r1877439, make sure that the test data gets
populated correctly when threads are disabled.
Submitted by: brane
Reviewed by: jorton
Modified:
apr/apr/branches/1.7.x/ (props changed)
apr/apr/branches/1.7.x/test/abts.c
apr/apr/branches/1.7.x/test/abts.h
apr/apr/branches/1.7.x/test/testdir.c
apr/apr/branches/1.7.x/test/testfile.c
Propchange: apr/apr/branches/1.7.x/
------------------------------------------------------------------------------
Merged /apr/apr/trunk:r1877439,1877441,1877443
Modified: apr/apr/branches/1.7.x/test/abts.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/test/abts.c?rev=1920067&r1=1920066&r2=1920067&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/test/abts.c (original)
+++ apr/apr/branches/1.7.x/test/abts.c Tue Aug 20 14:42:07 2024
@@ -76,6 +76,10 @@ static void end_suite(abts_suite *suite)
fprintf(stdout, "\b");
fflush(stdout);
}
+ if (last->skipped > 0) {
+ fprintf(stdout, "SKIPPED %d of %d\n", last->skipped, last->num_test);
+ fflush(stdout);
+ }
if (last->failed == 0) {
fprintf(stdout, "SUCCESS\n");
fflush(stdout);
@@ -102,6 +106,7 @@ abts_suite *abts_add_suite(abts_suite *s
subsuite = malloc(sizeof(*subsuite));
subsuite->num_test = 0;
subsuite->failed = 0;
+ subsuite->skipped = 0;
subsuite->next = NULL;
/* suite_name_full may be an absolute path depending on __FILE__
* expansion */
@@ -178,6 +183,7 @@ void abts_run_test(abts_suite *ts, test_
ss = ts->tail;
tc.failed = 0;
+ tc.skipped = 0;
tc.suite = ss;
ss->num_test++;
@@ -188,11 +194,25 @@ void abts_run_test(abts_suite *ts, test_
if (tc.failed) {
ss->failed++;
}
+
+ if (tc.skipped) {
+ ss->skipped++;
+ }
+}
+
+static void report_summary(const char *kind_header,
+ const char *name_header,
+ const char *percent_header)
+{
+ fprintf(stdout, "%-15s\t\tTotal\t%s\t%s\n",
+ kind_header, name_header, percent_header);
+ fprintf(stdout, "===================================================\n");
}
static int report(abts_suite *suite)
{
- int count = 0;
+ int failed_count = 0;
+ int skipped_count = 0;
sub_suite *dptr;
if (suite && suite->tail &&!suite->tail->not_run) {
@@ -200,25 +220,46 @@ static int report(abts_suite *suite)
}
for (dptr = suite->head; dptr; dptr = dptr->next) {
- count += dptr->failed;
+ failed_count += dptr->failed;
+ }
+
+ for (dptr = suite->head; dptr; dptr = dptr->next) {
+ skipped_count += dptr->skipped;
}
if (list_tests) {
return 0;
}
- if (count == 0) {
+ /* Report skipped tests */
+ if (skipped_count > 0) {
+ dptr = suite->head;
+ report_summary("Skipped Tests", "Skip", "Skipped %");
+ while (dptr != NULL) {
+ if (dptr->skipped != 0) {
+ float percent = ((float)dptr->skipped / (float)dptr->num_test);
+ fprintf(stdout, "%-15s\t\t%5d\t%4d\t%8.2f%%\n", dptr->name,
+ dptr->num_test, dptr->skipped, percent * 100);
+ }
+ dptr = dptr->next;
+ }
+ }
+
+ if (failed_count == 0) {
printf("All tests passed.\n");
return 0;
}
+ /* Report failed tests */
dptr = suite->head;
- fprintf(stdout, "%-15s\t\tTotal\tFail\tFailed %%\n", "Failed Tests");
- fprintf(stdout, "===================================================\n");
+ if (skipped_count > 0) {
+ fprintf(stdout, "\n");
+ }
+ report_summary("Failed Tests", "Fail", " Failed %");
while (dptr != NULL) {
if (dptr->failed != 0) {
float percent = ((float)dptr->failed / (float)dptr->num_test);
- fprintf(stdout, "%-15s\t\t%5d\t%4d\t%6.2f%%\n", dptr->name,
+ fprintf(stdout, "%-15s\t\t%5d\t%4d\t%8.2f%%\n", dptr->name,
dptr->num_test, dptr->failed, percent * 100);
}
dptr = dptr->next;
@@ -358,7 +399,19 @@ void abts_fail(abts_case *tc, const char
fflush(stderr);
}
}
-
+
+void abts_skip(abts_case *tc, const char *message, int lineno)
+{
+ update_status();
+ if (tc->skipped) return;
+
+ tc->skipped = TRUE;
+ if (verbose) {
+ fprintf(stderr, "\bSKIP: Line %d: %s\n", lineno, message);
+ fflush(stderr);
+ }
+}
+
void abts_assert(abts_case *tc, const char *message, int condition, int lineno)
{
update_status();
Modified: apr/apr/branches/1.7.x/test/abts.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/test/abts.h?rev=1920067&r1=1920066&r2=1920067&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/test/abts.h (original)
+++ apr/apr/branches/1.7.x/test/abts.h Tue Aug 20 14:42:07 2024
@@ -42,6 +42,7 @@ struct sub_suite {
char *name;
int num_test;
int failed;
+ int skipped;
int not_run;
int not_impl;
struct sub_suite *next;
@@ -56,6 +57,7 @@ typedef struct abts_suite abts_suite;
struct abts_case {
int failed;
+ int skipped;
sub_suite *suite;
};
typedef struct abts_case abts_case;
@@ -99,6 +101,7 @@ void abts_ptr_notnull(abts_case *tc, con
void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno);
void abts_true(abts_case *tc, int condition, int lineno);
void abts_fail(abts_case *tc, const char *message, int lineno);
+void abts_skip(abts_case *tc, const char *message, int lineno);
void abts_not_impl(abts_case *tc, const char *message, int lineno);
void abts_assert(abts_case *tc, const char *message, int condition, int lineno);
@@ -127,6 +130,13 @@ void abts_assert(abts_case *tc, const ch
#define ABTS_ASSERT(a, b, c) abts_assert(a, b, c, __LINE__);
+/* When skipping tests, make a reference to the test data parameter
+ to avoid unused variable warnings. */
+#define ABTS_SKIP(tc, data, msg) do { \
+ ((void)(data)); \
+ abts_skip((tc), (msg), __LINE__); \
+ } while (0)
+
abts_suite *run_tests(abts_suite *suite);
abts_suite *run_tests1(abts_suite *suite);
Modified: apr/apr/branches/1.7.x/test/testdir.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/test/testdir.c?rev=1920067&r1=1920066&r2=1920067&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/test/testdir.c (original)
+++ apr/apr/branches/1.7.x/test/testdir.c Tue Aug 20 14:42:07 2024
@@ -60,43 +60,51 @@ static void test_mkdir_recurs(abts_case
ABTS_INT_EQUAL(tc, APR_DIR, finfo.filetype);
}
-struct thread_data
-{
- abts_case *tc;
- apr_pool_t *pool;
-};
-
-static void *APR_THREAD_FUNC thread_mkdir_func(apr_thread_t *thd, void *data)
+static void mkdir_func(abts_case *tc, apr_pool_t *pool)
{
- struct thread_data *td = data;
apr_status_t s1, s2, s3, s4, s5;
s1 = apr_dir_make_recursive("data/prll/one/thwo/three",
APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
- td->pool);
+ pool);
s2 = apr_dir_make_recursive("data/prll/four/five/six/seven/eight",
APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
- td->pool);
+ pool);
s3 = apr_dir_make_recursive("data/prll/nine/ten",
APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
- td->pool);
+ pool);
s4 = apr_dir_make_recursive("data/prll/11/12/13/14/15/16/17/18/19/20",
APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
- td->pool);
+ pool);
s5 = apr_dir_make_recursive("data/fortytwo",
APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
- td->pool);
+ pool);
- ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s1);
- ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s2);
- ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s3);
- ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s4);
- ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s5);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s1);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s2);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s3);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s4);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s5);
+}
+
+#if APR_HAS_THREADS
+struct thread_data
+{
+ abts_case *tc;
+ apr_pool_t *pool;
+};
+
+static void *APR_THREAD_FUNC thread_mkdir_func(apr_thread_t *thd, void *data)
+{
+ struct thread_data *td = data;
+ mkdir_func(td->tc, td->pool);
return NULL;
}
+#endif /* APR_HAS_THREADS */
static void test_mkdir_recurs_parallel(abts_case *tc, void *data)
{
+#if APR_HAS_THREADS
struct thread_data td1, td2, td3, td4;
apr_thread_t *t1, *t2, *t3, *t4;
apr_status_t s1, s2, s3, s4;
@@ -125,6 +133,11 @@ static void test_mkdir_recurs_parallel(a
ABTS_INT_EQUAL(tc, APR_SUCCESS, s2);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s3);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s4);
+#else
+ /* Create the test directories for test_removeall anwyay. */
+ mkdir_func(tc, p);
+ ABTS_SKIP(tc, data, "This test requires APR thread support.");
+#endif /* APR_HAS_THREADS */
}
static void test_remove(abts_case *tc, void *data)
Modified: apr/apr/branches/1.7.x/test/testfile.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/test/testfile.c?rev=1920067&r1=1920066&r2=1920067&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/test/testfile.c (original)
+++ apr/apr/branches/1.7.x/test/testfile.c Tue Aug 20 14:42:07 2024
@@ -1474,6 +1474,7 @@ static void test_datasync_on_stream(abts
}
}
+#if APR_HAS_THREADS
typedef struct thread_file_append_ctx_t {
apr_pool_t *pool;
const char *fname;
@@ -1542,9 +1543,11 @@ static void * APR_THREAD_FUNC thread_fil
return NULL;
}
+#endif /* APR_HAS_THREADS */
static void test_atomic_append(abts_case *tc, void *data)
{
+#if APR_HAS_THREADS
apr_status_t rv;
apr_status_t thread_rv;
apr_file_t *f;
@@ -1597,6 +1600,9 @@ static void test_atomic_append(abts_case
}
apr_file_remove(fname, p);
+#else
+ ABTS_SKIP(tc, data, "This test requires APR thread support.");
+#endif /* APR_HAS_THREADS */
}
static void test_append_locked(abts_case *tc, void *data)