コード例 #1
0
ファイル: testdir.c プロジェクト: Alivx/apache2nginx
static void test_mkdir(abts_case *tc, void *data)
{
    apr_status_t rv;
    apr_finfo_t finfo;

    rv = apr_dir_make("data/testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_stat(&finfo, "data/testdir", APR_FINFO_TYPE, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_INT_EQUAL(tc, APR_DIR, finfo.filetype);
}
コード例 #2
0
ファイル: testpoll.c プロジェクト: KunZheng/mosbench
static void recv0_pollset(abts_case *tc, void *data)
{
    apr_status_t rv;
    int lrv;
    const apr_pollfd_t *descs = NULL;

    recv_msg(s, 0, p, tc);
    rv = apr_pollset_poll(pollset, 0, &lrv, &descs);
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv));
    ABTS_INT_EQUAL(tc, 0, lrv);
    ABTS_PTR_EQUAL(tc, NULL, descs);
}
コード例 #3
0
ファイル: testfile.c プロジェクト: cmjonze/apr
static void test_file_remove(abts_case *tc, void *data)
{
    apr_status_t rv;
    apr_file_t *filetest = NULL;

    rv = apr_file_remove(FILENAME, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_file_open(&filetest, FILENAME, APR_FOPEN_READ,
                       APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_GREAD, p);
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOENT(rv));
}
コード例 #4
0
ファイル: testfile.c プロジェクト: XianliangJ/mtcp
static 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);
}
コード例 #5
0
ファイル: testpipe.c プロジェクト: AbrahamJewowich/FreeSWITCH
static void close_pipe(abts_case *tc, void *data)
{
    apr_status_t rv;
    apr_size_t nbytes = 256;
    char buf[256];

    rv = apr_file_close(readp);
    rv = apr_file_close(writep);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_file_read(readp, buf, &nbytes);
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EBADF(rv));
}   
コード例 #6
0
ファイル: testdir.c プロジェクト: 321543223/kbengine
static void test_removeall(abts_case *tc, void *data)
{
    apr_status_t rv;

    rv = apr_dir_remove("data/one/two/three", p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_dir_remove("data/one/two", p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_dir_remove("data/one", p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}
コード例 #7
0
ファイル: testdir.c プロジェクト: 321543223/kbengine
static void test_mkdir_twice(abts_case *tc, void *data)
{
    apr_status_t rv;

    rv = apr_dir_make("data/testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_dir_make("data/testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE, p);
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EEXIST(rv));

    rv = apr_dir_remove("data/testdir", p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}
コード例 #8
0
ファイル: testfile.c プロジェクト: XianliangJ/mtcp
static 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_FOPEN_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_SIZE_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_SIZE_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_FOPEN_READ | APR_FOPEN_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_SIZE_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_SIZE_EQUAL(tc, 5, nbytes);
    ABTS_STR_EQUAL(tc, TESTSTR + strlen(TESTSTR) - 5, str);

    apr_file_close(filetest);
}
コード例 #9
0
ファイル: testpoll.c プロジェクト: Ga-vin/apache
static void make_socket(apr_socket_t **sock, apr_sockaddr_t **sa, 
                        apr_port_t port, apr_pool_t *p, abts_case *tc)
{
    apr_status_t rv;

    rv = apr_sockaddr_info_get(sa, "127.0.0.1", APR_UNSPEC, port, 0, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_socket_create(sock, (*sa)->family, SOCK_DGRAM, 0, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_socket_bind((*sock), (*sa));
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}
コード例 #10
0
ファイル: testpoll.c プロジェクト: Ga-vin/apache
static void timeout_pollcb(abts_case *tc, void *data)
{
    apr_status_t rv;
    pollcb_baton_t pcb;

    POLLCB_PREREQ;

    pcb.count = 0;
    pcb.tc = tc;

    rv = apr_pollcb_poll(pollcb, 1, trigger_pollcb_cb, &pcb);    
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv));
    ABTS_INT_EQUAL(tc, 0, pcb.count);
}
コード例 #11
0
ファイル: testfile.c プロジェクト: aptana/Jaxer
static void test_getc(abts_case *tc, void *data)
{
    apr_file_t *f = NULL;
    apr_status_t rv;
    char ch;

    rv = apr_file_open(&f, FILENAME, APR_READ, 0, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    apr_file_getc(&ch, f);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_INT_EQUAL(tc, (int)TESTSTR[0], (int)ch);
    apr_file_close(f);
}
コード例 #12
0
ファイル: testpath.c プロジェクト: 0jpq0/kbengine
static void list_split_multi(abts_case *tc, void *data)
{
    int i;
    apr_status_t rv;
    apr_array_header_t *pathelts;

    pathelts = NULL;
    rv = apr_filepath_list_split(&pathelts, path_in, p);
    ABTS_PTR_NOTNULL(tc, pathelts);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_INT_EQUAL(tc, parts_out_count, pathelts->nelts);
    for (i = 0; i < pathelts->nelts; ++i)
        ABTS_STR_EQUAL(tc, parts_out[i], ((char**)pathelts->elts)[i]);
}
コード例 #13
0
ファイル: testatomic.c プロジェクト: AAthresh/quantlib
static void test_dec32(abts_case *tc, void *data)
{
    apr_uint32_t y32;
    int rv;

    apr_atomic_set32(&y32, 2);

    rv = apr_atomic_dec32(&y32);
    ABTS_INT_EQUAL(tc, 1, y32);
    ABTS_ASSERT(tc, "atomic_dec returned zero when it shouldn't", rv != 0);

    rv = apr_atomic_dec32(&y32);
    ABTS_INT_EQUAL(tc, 0, y32);
    ABTS_ASSERT(tc, "atomic_dec didn't returned zero when it should", rv == 0);
}
コード例 #14
0
ファイル: testfile.c プロジェクト: aptana/Jaxer
static void test_userdata_set(abts_case *tc, void *data)
{
    apr_status_t rv;
    apr_file_t *filetest = NULL;

    rv = apr_file_open(&filetest, FILENAME, 
                       APR_WRITE, 
                       APR_UREAD | APR_UWRITE | APR_GREAD, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_file_data_set(filetest, "This is a test",
                           "test", apr_pool_cleanup_null);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    apr_file_close(filetest);
}
コード例 #15
0
ファイル: testpoll.c プロジェクト: Ga-vin/apache
static void send_last_pollset(abts_case *tc, void *data)
{
    apr_status_t rv;
    const apr_pollfd_t *descs = NULL;
    int num;
    
    send_msg(s, sa, LARGE_NUM_SOCKETS - 1, tc);
    rv = apr_pollset_poll(pollset, -1, &num, &descs);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_INT_EQUAL(tc, 1, num);
    ABTS_PTR_NOTNULL(tc, descs);

    ABTS_PTR_EQUAL(tc, s[LARGE_NUM_SOCKETS - 1], descs[0].desc.s);
    ABTS_PTR_EQUAL(tc, s[LARGE_NUM_SOCKETS - 1], descs[0].client_data);
}
コード例 #16
0
ファイル: testshm.c プロジェクト: 0jpq0/kbengine
static 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);
}
コード例 #17
0
ファイル: testatomic.c プロジェクト: AAthresh/quantlib
static void test_atomics_threaded(abts_case *tc, void *data)
{
    apr_thread_t *t1[NUM_THREADS];
    apr_thread_t *t2[NUM_THREADS];
    apr_thread_t *t3[NUM_THREADS];
    apr_status_t s1[NUM_THREADS]; 
    apr_status_t s2[NUM_THREADS];
    apr_status_t s3[NUM_THREADS];
    apr_status_t rv;
    int i;

#ifdef HAVE_PTHREAD_SETCONCURRENCY
    pthread_setconcurrency(8);
#endif

    rv = apr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_DEFAULT, p);
    APR_ASSERT_SUCCESS(tc, "Could not create lock", rv);

    for (i = 0; i < NUM_THREADS; i++) {
        apr_status_t r1, r2, r3;
        r1 = apr_thread_create(&t1[i], NULL, thread_func_mutex, NULL, p);
        r2 = apr_thread_create(&t2[i], NULL, thread_func_atomic, NULL, p);
        r3 = apr_thread_create(&t3[i], NULL, thread_func_none, NULL, p);
        ABTS_ASSERT(tc, "Failed creating threads",
                 r1 == APR_SUCCESS && r2 == APR_SUCCESS && 
                 r3 == APR_SUCCESS);
    }

    for (i = 0; i < NUM_THREADS; i++) {
        apr_thread_join(&s1[i], t1[i]);
        apr_thread_join(&s2[i], t2[i]);
        apr_thread_join(&s3[i], t3[i]);
                     
        ABTS_ASSERT(tc, "Invalid return value from thread_join",
                 s1[i] == exit_ret_val && s2[i] == exit_ret_val && 
                 s3[i] == exit_ret_val);
    }

    ABTS_INT_EQUAL(tc, x, NUM_THREADS * NUM_ITERATIONS);
    ABTS_INT_EQUAL(tc, apr_atomic_read32(&y), NUM_THREADS * NUM_ITERATIONS);
    /* Comment out this test, because I have no clue what this test is
     * actually telling us.  We are checking something that may or may not
     * be true, and it isn't really testing APR at all.
    ABTS_ASSERT(tc, "We expect this to fail, because we tried to update "
                 "an integer in a non-thread-safe manner.",
             z != NUM_THREADS * NUM_ITERATIONS);
     */
}
コード例 #18
0
static 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);
}
コード例 #19
0
ファイル: testmmap.c プロジェクト: Arcterus/MoarVM
static void test_file_close(abts_case *tc, void *data)
{
    apr_status_t rv;

    rv = apr_file_close(thefile);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}
