~ubuntu-branches/ubuntu/trusty/apr-util/trusty

« back to all changes in this revision

Viewing changes to test/testrmm.c

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur
  • Date: 2009-03-26 22:25:48 UTC
  • mto: (4.1.1 squeeze) (20.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20090326222548-v103269kb84vo0ub
Tags: upstream-1.3.4+dfsg
ImportĀ upstreamĀ versionĀ 1.3.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
    void *entity;
43
43
 
44
44
    rv = apr_pool_create(&pool, p);
45
 
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
45
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
46
46
 
47
47
    /* We're going to want 10 blocks of data from our target rmm. */
48
48
    size = SHARED_SIZE + apr_rmm_overhead_get(FRAG_COUNT + 1);
49
49
    rv = apr_shm_create(&shm, size, NULL, pool);
50
 
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
50
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
51
51
 
52
52
    if (rv != APR_SUCCESS)
53
53
        return;
54
54
 
55
55
    rv = apr_rmm_init(&rmm, NULL, apr_shm_baseaddr_get(shm), size, pool);
56
 
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
56
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
57
57
 
58
58
    if (rv != APR_SUCCESS)
59
59
        return;
93
93
        char **c = apr_rmm_addr_get(rmm, off[i]);
94
94
        for (j = 0; j < FRAG_SIZE; j++, c++) {
95
95
            char *d = apr_itoa(pool, i + j);
96
 
            ABTS_STR_EQUAL(tc, *c, d);
 
96
            ABTS_STR_EQUAL(tc, d, *c);
97
97
        }
98
98
    }
99
99
 
100
100
    /* Freeing each fragment */
101
101
    for (i = 0; i < FRAG_COUNT; i++) {
102
102
        rv = apr_rmm_free(rmm, off[i]);
103
 
        ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
103
        ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
104
104
    }
105
105
 
106
106
    /* Creating one large segment */
114
114
 
115
115
    /* Freeing large segment */
116
116
    rv = apr_rmm_free(rmm, off[0]);
117
 
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
117
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
118
118
 
119
119
    /* Creating each fragment of size fragsize */
120
120
    for (i = 0; i < FRAG_COUNT; i++) {
124
124
    /* Freeing each fragment backwards */
125
125
    for (i = FRAG_COUNT - 1; i >= 0; i--) {
126
126
        rv = apr_rmm_free(rmm, off[i]);
127
 
        ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
127
        ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
128
128
    }
129
129
 
130
130
    /* Creating one large segment (again) */
132
132
 
133
133
    /* Freeing large segment */
134
134
    rv = apr_rmm_free(rmm, off[0]);
135
 
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
135
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
136
136
 
137
137
    /* Checking realloc */
138
138
    off[0] = apr_rmm_calloc(rmm, SHARED_SIZE - 100);
142
142
 
143
143
    entity = apr_rmm_addr_get(rmm, off[1]);
144
144
    rv = apr_rmm_free(rmm, off[0]);
145
 
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
145
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
146
146
 
147
147
    {
148
148
        unsigned char *c = entity;
169
169
    }
170
170
 
171
171
    rv = apr_rmm_destroy(rmm);
172
 
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
172
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
173
173
 
174
174
    rv = apr_shm_destroy(shm);
175
 
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
175
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
176
176
 
177
177
    apr_pool_destroy(pool);
178
178
}