本文整理汇总了C++中ABTS_PTR_NOTNULL函数的典型用法代码示例。如果您正苦于以下问题:C++ ABTS_PTR_NOTNULL函数的具体用法?C++ ABTS_PTR_NOTNULL怎么用?C++ ABTS_PTR_NOTNULL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ABTS_PTR_NOTNULL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_write_notimeout
static void read_write_notimeout(abts_case *tc, void *data)
{
apr_status_t rv;
char *buf = "this is a test";
char *input;
apr_size_t nbytes;
nbytes = strlen("this is a test");
rv = apr_file_pipe_create(&readp, &writep, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, readp);
ABTS_PTR_NOTNULL(tc, writep);
rv = apr_file_write(writep, buf, &nbytes);
ABTS_INT_EQUAL(tc, strlen("this is a test"), nbytes);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
nbytes = 256;
input = apr_pcalloc(p, nbytes + 1);
rv = apr_file_read(readp, input, &nbytes);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_INT_EQUAL(tc, strlen("this is a test"), nbytes);
ABTS_STR_EQUAL(tc, "this is a test", input);
}
示例2: broadcast_threads
static void broadcast_threads(abts_case *tc, void *data)
{
toolbox_t box;
unsigned int i;
apr_status_t rv;
apr_uint32_t count = 0;
apr_thread_cond_t *cond = NULL;
apr_thread_mutex_t *mutex = NULL;
apr_thread_t *thread[NTHREADS];
rv = apr_thread_cond_create(&cond, p);
ABTS_SUCCESS(rv);
ABTS_PTR_NOTNULL(tc, cond);
rv = apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_DEFAULT, p);
ABTS_SUCCESS(rv);
ABTS_PTR_NOTNULL(tc, mutex);
rv = apr_thread_mutex_lock(mutex);
ABTS_SUCCESS(rv);
box.tc = tc;
box.data = &count;
box.mutex = mutex;
box.cond = cond;
box.func = lock_and_wait;
for (i = 0; i < NTHREADS; i++) {
rv = apr_thread_create(&thread[i], NULL, thread_routine, &box, p);
ABTS_SUCCESS(rv);
}
do {
rv = apr_thread_mutex_unlock(mutex);
ABTS_SUCCESS(rv);
apr_sleep(100000);
rv = apr_thread_mutex_lock(mutex);
ABTS_SUCCESS(rv);
} while (apr_atomic_read32(&count) != NTHREADS);
rv = apr_thread_cond_broadcast(cond);
ABTS_SUCCESS(rv);
rv = apr_thread_mutex_unlock(mutex);
ABTS_SUCCESS(rv);
for (i = 0; i < NTHREADS; i++) {
apr_status_t retval;
rv = apr_thread_join(&retval, thread[i]);
ABTS_SUCCESS(rv);
}
ABTS_INT_EQUAL(tc, 0, count);
rv = apr_thread_cond_destroy(cond);
ABTS_SUCCESS(rv);
rv = apr_thread_mutex_destroy(mutex);
ABTS_SUCCESS(rv);
}
示例3: merge_lowercasedrive
static void merge_lowercasedrive(abts_case *tc, void *data)
{
char current_dir[1024];
char current_dir_on_C[1024];
char *dir_on_c;
char *testdir;
apr_status_t rv;
/* Change the current directory on C: from something like "C:\dir"
to something like "c:\dir" to replicate the failing case. */
ABTS_PTR_NOTNULL(tc, _getcwd(current_dir, sizeof(current_dir)));
/* 3 stands for drive C: */
ABTS_PTR_NOTNULL(tc, _getdcwd(3, current_dir_on_C,
sizeof(current_dir_on_C)));
/* Use the same path, but now with a lower case driveletter */
dir_on_c = apr_pstrdup(p, current_dir_on_C);
dir_on_c[0] = (char)tolower(dir_on_c[0]);
chdir(dir_on_c);
/* Now merge a drive relative path with an upper case drive letter. */
rv = apr_filepath_merge(&testdir, NULL, "C:hi",
APR_FILEPATH_NOTRELATIVE, p);
/* Change back to original directory for next tests */
chdir("C:\\"); /* Switch to upper case */
chdir(current_dir_on_C); /* Switch cwd on C: */
chdir(current_dir); /* Switch back to original cwd */
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}
示例4: test_dup2
static void test_dup2(abts_case *tc, void *data)
{
apr_file_t *testfile = NULL;
apr_file_t *errfile = NULL;
apr_file_t *saveerr = NULL;
apr_status_t rv;
rv = apr_file_open(&testfile, FILEPATH "testdup2.file",
APR_FOPEN_READ | APR_FOPEN_WRITE | APR_FOPEN_CREATE |
APR_FOPEN_DELONCLOSE, APR_OS_DEFAULT, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, testfile);
rv = apr_file_open_stderr(&errfile, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
/* Set aside the real errfile */
rv = apr_file_dup(&saveerr, errfile, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, saveerr);
rv = apr_file_dup2(errfile, testfile, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, errfile);
apr_file_close(testfile);
rv = apr_file_dup2(errfile, saveerr, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, errfile);
apr_file_close(saveerr);
}
示例5: 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);
}
示例6: 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);
}
示例7: overlay_empty
static void overlay_empty(abts_case *tc, void *data)
{
apr_hash_t *base = NULL;
apr_hash_t *overlay = NULL;
apr_hash_t *result = NULL;
int count;
char StrArray[MAX_DEPTH][MAX_LTH];
base = apr_hash_make(p);
overlay = apr_hash_make(p);
ABTS_PTR_NOTNULL(tc, base);
ABTS_PTR_NOTNULL(tc, overlay);
apr_hash_set(base, "key1", APR_HASH_KEY_STRING, "value1");
apr_hash_set(base, "key2", APR_HASH_KEY_STRING, "value2");
apr_hash_set(base, "key3", APR_HASH_KEY_STRING, "value3");
apr_hash_set(base, "key4", APR_HASH_KEY_STRING, "value4");
apr_hash_set(base, "key5", APR_HASH_KEY_STRING, "value5");
result = apr_hash_overlay(p, overlay, base);
count = apr_hash_count(result);
ABTS_INT_EQUAL(tc, 5, count);
dump_hash(p, result, StrArray);
ABTS_STR_EQUAL(tc, "Key key1 (4) Value value1\n", StrArray[0]);
ABTS_STR_EQUAL(tc, "Key key2 (4) Value value2\n", StrArray[1]);
ABTS_STR_EQUAL(tc, "Key key3 (4) Value value3\n", StrArray[2]);
ABTS_STR_EQUAL(tc, "Key key4 (4) Value value4\n", StrArray[3]);
ABTS_STR_EQUAL(tc, "Key key5 (4) Value value5\n", StrArray[4]);
ABTS_STR_EQUAL(tc, "#entries 5\n", StrArray[5]);
}
示例8: create_pipe
static void create_pipe(abts_case *tc, void *data)
{
apr_status_t rv;
rv = apr_file_pipe_create(&readp, &writep, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, readp);
ABTS_PTR_NOTNULL(tc, writep);
}
示例9: root_from_cwd_and_back
static void root_from_cwd_and_back(abts_case *tc, void *data)
{
apr_status_t rv;
const char *root = NULL;
const char *path = "//";
char *origpath;
char *testpath;
int hadfailed;
ABTS_INT_EQUAL(tc, APR_SUCCESS, apr_filepath_get(&origpath, 0, p));
path = origpath;
rv = apr_filepath_root(&root, &path, APR_FILEPATH_TRUENAME, p);
#if defined(WIN32) || defined(OS2)
hadfailed = tc->failed;
/* It appears some mingw/cygwin and more modern builds can return
* a lowercase drive designation, but we canonicalize to uppercase
*/
ABTS_INT_EQUAL(tc, toupper(origpath[0]), root[0]);
ABTS_INT_EQUAL(tc, ':', root[1]);
ABTS_INT_EQUAL(tc, '/', root[2]);
ABTS_INT_EQUAL(tc, 0, root[3]);
ABTS_STR_EQUAL(tc, origpath + 3, path);
#elif defined(NETWARE)
ABTS_INT_EQUAL(tc, origpath[0], root[0]);
{
char *pt = strchr(root, ':');
ABTS_PTR_NOTNULL(tc, pt);
ABTS_INT_EQUAL(tc, ':', pt[0]);
ABTS_INT_EQUAL(tc, '/', pt[1]);
ABTS_INT_EQUAL(tc, 0, pt[2]);
pt = strchr(origpath, ':');
ABTS_PTR_NOTNULL(tc, pt);
ABTS_STR_EQUAL(tc, (pt+2), path);
}
#else
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_STR_EQUAL(tc, "/", root);
ABTS_STR_EQUAL(tc, origpath + 1, path);
#endif
rv = apr_filepath_merge(&testpath, root, path,
APR_FILEPATH_TRUENAME
| APR_FILEPATH_NOTABOVEROOT
| APR_FILEPATH_NOTRELATIVE, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
hadfailed = tc->failed;
/* The API doesn't promise equality!!!
* apr_filepath_get never promised a canonical filepath.
* We'll emit noise under verbose so the user is aware,
* but translate this back to success.
*/
ABTS_STR_EQUAL(tc, origpath, testpath);
#if defined(WIN32) || defined(OS2) || defined(NETWARE)
if (!hadfailed) tc->failed = 0;
#endif
}
示例10: test_mmap_contents
static void test_mmap_contents(abts_case *tc, void *data)
{
ABTS_PTR_NOTNULL(tc, themmap);
ABTS_PTR_NOTNULL(tc, themmap->mm);
ABTS_SIZE_EQUAL(tc, thisfsize, themmap->size);
/* Must use nEquals since the string is not guaranteed to be NULL terminated */
ABTS_STR_NEQUAL(tc, themmap->mm, TEST_STRING, thisfsize);
}
示例11: test_str
static void test_str(abts_case *tc, void *data)
{
apr_pool_t *pool = p;
const apr_strmatch_pattern *pattern;
const apr_strmatch_pattern *pattern_nocase;
const apr_strmatch_pattern *pattern_onechar;
const apr_strmatch_pattern *pattern_zero;
const char *match = NULL;
const char *input1 = "string that contains a patterN...";
const char *input2 = "string that contains a pattern...";
const char *input3 = "pattern at the start of a string";
const char *input4 = "string that ends with a pattern";
const char *input5 = "patter\200n not found, negative chars in input";
const char *input6 = "patter\200n, negative chars, contains pattern...";
pattern = apr_strmatch_precompile(pool, "pattern", 1);
ABTS_PTR_NOTNULL(tc, pattern);
pattern_nocase = apr_strmatch_precompile(pool, "pattern", 0);
ABTS_PTR_NOTNULL(tc, pattern_nocase);
pattern_onechar = apr_strmatch_precompile(pool, "g", 0);
ABTS_PTR_NOTNULL(tc, pattern_onechar);
pattern_zero = apr_strmatch_precompile(pool, "", 0);
ABTS_PTR_NOTNULL(tc, pattern_zero);
match = apr_strmatch(pattern, input1, strlen(input1));
ABTS_PTR_EQUAL(tc, match, NULL);
match = apr_strmatch(pattern, input2, strlen(input2));
ABTS_PTR_EQUAL(tc, match, input2 + 23);
match = apr_strmatch(pattern_onechar, input1, strlen(input1));
ABTS_PTR_EQUAL(tc, match, input1 + 5);
match = apr_strmatch(pattern_zero, input1, strlen(input1));
ABTS_PTR_EQUAL(tc, match, input1);
match = apr_strmatch(pattern_nocase, input1, strlen(input1));
ABTS_PTR_EQUAL(tc, match, input1 + 23);
match = apr_strmatch(pattern, input3, strlen(input3));
ABTS_PTR_EQUAL(tc, match, input3);
match = apr_strmatch(pattern, input4, strlen(input4));
ABTS_PTR_EQUAL(tc, match, input4 + 24);
match = apr_strmatch(pattern, input5, strlen(input5));
ABTS_PTR_EQUAL(tc, match, NULL);
match = apr_strmatch(pattern, input6, strlen(input6));
ABTS_PTR_EQUAL(tc, match, input6 + 35);
}
示例12: test_file_dup
static void test_file_dup(abts_case *tc, void *data)
{
apr_file_t *file1 = NULL;
apr_file_t *file3 = NULL;
apr_status_t rv;
apr_finfo_t finfo;
/* First, create a new file, empty... */
rv = apr_file_open(&file1, FILEPATH "testdup.file",
APR_FOPEN_READ | APR_FOPEN_WRITE | APR_FOPEN_CREATE |
APR_FOPEN_DELONCLOSE, APR_OS_DEFAULT, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, file1);
rv = apr_file_dup(&file3, file1, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, file3);
rv = apr_file_close(file1);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
/* cleanup after ourselves */
rv = apr_file_close(file3);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
rv = apr_stat(&finfo, FILEPATH "testdup.file", APR_FINFO_NORM, p);
ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOENT(rv));
}
示例13: pollcb_default
static void pollcb_default(abts_case *tc, void *data)
{
apr_status_t rv1, rv2;
apr_pollcb_t *pollcb;
/* verify that APR will successfully create a pollcb if an invalid method
* is specified as long as APR_POLLSET_NODEFAULT isn't specified
* (no platform has both APR_POLLSET_PORT and APR_POLLSET_KQUEUE, so at
* least one create call will succeed after having to switch to the default
* type)
*/
rv1 = apr_pollcb_create_ex(&pollcb, 1, p, 0, APR_POLLSET_PORT);
if (rv1 == APR_ENOTIMPL) {
ABTS_NOT_IMPL(tc, "pollcb interface not supported");
return;
}
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv1);
ABTS_PTR_NOTNULL(tc, pollcb);
rv1 = apr_pollcb_create_ex(&pollcb, 1, p, 0, APR_POLLSET_KQUEUE);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv1);
ABTS_PTR_NOTNULL(tc, pollcb);
/* verify that APR will fail to create a pollcb if an invalid method is
* specified along with APR_POLLSET_NODEFAULT
* (no platform has both APR_POLLSET_PORT and APR_POLLSET_KQUEUE, so at
* least one create call will fail since it can't switch to the default
* type)
*/
rv1 = apr_pollcb_create_ex(&pollcb, 1, p, APR_POLLSET_NODEFAULT,
APR_POLLSET_PORT);
if (rv1 == APR_SUCCESS) {
ABTS_PTR_NOTNULL(tc, pollcb);
}
rv2 = apr_pollcb_create_ex(&pollcb, 1, p, APR_POLLSET_NODEFAULT,
APR_POLLSET_KQUEUE);
if (rv2 == APR_SUCCESS) {
ABTS_PTR_NOTNULL(tc, pollcb);
}
ABTS_ASSERT(tc,
"failure using APR_POLLSET_NODEFAULT with unsupported method",
rv1 != APR_SUCCESS || rv2 != APR_SUCCESS);
/* verify basic behavior for another method fallback case (this caused
* APR to crash before r834029)
*/
rv1 = apr_pollcb_create_ex(&pollcb, 1, p, 0, APR_POLLSET_POLL);
if (rv1 != APR_ENOTIMPL) {
ABTS_INT_EQUAL(tc, rv1, APR_SUCCESS);
ABTS_PTR_NOTNULL(tc, pollcb);
}
}
示例14: test_cond
static void test_cond(abts_case *tc, void *data)
{
apr_thread_t *p1, *p2, *p3, *p4, *c1;
apr_status_t s0, s1, s2, s3, s4;
int count1, count2, count3, count4;
int sum;
APR_ASSERT_SUCCESS(tc, "create put mutex",
apr_thread_mutex_create(&put.mutex,
APR_THREAD_MUTEX_DEFAULT, p));
ABTS_PTR_NOTNULL(tc, put.mutex);
APR_ASSERT_SUCCESS(tc, "create nready mutex",
apr_thread_mutex_create(&nready.mutex,
APR_THREAD_MUTEX_DEFAULT, p));
ABTS_PTR_NOTNULL(tc, nready.mutex);
APR_ASSERT_SUCCESS(tc, "create condvar",
apr_thread_cond_create(&nready.cond, p));
ABTS_PTR_NOTNULL(tc, nready.cond);
count1 = count2 = count3 = count4 = 0;
put.nput = put.nval = 0;
nready.nready = 0;
i = 0;
x = 0;
s0 = apr_thread_create(&p1, NULL, thread_cond_producer, &count1, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s0);
s1 = apr_thread_create(&p2, NULL, thread_cond_producer, &count2, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s1);
s2 = apr_thread_create(&p3, NULL, thread_cond_producer, &count3, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s2);
s3 = apr_thread_create(&p4, NULL, thread_cond_producer, &count4, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s3);
s4 = apr_thread_create(&c1, NULL, thread_cond_consumer, NULL, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s4);
apr_thread_join(&s0, p1);
apr_thread_join(&s1, p2);
apr_thread_join(&s2, p3);
apr_thread_join(&s3, p4);
apr_thread_join(&s4, c1);
APR_ASSERT_SUCCESS(tc, "destroy condvar",
apr_thread_cond_destroy(nready.cond));
sum = count1 + count2 + count3 + count4;
/*
printf("count1 = %d count2 = %d count3 = %d count4 = %d\n",
count1, count2, count3, count4);
*/
ABTS_INT_EQUAL(tc, MAX_COUNTER, sum);
}
示例15: test_dup2_readwrite
static void test_dup2_readwrite(abts_case *tc, void *data)
{
apr_file_t *errfile = NULL;
apr_file_t *testfile = NULL;
apr_file_t *saveerr = NULL;
apr_status_t rv;
apr_size_t txtlen = sizeof(TEST);
char buff[50];
apr_off_t fpos;
rv = apr_file_open(&testfile, FILEPATH "testdup2.readwrite.file",
APR_FOPEN_READ | APR_FOPEN_WRITE | APR_FOPEN_CREATE |
APR_FOPEN_DELONCLOSE, APR_OS_DEFAULT, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, testfile);
rv = apr_file_open_stderr(&errfile, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
/* Set aside the real errfile */
rv = apr_file_dup(&saveerr, errfile, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, saveerr);
rv = apr_file_dup2(errfile, testfile, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, errfile);
txtlen = sizeof(TEST2);
rv = apr_file_write(errfile, TEST2, &txtlen);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_SIZE_EQUAL(tc, sizeof(TEST2), txtlen);
fpos = 0;
rv = apr_file_seek(testfile, APR_SET, &fpos);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_ASSERT(tc, "File position mismatch, expected 0", fpos == 0);
txtlen = 50;
rv = apr_file_read(testfile, buff, &txtlen);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_STR_EQUAL(tc, TEST2, buff);
apr_file_close(testfile);
rv = apr_file_dup2(errfile, saveerr, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_PTR_NOTNULL(tc, errfile);
apr_file_close(saveerr);
}