本文整理匯總了C++中ABTS_ASSERT函數的典型用法代碼示例。如果您正苦於以下問題:C++ ABTS_ASSERT函數的具體用法?C++ ABTS_ASSERT怎麽用?C++ ABTS_ASSERT使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ABTS_ASSERT函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: test_partition
static void test_partition(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_bucket *e;
e = apr_bucket_immortal_create(hello, strlen(hello), ba);
APR_BRIGADE_INSERT_HEAD(bb, e);
apr_assert_success(tc, "partition brigade",
apr_brigade_partition(bb, 5, &e));
test_bucket_content(tc, APR_BRIGADE_FIRST(bb),
"hello", 5);
test_bucket_content(tc, APR_BRIGADE_LAST(bb),
", world", 7);
ABTS_ASSERT(tc, "partition returns APR_INCOMPLETE",
apr_brigade_partition(bb, 8192, &e));
ABTS_ASSERT(tc, "APR_INCOMPLETE partition returned sentinel",
e == APR_BRIGADE_SENTINEL(bb));
apr_brigade_destroy(bb);
apr_bucket_alloc_destroy(ba);
}
示例2: test_truncfile
/* Regression test for PR 34708, where a file bucket will keep
* duplicating itself on being read() when EOF is reached
* prematurely. */
static void test_truncfile(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 = make_test_file(tc, "testfile.txt", "hello");
apr_bucket *e;
const char *buf;
apr_size_t len;
apr_brigade_insert_file(bb, f, 0, 5, p);
apr_file_trunc(f, 0);
e = APR_BRIGADE_FIRST(bb);
ABTS_ASSERT(tc, "single bucket in brigade",
APR_BUCKET_NEXT(e) == APR_BRIGADE_SENTINEL(bb));
apr_bucket_file_enable_mmap(e, 0);
ABTS_ASSERT(tc, "read gave APR_EOF",
apr_bucket_read(e, &buf, &len, APR_BLOCK_READ) == APR_EOF);
ABTS_ASSERT(tc, "read length 0", len == 0);
ABTS_ASSERT(tc, "still a single bucket in brigade",
APR_BUCKET_NEXT(e) == APR_BRIGADE_SENTINEL(bb));
apr_file_close(f);
apr_brigade_destroy(bb);
apr_bucket_alloc_destroy(ba);
}
示例3: string_strfsize
static void string_strfsize(abts_case *tc, void *data)
{
static const struct {
apr_off_t size;
const char *buf;
} ts[] = {
{ -1, " - " },
{ 0, " 0 " },
{ 666, "666 " },
{ 1024, "1.0K" },
{ 1536, "1.5K" },
{ 2048, "2.0K" },
{ 1293874, "1.2M" },
{ 9999999, "9.5M" },
{ 103809024, " 99M" },
{ 1047527424, "1.0G" } /* "999M" would be more correct */
};
apr_size_t n;
for (n = 0; n < sizeof(ts)/sizeof(ts[0]); n++) {
char buf[6], *ret;
buf[5] = '%';
ret = apr_strfsize(ts[n].size, buf);
ABTS_ASSERT(tc, "strfsize returned wrong buffer", ret == buf);
ABTS_ASSERT(tc, "strfsize overflowed", buf[5] == '%');
ABTS_STR_EQUAL(tc, ts[n].buf, ret);
}
}
示例4: copy_helper
static void copy_helper(abts_case *tc, const char *from, const char * to,
apr_fileperms_t perms, int append, apr_pool_t *p)
{
apr_status_t rv;
apr_status_t dest_rv;
apr_finfo_t copy;
apr_finfo_t orig;
apr_finfo_t dest;
dest_rv = apr_stat(&dest, to, APR_FINFO_SIZE, p);
if (!append) {
rv = apr_file_copy(from, to, perms, p);
}
else {
rv = apr_file_append(from, to, perms, p);
}
APR_ASSERT_SUCCESS(tc, "Error copying file", rv);
rv = apr_stat(&orig, from, APR_FINFO_SIZE, p);
APR_ASSERT_SUCCESS(tc, "Couldn't stat original file", rv);
rv = apr_stat(©, to, APR_FINFO_SIZE, p);
APR_ASSERT_SUCCESS(tc, "Couldn't stat copy file", rv);
if (!append) {
ABTS_ASSERT(tc, "File size differs", orig.size == copy.size);
}
else {
ABTS_ASSERT(tc, "File size differs",
((dest_rv == APR_SUCCESS)
? dest.size : 0) + orig.size == copy.size);
}
}
示例5: apr_crypto_init
static const apr_crypto_driver_t *get_driver(abts_case *tc, apr_pool_t *pool,
const char *name, const apr_array_header_t *params) {
const apr_crypto_driver_t *driver = NULL;
const apu_err_t *err = NULL;
apr_status_t rv;
rv = apr_crypto_init(pool, params);
ABTS_ASSERT(tc, "failed to init apr_crypto", rv == APR_SUCCESS);
rv = apr_crypto_get_driver(pool, name, &driver, params, &err);
if (APR_SUCCESS != rv && err) {
ABTS_NOT_IMPL(tc, err->msg);
return NULL;
}
if (APR_ENOTIMPL == rv) {
ABTS_NOT_IMPL(tc, (char *)driver);
return NULL;
}
ABTS_ASSERT(tc, "failed to apr_crypto_get_driver", rv == APR_SUCCESS);
ABTS_ASSERT(tc, "apr_crypto_get_driver returned NULL", driver != NULL);
if (!driver || rv) {
return NULL;
}
return driver;
}
示例6: overflow_strfsize
/* random-ish checks for strfsize buffer overflows */
static void overflow_strfsize(abts_case *tc, void *data)
{
apr_off_t off;
char buf[7];
buf[5] = '$';
buf[6] = '@';
for (off = -9999; off < 20000; off++) {
apr_strfsize(off, buf);
}
for (; off < 9999999; off += 9) {
apr_strfsize(off, buf);
}
for (; off < 999999999; off += 999) {
apr_strfsize(off, buf);
}
for (off = 1; off < LONG_MAX && off > 0; off *= 2) {
apr_strfsize(off, buf);
apr_strfsize(off + 1, buf);
apr_strfsize(off - 1, buf);
}
ABTS_ASSERT(tc, "strfsize overflowed", buf[5] == '$');
ABTS_ASSERT(tc, "strfsize overflowed", buf[6] == '@');
}
示例7: test_dbd_sqlite3
static void test_dbd_sqlite3(abts_case *tc, void *data)
{
apr_pool_t *pool = p;
apr_status_t rv;
const apr_dbd_driver_t* driver = NULL;
apr_dbd_t* handle = NULL;
rv = apr_dbd_get_driver(pool, "sqlite3", &driver);
ABTS_ASSERT(tc, "failed to fetch sqlite3 driver", rv == APR_SUCCESS);
ABTS_PTR_NOTNULL(tc, driver);
if (!driver) {
return;
}
ABTS_STR_EQUAL(tc, "sqlite3", apr_dbd_name(driver));
rv = apr_dbd_open(driver, pool, "data/sqlite3.db", &handle);
ABTS_ASSERT(tc, "failed to open sqlite3 database", rv == APR_SUCCESS);
ABTS_PTR_NOTNULL(tc, handle);
if (!handle) {
return;
}
test_dbd_generic(tc, handle, driver);
}
示例8: test_dso_sym
static void test_dso_sym(abts_case *tc, void *data)
{
apr_dso_handle_t *h = NULL;
apr_dso_handle_sym_t func1 = NULL;
apr_status_t status;
void (*function)(char str[256]);
char teststr[256];
char errstr[256];
status = apr_dso_load(&h, modname, p);
ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status);
ABTS_PTR_NOTNULL(tc, h);
status = apr_dso_sym(&func1, h, "print_hello");
ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status);
ABTS_PTR_NOTNULL(tc, func1);
if (!tc->failed) {
function = (void (*)(char *))func1;
(*function)(teststr);
ABTS_STR_EQUAL(tc, "Hello - I'm a DSO!\n", teststr);
}
apr_dso_unload(h);
}
示例9: test_pipe_writefull
static void test_pipe_writefull(abts_case *tc, void *data)
{
int iterations = 1000;
int i;
int bytes_per_iteration = 8000;
char *buf = (char *)malloc(bytes_per_iteration);
char responsebuf[128];
apr_size_t nbytes;
int bytes_processed;
apr_proc_t proc = {0};
apr_procattr_t *procattr;
const char *args[2];
apr_status_t rv;
apr_exit_why_e why;
rv = apr_procattr_create(&procattr, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
rv = apr_procattr_io_set(procattr, APR_CHILD_BLOCK, APR_CHILD_BLOCK,
APR_CHILD_BLOCK);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
rv = apr_procattr_error_check_set(procattr, 1);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
args[0] = "readchild" EXTENSION;
args[1] = NULL;
rv = apr_proc_create(&proc, "./readchild" EXTENSION, args, NULL, procattr, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
rv = apr_file_pipe_timeout_set(proc.in, apr_time_from_sec(10));
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
rv = apr_file_pipe_timeout_set(proc.out, apr_time_from_sec(10));
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
i = iterations;
do {
rv = apr_file_write_full(proc.in, buf, bytes_per_iteration, NULL);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
} while (--i);
free(buf);
rv = apr_file_close(proc.in);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
nbytes = sizeof(responsebuf);
rv = apr_file_read(proc.out, responsebuf, &nbytes);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
bytes_processed = (int)apr_strtoi64(responsebuf, NULL, 10);
ABTS_INT_EQUAL(tc, iterations * bytes_per_iteration, bytes_processed);
ABTS_ASSERT(tc, "wait for child process",
apr_proc_wait(&proc, NULL, &why, APR_WAIT) == APR_CHILD_DONE);
ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT);
}
示例10: test_insertfile
static void test_insertfile(abts_case *tc, void *ctx)
{
apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
apr_bucket_brigade *bb;
const apr_off_t bignum = (APR_INT64_C(2) << 32) + 424242;
apr_off_t count;
apr_file_t *f;
apr_bucket *e;
ABTS_ASSERT(tc, "open test file",
apr_file_open(&f, TIF_FNAME,
APR_FOPEN_WRITE | APR_FOPEN_TRUNCATE
| APR_FOPEN_CREATE | APR_FOPEN_SPARSE,
APR_OS_DEFAULT, p) == APR_SUCCESS);
if (apr_file_trunc(f, bignum)) {
apr_file_close(f);
apr_file_remove(TIF_FNAME, p);
ABTS_NOT_IMPL(tc, "Skipped: could not create large file");
return;
}
bb = apr_brigade_create(p, ba);
e = apr_brigade_insert_file(bb, f, 0, bignum, p);
ABTS_ASSERT(tc, "inserted file was not at end of brigade",
e == APR_BRIGADE_LAST(bb));
/* check that the total size of inserted buckets is equal to the
* total size of the file. */
count = 0;
for (e = APR_BRIGADE_FIRST(bb);
e != APR_BRIGADE_SENTINEL(bb);
e = APR_BUCKET_NEXT(e)) {
ABTS_ASSERT(tc, "bucket size sane", e->length != (apr_size_t)-1);
count += e->length;
}
ABTS_ASSERT(tc, "total size of buckets incorrect", count == bignum);
apr_brigade_destroy(bb);
/* Truncate the file to zero size before close() so that we don't
* actually write out the large file if we are on a non-sparse file
* system - like Mac OS X's HFS. Otherwise, pity the poor user who
* has to wait for the 8GB file to be written to disk.
*/
apr_file_trunc(f, 0);
apr_file_close(f);
apr_bucket_alloc_destroy(ba);
apr_file_remove(TIF_FNAME, p);
}
示例11: wait_child
static int wait_child(abts_case *tc, apr_proc_t *proc)
{
int exitcode;
apr_exit_why_e why;
ABTS_ASSERT(tc, "Error waiting for child process",
apr_proc_wait(proc, &exitcode, &why, APR_WAIT) == APR_CHILD_DONE);
ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT);
return exitcode;
}
示例12: multi_event_pollset
static void multi_event_pollset(abts_case *tc, void *data)
{
apr_status_t rv;
apr_pollfd_t socket_pollfd;
int lrv;
const apr_pollfd_t *descs = NULL;
ABTS_PTR_NOTNULL(tc, s[0]);
socket_pollfd.desc_type = APR_POLL_SOCKET;
socket_pollfd.reqevents = APR_POLLIN | APR_POLLOUT;
socket_pollfd.desc.s = s[0];
socket_pollfd.client_data = s[0];
rv = apr_pollset_add(pollset, &socket_pollfd);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
send_msg(s, sa, 0, tc);
rv = apr_pollset_poll(pollset, -1, &lrv, &descs);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
if (lrv == 1) {
int ev = descs[0].rtnevents;
ABTS_PTR_EQUAL(tc, s[0], descs[0].desc.s);
ABTS_PTR_EQUAL(tc, s[0], descs[0].client_data);
ABTS_ASSERT(tc, "either or both of APR_POLLIN, APR_POLLOUT returned",
((ev & APR_POLLIN) != 0) || ((ev & APR_POLLOUT) != 0));
}
else if (lrv == 2) {
ABTS_PTR_EQUAL(tc, s[0], descs[0].desc.s);
ABTS_PTR_EQUAL(tc, s[0], descs[0].client_data);
ABTS_PTR_EQUAL(tc, s[0], descs[1].desc.s);
ABTS_PTR_EQUAL(tc, s[0], descs[1].client_data);
ABTS_ASSERT(tc, "returned events incorrect",
((descs[0].rtnevents | descs[1].rtnevents)
== (APR_POLLIN | APR_POLLOUT))
&& descs[0].rtnevents != descs[1].rtnevents);
}
else {
ABTS_ASSERT(tc, "either one or two events returned",
lrv == 1 || lrv == 2);
}
recv_msg(s, 0, p, tc);
rv = apr_pollset_poll(pollset, 0, &lrv, &descs);
ABTS_INT_EQUAL(tc, 0, APR_STATUS_IS_TIMEUP(rv));
ABTS_INT_EQUAL(tc, 1, lrv);
ABTS_PTR_EQUAL(tc, s[0], descs[0].desc.s);
ABTS_INT_EQUAL(tc, APR_POLLOUT, descs[0].rtnevents);
ABTS_PTR_EQUAL(tc, s[0], descs[0].client_data);
rv = apr_pollset_remove(pollset, &socket_pollfd);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}
示例13: string_strtoff
static void string_strtoff(abts_case *tc, void *data)
{
apr_off_t off;
ABTS_ASSERT(tc, "strtoff fails on out-of-range integer",
apr_strtoff(&off, "999999999999999999999999999999",
NULL, 10) != APR_SUCCESS);
ABTS_ASSERT(tc, "strtoff failed for 1234",
apr_strtoff(&off, "1234", NULL, 10) == APR_SUCCESS);
ABTS_ASSERT(tc, "strtoff failed to parse 1234", off == 1234);
}
示例14: launch_reader
static int launch_reader(abts_case *tc)
{
apr_proc_t proc = {0};
apr_procattr_t *procattr;
const char *args[2];
apr_status_t rv;
apr_exit_why_e why;
int exitcode;
rv = apr_procattr_create(&procattr, p);
APR_ASSERT_SUCCESS(tc, "Couldn't create procattr", rv);
rv = apr_procattr_io_set(procattr, APR_NO_PIPE, APR_NO_PIPE,
APR_NO_PIPE);
APR_ASSERT_SUCCESS(tc, "Couldn't set io in procattr", rv);
rv = apr_procattr_error_check_set(procattr, 1);
APR_ASSERT_SUCCESS(tc, "Couldn't set error check in procattr", rv);
args[0] = "tryread" EXTENSION;
args[1] = NULL;
rv = apr_proc_create(&proc, "./tryread" EXTENSION, args, NULL, procattr, p);
APR_ASSERT_SUCCESS(tc, "Couldn't launch program", rv);
ABTS_ASSERT(tc, "wait for child process",
apr_proc_wait(&proc, &exitcode, &why, APR_WAIT) == APR_CHILD_DONE);
ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT);
return exitcode;
}
示例15: test_file_trunc
static void test_file_trunc(abts_case *tc, void *data)
{
apr_status_t rv;
apr_file_t *f;
const char *fname = "data/testtruncate.dat";
const char *s;
apr_size_t nbytes;
apr_finfo_t finfo;
apr_file_remove(fname, p);
/* Test unbuffered */
rv = apr_file_open(&f, fname,
APR_FOPEN_CREATE | APR_FOPEN_READ |
APR_FOPEN_WRITE,
APR_FPROT_UREAD | APR_FPROT_UWRITE, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
s = "some data";
nbytes = strlen(s);
rv = apr_file_write(f, s, &nbytes);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_SIZE_EQUAL(tc, strlen(s), nbytes);
rv = apr_file_trunc(f, 4);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
rv = apr_file_close(f);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
rv = apr_stat(&finfo, fname, APR_FINFO_SIZE, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_ASSERT(tc, "File size mismatch, expected 4", finfo.size == 4);
rv = apr_file_remove(fname, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
/* Test buffered */
rv = apr_file_open(&f, fname,
APR_FOPEN_CREATE | APR_FOPEN_READ |
APR_FOPEN_WRITE | APR_FOPEN_BUFFERED,
APR_FPROT_UREAD | APR_FPROT_UWRITE, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
nbytes = strlen(s);
rv = apr_file_write(f, s, &nbytes);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_SIZE_EQUAL(tc, strlen(s), nbytes);
rv = apr_file_trunc(f, 4);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
rv = apr_file_close(f);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
rv = apr_stat(&finfo, fname, APR_FINFO_SIZE, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_ASSERT(tc, "File size mismatch, expected 4", finfo.size == 4);
rv = apr_file_remove(fname, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}