这篇教程C++ APR_ASSERT_SUCCESS函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中APR_ASSERT_SUCCESS函数的典型用法代码示例。如果您正苦于以下问题:C++ APR_ASSERT_SUCCESS函数的具体用法?C++ APR_ASSERT_SUCCESS怎么用?C++ APR_ASSERT_SUCCESS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了APR_ASSERT_SUCCESS函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: test_addr_infostatic void test_addr_info(abts_case *tc, void *data){ apr_status_t rv; apr_sockaddr_t *sa; int rc; rv = apr_sockaddr_info_get(&sa, NULL, APR_UNSPEC, 80, 0, p); APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv); rc = apr_sockaddr_is_wildcard(sa); ABTS_INT_NEQUAL(tc, 0, rc); rv = apr_sockaddr_info_get(&sa, "127.0.0.1", APR_UNSPEC, 80, 0, p); APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv); ABTS_STR_EQUAL(tc, "127.0.0.1", sa->hostname); rc = apr_sockaddr_is_wildcard(sa); ABTS_INT_EQUAL(tc, 0, rc); rv = apr_sockaddr_info_get(&sa, "127.0.0.1", APR_UNSPEC, 0, 0, p); APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv); ABTS_STR_EQUAL(tc, "127.0.0.1", sa->hostname); ABTS_INT_EQUAL(tc, 0, sa->port); ABTS_INT_EQUAL(tc, 0, ntohs(sa->sa.sin.sin_port));}
开发者ID:TaoheGit,项目名称:hmi_sdl_android,代码行数:25,
示例2: test_print_addrstatic void test_print_addr(abts_case *tc, void *data){ apr_sockaddr_t *sa; apr_status_t rv; char *s; rv = apr_sockaddr_info_get(&sa, "0.0.0.0", APR_INET, 80, 0, p); APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv); s = apr_psprintf(p, "foo %pI bar", sa); ABTS_STR_EQUAL(tc, "foo 0.0.0.0:80 bar", s);#if APR_HAVE_IPV6 rv = apr_sockaddr_info_get(&sa, "::ffff:0.0.0.0", APR_INET6, 80, 0, p); APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv); if (rv == APR_SUCCESS) ABTS_TRUE(tc, sa != NULL); if (rv == APR_SUCCESS && sa) { /* sa should now be a v4-mapped IPv6 address. */ char buf[128]; int rc; rc = apr_sockaddr_is_wildcard(sa); ABTS_INT_NEQUAL(tc, 0, rc); memset(buf, 'z', sizeof buf); APR_ASSERT_SUCCESS(tc, "could not get IP address", apr_sockaddr_ip_getbuf(buf, 22, sa)); ABTS_STR_EQUAL(tc, "0.0.0.0", buf); }#endif}
开发者ID:TaoheGit,项目名称:hmi_sdl_android,代码行数:35,
示例3: copy_helperstatic 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); }}
开发者ID:cmjonze,项目名称:apr,代码行数:34,
示例4: launch_childstatic void launch_child(abts_case *tc, apr_proc_t *proc, const char *arg1, apr_pool_t *p){ apr_procattr_t *procattr; const char *args[3]; apr_status_t rv; 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); rv = apr_procattr_cmdtype_set(procattr, APR_PROGRAM_ENV); APR_ASSERT_SUCCESS(tc, "Couldn't set copy environment", rv); args[0] = "sockchild" EXTENSION; args[1] = arg1; args[2] = NULL; rv = apr_proc_create(proc, TESTBINPATH "sockchild" EXTENSION, args, NULL, procattr, p); APR_ASSERT_SUCCESS(tc, "Couldn't launch program", rv);}
开发者ID:TaoheGit,项目名称:hmi_sdl_android,代码行数:26,
示例5: test_timeoutstatic void test_timeout(abts_case *tc, void *data){ apr_status_t rv; apr_socket_t *sock; apr_socket_t *sock2; apr_proc_t proc; int protocol; int exit; sock = setup_socket(tc); if (!sock) return; launch_child(tc, &proc, "read", p); rv = apr_socket_accept(&sock2, sock, p); APR_ASSERT_SUCCESS(tc, "Problem with receiving connection", rv); apr_socket_protocol_get(sock2, &protocol); ABTS_INT_EQUAL(tc, APR_PROTO_TCP, protocol); exit = wait_child(tc, &proc); ABTS_INT_EQUAL(tc, SOCKET_TIMEOUT, exit); /* We didn't write any data, so make sure the child program returns * an error. */ rv = apr_socket_close(sock2); APR_ASSERT_SUCCESS(tc, "Problem closing connected socket", rv); rv = apr_socket_close(sock); APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv);}
开发者ID:AAthresh,项目名称:quantlib,代码行数:31,
示例6: launch_readerstatic 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;}
开发者ID:TaoheGit,项目名称:hmi_sdl_android,代码行数:30,
示例7: test_writev_fullstatic void test_writev_full(abts_case *tc, void *data){ apr_file_t *f; apr_size_t nbytes; struct iovec vec[5]; const char *fname = "data/testwritev_full.txt"; APR_ASSERT_SUCCESS(tc, "open file for writing", apr_file_open(&f, fname, APR_WRITE|APR_CREATE|APR_TRUNCATE, APR_OS_DEFAULT, p)); vec[0].iov_base = LINE1; vec[0].iov_len = strlen(LINE1); vec[1].iov_base = LINE2; vec[1].iov_len = strlen(LINE2); vec[2].iov_base = LINE1; vec[2].iov_len = strlen(LINE1); vec[3].iov_base = LINE1; vec[3].iov_len = strlen(LINE1); vec[4].iov_base = LINE2; vec[4].iov_len = strlen(LINE2); APR_ASSERT_SUCCESS(tc, "writev_full of size 5 to file", apr_file_writev_full(f, vec, 5, &nbytes)); ABTS_INT_EQUAL(tc, strlen(LINE1)*3 + strlen(LINE2)*2, nbytes); APR_ASSERT_SUCCESS(tc, "close for writing", apr_file_close(f)); file_contents_equal(tc, fname, LINE1 LINE2 LINE1 LINE1 LINE2, strlen(LINE1)*3 + strlen(LINE2)*2);}
开发者ID:aptana,项目名称:Jaxer,代码行数:35,
示例8: test_sendstatic void test_send(abts_case *tc, void *data){ apr_status_t rv; apr_socket_t *sock; apr_socket_t *sock2; apr_proc_t proc; int protocol; apr_size_t length; sock = setup_socket(tc); if (!sock) return; launch_child(tc, &proc, "read", p); rv = apr_socket_accept(&sock2, sock, p); APR_ASSERT_SUCCESS(tc, "Problem with receiving connection", rv); apr_socket_protocol_get(sock2, &protocol); ABTS_INT_EQUAL(tc, APR_PROTO_TCP, protocol); length = strlen(DATASTR); apr_socket_send(sock2, DATASTR, &length); /* Make sure that the client received the data we sent */ ABTS_SIZE_EQUAL(tc, strlen(DATASTR), wait_child(tc, &proc)); rv = apr_socket_close(sock2); APR_ASSERT_SUCCESS(tc, "Problem closing connected socket", rv); rv = apr_socket_close(sock); APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv);}
开发者ID:AAthresh,项目名称:quantlib,代码行数:31,
示例9: test_recvstatic void test_recv(abts_case *tc, void *data){ apr_status_t rv; apr_socket_t *sock; apr_socket_t *sock2; apr_proc_t proc; int protocol; apr_size_t length = STRLEN; char datastr[STRLEN]; sock = setup_socket(tc); if (!sock) return; launch_child(tc, &proc, "write", p); rv = apr_socket_accept(&sock2, sock, p); APR_ASSERT_SUCCESS(tc, "Problem with receiving connection", rv); apr_socket_protocol_get(sock2, &protocol); ABTS_INT_EQUAL(tc, APR_PROTO_TCP, protocol); memset(datastr, 0, STRLEN); apr_socket_recv(sock2, datastr, &length); /* Make sure that the server received the data we sent */ ABTS_STR_EQUAL(tc, DATASTR, datastr); ABTS_SIZE_EQUAL(tc, strlen(datastr), wait_child(tc, &proc)); rv = apr_socket_close(sock2); APR_ASSERT_SUCCESS(tc, "Problem closing connected socket", rv); rv = apr_socket_close(sock); APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv);}
开发者ID:AAthresh,项目名称:quantlib,代码行数:33,
示例10: test_thread_rwlockstatic void test_thread_rwlock(abts_case *tc, void *data){ apr_thread_t *t1, *t2, *t3, *t4; apr_status_t s1, s2, s3, s4; s1 = apr_thread_rwlock_create(&rwlock, p); if (s1 == APR_ENOTIMPL) { ABTS_NOT_IMPL(tc, "rwlocks not implemented"); return; } APR_ASSERT_SUCCESS(tc, "rwlock_create", s1); ABTS_PTR_NOTNULL(tc, rwlock); i = 0; x = 0; s1 = apr_thread_create(&t1, NULL, thread_rwlock_func, NULL, p); APR_ASSERT_SUCCESS(tc, "create thread 1", s1); s2 = apr_thread_create(&t2, NULL, thread_rwlock_func, NULL, p); APR_ASSERT_SUCCESS(tc, "create thread 2", s2); s3 = apr_thread_create(&t3, NULL, thread_rwlock_func, NULL, p); APR_ASSERT_SUCCESS(tc, "create thread 3", s3); s4 = apr_thread_create(&t4, NULL, thread_rwlock_func, NULL, p); APR_ASSERT_SUCCESS(tc, "create thread 4", s4); apr_thread_join(&s1, t1); apr_thread_join(&s2, t2); apr_thread_join(&s3, t3); apr_thread_join(&s4, t4); ABTS_INT_EQUAL(tc, MAX_ITER, x); apr_thread_rwlock_destroy(rwlock);}
开发者ID:skizhak,项目名称:open-media-flow-controller,代码行数:34,
示例11: test_buffered_write_sizestatic void test_buffered_write_size(abts_case *tc, void *data){ const apr_size_t data_len = strlen(NEWFILEDATA); apr_file_t *thefile; apr_finfo_t finfo; apr_status_t rv; apr_size_t bytes; rv = apr_file_open(&thefile, NEWFILENAME, APR_READ | APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED | APR_DELONCLOSE, APR_OS_DEFAULT, p); APR_ASSERT_SUCCESS(tc, "open file", rv); /* A funny thing happened to me the other day: I wrote something * into a buffered file, then asked for its size using * apr_file_info_get; and guess what? The size was 0! That's not a * nice way to behave. */ bytes = data_len; rv = apr_file_write(thefile, NEWFILEDATA, &bytes); APR_ASSERT_SUCCESS(tc, "write file contents", rv); ABTS_TRUE(tc, data_len == bytes); rv = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); APR_ASSERT_SUCCESS(tc, "get file size", rv); ABTS_TRUE(tc, bytes == (apr_size_t) finfo.size); apr_file_close(thefile);}
开发者ID:AAthresh,项目名称:quantlib,代码行数:29,
示例12: test_writev_bufferedstatic void test_writev_buffered(abts_case *tc, void *data){ apr_file_t *f; apr_size_t nbytes; struct iovec vec[2]; const char *fname = "data/testwritev_buffered.dat"; APR_ASSERT_SUCCESS(tc, "open file for writing", apr_file_open(&f, fname, APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED, APR_OS_DEFAULT, p)); nbytes = strlen(TESTSTR); APR_ASSERT_SUCCESS(tc, "buffered write", apr_file_write(f, TESTSTR, &nbytes)); vec[0].iov_base = LINE1; vec[0].iov_len = strlen(LINE1); vec[1].iov_base = LINE2; vec[1].iov_len = strlen(LINE2); APR_ASSERT_SUCCESS(tc, "writev of size 2 to file", apr_file_writev(f, vec, 2, &nbytes)); APR_ASSERT_SUCCESS(tc, "close for writing", apr_file_close(f)); file_contents_equal(tc, fname, TESTSTR LINE1 LINE2, strlen(TESTSTR) + strlen(LINE1) + strlen(LINE2));}
开发者ID:aptana,项目名称:Jaxer,代码行数:30,
示例13: test_atreadeofstatic void test_atreadeof(abts_case *tc, void *data){ apr_status_t rv; apr_socket_t *sock; apr_socket_t *sock2; apr_proc_t proc; apr_size_t length = STRLEN; char datastr[STRLEN]; int atreadeof = -1; sock = setup_socket(tc); if (!sock) return; launch_child(tc, &proc, "write", p); rv = apr_socket_accept(&sock2, sock, p); APR_ASSERT_SUCCESS(tc, "Problem with receiving connection", rv); /* Check that the remote socket is still open */ rv = apr_socket_atreadeof(sock2, &atreadeof); APR_ASSERT_SUCCESS(tc, "Determine whether at EOF, #1", rv); ABTS_INT_EQUAL(tc, 0, atreadeof); memset(datastr, 0, STRLEN); apr_socket_recv(sock2, datastr, &length); /* Make sure that the server received the data we sent */ ABTS_STR_EQUAL(tc, DATASTR, datastr); ABTS_SIZE_EQUAL(tc, strlen(datastr), wait_child(tc, &proc)); /* The child is dead, so should be the remote socket */ rv = apr_socket_atreadeof(sock2, &atreadeof); APR_ASSERT_SUCCESS(tc, "Determine whether at EOF, #2", rv); ABTS_INT_EQUAL(tc, 1, atreadeof); rv = apr_socket_close(sock2); APR_ASSERT_SUCCESS(tc, "Problem closing connected socket", rv); launch_child(tc, &proc, "close", p); rv = apr_socket_accept(&sock2, sock, p); APR_ASSERT_SUCCESS(tc, "Problem with receiving connection", rv); /* The child closed the socket as soon as it could... */ rv = apr_socket_atreadeof(sock2, &atreadeof); APR_ASSERT_SUCCESS(tc, "Determine whether at EOF, #3", rv); if (!atreadeof) { /* ... but perhaps not yet; wait a moment */ apr_sleep(apr_time_from_msec(5)); rv = apr_socket_atreadeof(sock2, &atreadeof); APR_ASSERT_SUCCESS(tc, "Determine whether at EOF, #4", rv); } ABTS_INT_EQUAL(tc, 1, atreadeof); wait_child(tc, &proc); rv = apr_socket_close(sock2); APR_ASSERT_SUCCESS(tc, "Problem closing connected socket", rv); rv = apr_socket_close(sock); APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv);}
开发者ID:TaoheGit,项目名称:hmi_sdl_android,代码行数:60,
示例14: test_condstatic 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);}
开发者ID:skizhak,项目名称:open-media-flow-controller,代码行数:54,
示例15: test_addr_infostatic void test_addr_info(abts_case *tc, void *data){ apr_status_t rv; apr_sockaddr_t *sa; rv = apr_sockaddr_info_get(&sa, NULL, APR_UNSPEC, 80, 0, p); APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv); rv = apr_sockaddr_info_get(&sa, "127.0.0.1", APR_UNSPEC, 80, 0, p); APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv); ABTS_STR_EQUAL(tc, "127.0.0.1", sa->hostname);}
开发者ID:AAthresh,项目名称:quantlib,代码行数:12,
示例16: test_anon_createstatic void test_anon_create(abts_case *tc, void *data){ apr_status_t rv; apr_shm_t *shm = NULL; rv = apr_shm_create(&shm, SHARED_SIZE, NULL, p); APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); ABTS_PTR_NOTNULL(tc, shm); rv = apr_shm_destroy(shm); APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);}
开发者ID:0jpq0,项目名称:kbengine,代码行数:12,
示例17: test_xthreadstatic void test_xthread(abts_case *tc, void *data){ apr_file_t *f; const char *fname = "data/testxthread.dat"; apr_status_t rv; apr_int32_t flags = APR_FOPEN_CREATE|APR_FOPEN_READ|APR_FOPEN_WRITE|APR_FOPEN_APPEND|APR_FOPEN_XTHREAD; char buf[128] = { 0 }; /* Test for bug 38438, opening file with append + xthread and seeking to the end of the file resulted in writes going to the beginning not the end. */ apr_file_remove(fname, p); APR_ASSERT_SUCCESS(tc, "open test file", apr_file_open(&f, fname, flags, APR_UREAD|APR_UWRITE, p)); APR_ASSERT_SUCCESS(tc, "write should succeed", apr_file_puts("hello", f)); apr_file_close(f); APR_ASSERT_SUCCESS(tc, "open test file", apr_file_open(&f, fname, flags, APR_UREAD|APR_UWRITE, p)); /* Seek to the end. */ { apr_off_t offset = 0; rv = apr_file_seek(f, APR_END, &offset); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } APR_ASSERT_SUCCESS(tc, "more writes should succeed", apr_file_puts("world", f)); /* Back to the beginning. */ { apr_off_t offset = 0; rv = apr_file_seek(f, APR_SET, &offset); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } apr_file_read_full(f, buf, sizeof(buf), NULL); ABTS_STR_EQUAL(tc, "helloworld", buf); apr_file_close(f);}
开发者ID:XianliangJ,项目名称:mtcp,代码行数:52,
示例18: test_seekstatic void test_seek(abts_case *tc, void *data){ apr_status_t rv; apr_off_t offset = 5; apr_size_t nbytes = 256; char *str = apr_pcalloc(p, nbytes + 1); apr_file_t *filetest = NULL; rv = apr_file_open(&filetest, FILENAME, APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD, p); APR_ASSERT_SUCCESS(tc, "Open test file " FILENAME, rv); rv = apr_file_read(filetest, str, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(TESTSTR), nbytes); ABTS_STR_EQUAL(tc, TESTSTR, str); memset(str, 0, nbytes + 1); rv = apr_file_seek(filetest, SEEK_SET, &offset); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); rv = apr_file_read(filetest, str, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(TESTSTR) - 5, nbytes); ABTS_STR_EQUAL(tc, TESTSTR + 5, str); apr_file_close(filetest); /* Test for regression of sign error bug with SEEK_END and buffered files. */ rv = apr_file_open(&filetest, FILENAME, APR_READ | APR_BUFFERED, APR_UREAD | APR_UWRITE | APR_GREAD, p); APR_ASSERT_SUCCESS(tc, "Open test file " FILENAME, rv); offset = -5; rv = apr_file_seek(filetest, SEEK_END, &offset); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(TESTSTR) - 5, nbytes); memset(str, 0, nbytes + 1); nbytes = 256; rv = apr_file_read(filetest, str, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 5, nbytes); ABTS_STR_EQUAL(tc, TESTSTR + strlen(TESTSTR) - 5, str); apr_file_close(filetest);}
开发者ID:aptana,项目名称:Jaxer,代码行数:51,
示例19: test_anonstatic void test_anon(abts_case *tc, void *data){ apr_proc_t proc; apr_status_t rv; apr_shm_t *shm; apr_size_t retsize; int cnt, i; int recvd; rv = apr_shm_create(&shm, SHARED_SIZE, NULL, p); APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); ABTS_PTR_NOTNULL(tc, shm); retsize = apr_shm_size_get(shm); ABTS_INT_EQUAL(tc, SHARED_SIZE, retsize); boxes = apr_shm_baseaddr_get(shm); ABTS_PTR_NOTNULL(tc, boxes); rv = apr_proc_fork(&proc, p); if (rv == APR_INCHILD) { /* child */ int num = msgwait(5, 0, N_BOXES); /* exit with the number of messages received so that the parent * can check that all messages were received. */ exit(num); } else if (rv == APR_INPARENT) { /* parent */ i = N_BOXES; cnt = 0; while (cnt++ < N_MESSAGES) { if ((i-=3) < 0) { i += N_BOXES; /* start over at the top */ } msgput(i, MSG); apr_sleep(apr_time_make(0, 10000)); } } else { ABTS_FAIL(tc, "apr_proc_fork failed"); } /* wait for the child */ rv = apr_proc_wait(&proc, &recvd, NULL, APR_WAIT); ABTS_INT_EQUAL(tc, N_MESSAGES, recvd); rv = apr_shm_destroy(shm); APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);}
开发者ID:0jpq0,项目名称:kbengine,代码行数:48,
示例20: test_delenvstatic void test_delenv(abts_case *tc, void *data){ char *value; apr_status_t rv; if (!have_env_set) { ABTS_NOT_IMPL(tc, "apr_env_set (skip test for apr_env_delete)"); return; } rv = apr_env_delete(TEST_ENVVAR_NAME, p); have_env_del = (rv != APR_ENOTIMPL); if (!have_env_del) { ABTS_NOT_IMPL(tc, "apr_env_delete"); return; } APR_ASSERT_SUCCESS(tc, "delete environment variable", rv); if (!have_env_get) { ABTS_NOT_IMPL(tc, "apr_env_get (skip sanity check for apr_env_delete)"); return; } rv = apr_env_get(&value, TEST_ENVVAR_NAME, p); ABTS_INT_EQUAL(tc, APR_ENOENT, rv);}
开发者ID:AAthresh,项目名称:quantlib,代码行数:25,
示例21: test_check_sizestatic void test_check_size(abts_case *tc, void *data){ apr_status_t rv; apr_shm_t *shm = NULL; apr_size_t retsize; rv = apr_shm_create(&shm, SHARED_SIZE, NULL, p); APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); ABTS_PTR_NOTNULL(tc, shm); retsize = apr_shm_size_get(shm); ABTS_SIZE_EQUAL(tc, SHARED_SIZE, retsize); rv = apr_shm_destroy(shm); APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);}
开发者ID:0jpq0,项目名称:kbengine,代码行数:16,
示例22: test_fail_write_flushstatic void test_fail_write_flush(abts_case *tc, void *data){ apr_file_t *f; const char *fname = "data/testflush.dat"; apr_status_t rv; char buf[APR_BUFFERSIZE]; int n; apr_file_remove(fname, p); APR_ASSERT_SUCCESS(tc, "open test file", apr_file_open(&f, fname, APR_CREATE|APR_READ|APR_BUFFERED, APR_UREAD|APR_UWRITE, p)); memset(buf, 'A', sizeof buf); /* Try three writes. One of these should fail when it exceeds the * internal buffer and actually tries to write to the file, which * was opened read-only and hence should be unwritable. */ for (n = 0, rv = APR_SUCCESS; n < 4 && rv == APR_SUCCESS; n++) { apr_size_t bytes = sizeof buf; rv = apr_file_write(f, buf, &bytes); } ABTS_ASSERT(tc, "failed to write to read-only buffered fd", rv != APR_SUCCESS); apr_file_close(f);}
开发者ID:aptana,项目名称:Jaxer,代码行数:30,
示例23: test_bigfprintfstatic void test_bigfprintf(abts_case *tc, void *data){ apr_file_t *f; const char *fname = "data/testbigfprintf.dat"; char *to_write; int i; apr_file_remove(fname, p); APR_ASSERT_SUCCESS(tc, "open test file", apr_file_open(&f, fname, APR_CREATE|APR_WRITE, APR_UREAD|APR_UWRITE, p)); to_write = malloc(HUGE_STRING_LEN + 3); for (i = 0; i < HUGE_STRING_LEN + 1; ++i) to_write[i] = 'A' + i%26; strcpy(to_write + HUGE_STRING_LEN, "42"); i = apr_file_printf(f, "%s", to_write); ABTS_INT_EQUAL(tc, HUGE_STRING_LEN + 2, i); apr_file_close(f); file_contents_equal(tc, fname, to_write, HUGE_STRING_LEN + 2); free(to_write);}
开发者ID:aptana,项目名称:Jaxer,代码行数:31,
示例24: test_mtime_setstatic void test_mtime_set(abts_case *tc, void *data){ apr_file_t *thefile; apr_finfo_t finfo; apr_time_t epoch = 0; apr_status_t rv; /* This test sort of depends on the system clock being at least * marginally ccorrect; We'll be setting the modification time to * the epoch. */ rv = apr_file_open(&thefile, NEWFILENAME, APR_READ | APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED | APR_DELONCLOSE, APR_OS_DEFAULT, p); APR_ASSERT_SUCCESS(tc, "open file", rv); /* Check that the current mtime is not the epoch */ rv = apr_stat(&finfo, NEWFILENAME, APR_FINFO_MTIME, p); if (rv == APR_INCOMPLETE) { char *str; int i; str = apr_pstrdup(p, "APR_INCOMPLETE: Missing "); for (i = 0; vfi[i].bits; ++i) { if (vfi[i].bits & ~finfo.valid) { str = apr_pstrcat(p, str, vfi[i].description, " ", NULL); } } ABTS_FAIL(tc, str); } APR_ASSERT_SUCCESS(tc, "get initial mtime", rv); ABTS_TRUE(tc, finfo.mtime != epoch); /* Reset the mtime to the epoch and verify the result. * Note: we blindly assume that if the first apr_stat succeeded, * the second one will, too. */ rv = apr_file_mtime_set(NEWFILENAME, epoch, p); APR_ASSERT_SUCCESS(tc, "set mtime", rv); rv = apr_stat(&finfo, NEWFILENAME, APR_FINFO_MTIME, p); APR_ASSERT_SUCCESS(tc, "get modified mtime", rv); ABTS_TRUE(tc, finfo.mtime == epoch); apr_file_close(thefile);}
开发者ID:AAthresh,项目名称:quantlib,代码行数:46,
示例25: test_fail_read_flushstatic void test_fail_read_flush(abts_case *tc, void *data){ apr_file_t *f; const char *fname = "data/testflush.dat"; apr_status_t rv; char buf[2]; apr_file_remove(fname, p); APR_ASSERT_SUCCESS(tc, "open test file", apr_file_open(&f, fname, APR_CREATE|APR_READ|APR_BUFFERED, APR_UREAD|APR_UWRITE, p)); /* this write should be buffered. */ APR_ASSERT_SUCCESS(tc, "buffered write should succeed", apr_file_puts("hello", f)); /* Now, trying a read should fail since the write must be flushed, * and should fail with something other than EOF since the file is * opened read-only. */ rv = apr_file_read_full(f, buf, 2, NULL); ABTS_ASSERT(tc, "read should flush buffered write and fail", rv != APR_SUCCESS && rv != APR_EOF); /* Likewise for gets */ rv = apr_file_gets(buf, 2, f); ABTS_ASSERT(tc, "gets should flush buffered write and fail", rv != APR_SUCCESS && rv != APR_EOF); /* Likewise for seek. */ { apr_off_t offset = 0; rv = apr_file_seek(f, APR_SET, &offset); } ABTS_ASSERT(tc, "seek should flush buffered write and fail", rv != APR_SUCCESS && rv != APR_EOF); apr_file_close(f);}
开发者ID:aptana,项目名称:Jaxer,代码行数:44,
示例26: test_md5passstatic void test_md5pass(abts_case *tc, void *data){ const char *pass = "hellojed", *salt = "sardine"; char hash[100]; apr_md5_encode(pass, salt, hash, sizeof hash); APR_ASSERT_SUCCESS(tc, "MD5 password validated", apr_password_validate(pass, hash));}
开发者ID:dtrebbien,项目名称:apr,代码行数:10,
示例27: test_create_bind_listenstatic void test_create_bind_listen(abts_case *tc, void *data){ apr_status_t rv; apr_socket_t *sock = setup_socket(tc); if (!sock) return; rv = apr_socket_close(sock); APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv);}
开发者ID:AAthresh,项目名称:quantlib,代码行数:10,
示例28: test_cryptstatic void test_crypt(abts_case *tc, void *data){ int i; for (i = 0; i < num_passwords; i++) { APR_ASSERT_SUCCESS(tc, "check for valid password", apr_password_validate(passwords[i].password, passwords[i].hash)); }}
开发者ID:dtrebbien,项目名称:apr,代码行数:10,
示例29: test_shapassstatic void test_shapass(abts_case *tc, void *data){ const char *pass = "hellojed"; char hash[100]; apr_sha1_base64(pass, strlen(pass), hash); APR_ASSERT_SUCCESS(tc, "SHA1 password validated", apr_password_validate(pass, hash));}
开发者ID:dtrebbien,项目名称:apr,代码行数:10,
示例30: file_contents_equal/* Test that the contents of file FNAME are equal to data EXPECT of * length EXPECTLEN. */static void file_contents_equal(abts_case *tc, const char *fname, const void *expect, apr_size_t expectlen){ void *actual = apr_palloc(p, expectlen); apr_file_t *f; APR_ASSERT_SUCCESS(tc, "open file", apr_file_open(&f, fname, APR_READ|APR_BUFFERED, 0, p)); APR_ASSERT_SUCCESS(tc, "read from file", apr_file_read_full(f, actual, expectlen, NULL)); ABTS_ASSERT(tc, "matched expected file contents", memcmp(expect, actual, expectlen) == 0); APR_ASSERT_SUCCESS(tc, "close file", apr_file_close(f));}
开发者ID:aptana,项目名称:Jaxer,代码行数:21,
注:本文中的APR_ASSERT_SUCCESS函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ APR_BRIGADE_EMPTY函数代码示例 C++ APP_UART_FIFO_INIT函数代码示例 |