Skip to content

Commit

Permalink
Add test to try triggering UBSan
Browse files Browse the repository at this point in the history
  • Loading branch information
notroj committed Dec 18, 2023
1 parent eebff82 commit 89559a8
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/testbuckets.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,36 @@ static void test_splitline(abts_case *tc, void *data)
apr_bucket_alloc_destroy(ba);
}

static void test_splitline_eos(abts_case *tc, void *data)
{
apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
apr_bucket_brigade *bin, *bout;
apr_bucket *eos = apr_bucket_eos_create(ba);

bin = make_simple_brigade(ba, "blah blah\n",
"foo foo");
APR_BRIGADE_INSERT_TAIL(bin, eos);

bout = apr_brigade_create(p, ba);

APR_ASSERT_SUCCESS(tc, "split line eos #1",
apr_brigade_split_line(bout, bin,
APR_BLOCK_READ, 100));

flatten_match(tc, "split line eos", bout, "blah blah\n");

apr_brigade_cleanup(bout);
APR_ASSERT_SUCCESS(tc, "split line eos #2",
apr_brigade_split_line(bout, bin,
APR_BLOCK_READ, 100));

flatten_match(tc, "split line eos", bout, "foo foo");

apr_brigade_destroy(bout);
apr_brigade_destroy(bin);
apr_bucket_alloc_destroy(ba);
}

static void test_splitboundary(abts_case *tc, void *data)
{
apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
Expand Down Expand Up @@ -559,6 +589,9 @@ static void test_write_putstrs(abts_case *tc, void *data)
apr_brigade_putstrs(bb, NULL, NULL, "2", "34", "567", "8", "9a", "bcd",
"e", "f", "gh", "i", NULL);
apr_brigade_putstrs(bb, NULL, NULL, "j", NULL);
e = apr_bucket_eos_create(ba);
APR_BRIGADE_INSERT_HEAD(bb, e);

APR_ASSERT_SUCCESS(tc, "apr_brigade_flatten",
apr_brigade_flatten(bb, buf, &len));
ABTS_STR_NEQUAL(tc, expect, buf, strlen(expect));
Expand All @@ -577,6 +610,7 @@ abts_suite *testbuckets(abts_suite *suite)
abts_run_test(suite, test_split, NULL);
abts_run_test(suite, test_bwrite, NULL);
abts_run_test(suite, test_splitline, NULL);
abts_run_test(suite, test_splitline_eos, NULL);
abts_run_test(suite, test_splitboundary, NULL);
abts_run_test(suite, test_splits, NULL);
abts_run_test(suite, test_insertfile, NULL);
Expand Down

0 comments on commit 89559a8

Please sign in to comment.