コード例 #20
0
ファイル: testargs.c プロジェクト: ohmann/checkapi
static void no_options(abts_case *tc, void *data)
{
    int largc = 5;
    const char * const largv[] = {"testprog", "-a", "-b", "-c", "-d"};
    apr_getopt_t *opt;
    apr_status_t rv;
    char ch;
    const char *optarg;
    char str[8196];

    str[0] = '\0';
    rv = apr_getopt_init(&opt, p, largc, largv);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    opt->errfn = unknown_arg;
    opt->errarg = str;

    while (apr_getopt(opt, "efgh", &ch, &optarg) == APR_SUCCESS) {
        switch (ch) {
            case 'a':
            case 'b':
            case 'c':
            case 'd':
                format_arg(str, ch, optarg);
                break;
            default:
                break;
        }
    }
    ABTS_STR_EQUAL(tc, "testprog: illegal option -- a\n", str);
}
コード例 #21
0
ファイル: testargs.c プロジェクト: ohmann/checkapi
static void no_options_found(abts_case *tc, void *data)
{
    int largc = 5;
    const char * const largv[] = {"testprog", "-a", "-b", "-c", "-d"};
    apr_getopt_t *opt;
    apr_status_t rv;
    char ch;
    const char *optarg;
    char str[8196];

    str[0] = '\0';
    rv = apr_getopt_init(&opt, p, largc, largv);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    while (apr_getopt(opt, "abcd", &ch, &optarg) == APR_SUCCESS) {
        switch (ch) {
            case 'a':
            case 'b':
            case 'c':
            case 'd':
            default:
                format_arg(str, ch, optarg);
        }
    }
    ABTS_STR_EQUAL(tc, "option: a\n"
                          "option: b\n"
                          "option: c\n"
                          "option: d\n", str);
}
コード例 #22
0
ファイル: testfile.c プロジェクト: aptana/Jaxer
static 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);
}
コード例 #23
0
ファイル: testfile.c プロジェクト: aptana/Jaxer
static void test_write(abts_case *tc, void *data)
{
    apr_status_t rv;
    apr_size_t bytes = strlen(TESTSTR);
    apr_file_t *filetest = NULL;

    rv = apr_file_open(&filetest, FILENAME, 
                       APR_WRITE | APR_CREATE, 
                       APR_UREAD | APR_UWRITE | APR_GREAD, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_file_write(filetest, TESTSTR, &bytes);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    apr_file_close(filetest);
}
コード例 #24
0
ファイル: testsockets.c プロジェクト: Ga-vin/apache
static void udp_socket(abts_case *tc, void *data)
{
    apr_status_t rv;
    apr_socket_t *sock = NULL;
    int type;

    rv = apr_socket_create(&sock, APR_INET, SOCK_DGRAM, 0, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_PTR_NOTNULL(tc, sock);

    rv = apr_socket_type_get(sock, &type);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_INT_EQUAL(tc, SOCK_DGRAM, type);

    apr_socket_close(sock);
}
コード例 #25
0
ファイル: testfile.c プロジェクト: aptana/Jaxer
static void test_userdata_getnokey(abts_case *tc, void *data)
{
    apr_status_t rv;
    void *teststr;
    apr_file_t *filetest = NULL;

    rv = apr_file_open(&filetest, FILENAME, 
                       APR_WRITE, 
                       APR_UREAD | APR_UWRITE | APR_GREAD, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    rv = apr_file_data_get(&teststr, "nokey", filetest);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_PTR_EQUAL(tc, NULL, teststr);
    apr_file_close(filetest);
}
コード例 #26
0
ファイル: testud.c プロジェクト: Bernd8/quantlib
static void set_userdata(abts_case *tc, void *data)
{
    apr_status_t rv;

    rv = apr_pool_userdata_set(testdata, "TEST", string_cleanup, pool);
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
}
コード例 #27
0
ファイル: testfile.c プロジェクト: aptana/Jaxer
static 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);

}
コード例 #28
0
ファイル: testargs.c プロジェクト: ohmann/checkapi
static void optional_option(abts_case *tc, void *data)
{
    int largc = 3;
    const char * const largv[] = {"testprog", "-a", "foo"};
    apr_getopt_t *opt;
    apr_status_t rv;
    char ch;
    const char *optarg;
    char str[8196];

    str[0] = '\0';
    rv = apr_getopt_init(&opt, p, largc, largv);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    opt->errfn = unknown_arg;
    opt->errarg = str;

    while (apr_getopt(opt, "a::", &ch, &optarg) == APR_SUCCESS) {
        switch (ch) {
            case 'a':
                format_arg(str, ch, optarg);
                break;
            default:
                break;
        }
    }
    ABTS_STR_EQUAL(tc, "option: a with foo\n", str);
}
コード例 #29
0
ファイル: testfile.c プロジェクト: aptana/Jaxer
static void test_readzero(abts_case *tc, void *data)
{
    apr_status_t rv;
    apr_size_t nbytes = 0;
    char *str = NULL;
    apr_file_t *filetest;
    
    rv = apr_file_open(&filetest, FILENAME, APR_READ, APR_OS_DEFAULT, p);
    APR_ASSERT_SUCCESS(tc, "Opening test file " FILENAME, rv);

    rv = apr_file_read(filetest, str, &nbytes);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_INT_EQUAL(tc, 0, nbytes);

    apr_file_close(filetest);
}
コード例 #30
0
ファイル: testargs.c プロジェクト: ohmann/checkapi
static void optional_option_notgiven(abts_case *tc, void *data)
{
    int largc = 2;
    const char * const largv[] = {"testprog", "-a"};
    apr_getopt_t *opt;
    apr_status_t rv;
    char ch;
    const char *optarg;
    char str[8196];

    str[0] = '\0';
    rv = apr_getopt_init(&opt, p, largc, largv);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);

    opt->errfn = unknown_arg;
    opt->errarg = str;

    while (apr_getopt(opt, "a::", &ch, &optarg) == APR_SUCCESS) {
        switch (ch) {
            case 'a':
                format_arg(str, ch, optarg);
                break;
            default:
                break;
        }
    }
#if 0
/*  Our version of getopt doesn't allow for optional arguments.  */
    ABTS_STR_EQUAL(tc, "option: a\n", str);
#endif
    ABTS_STR_EQUAL(tc, "testprog: option requires an argument -- a\n", str);
}