MCPcopy Create free account
hub / github.com/axboe/liburing / test_offsets

Function test_offsets

test/reg-wait.c:106–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106static int test_offsets(struct io_uring *ring, struct io_uring_reg_wait *base,
107 size_t size, bool overallocated)
108{
109 struct io_uring_cqe *cqe;
110 int max_index = size / sizeof(struct io_uring_reg_wait);
111 struct io_uring_reg_wait *rw;
112 unsigned long offset;
113 int copy_size;
114 void *rw_ptr;
115 int ret;
116
117 rw = base;
118 memcpy(rw, &brief_wait, sizeof(brief_wait));
119 ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, 0);
120 if (ret != -ETIME) {
121 fprintf(stderr, "0 index failed: %d\n", ret);
122 return T_EXIT_FAIL;
123 }
124
125 if (overallocated) {
126 rw = base + max_index;
127 memcpy(rw, &brief_wait, sizeof(brief_wait));
128 }
129 ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, max_index);
130 if (ret != -EFAULT) {
131 fprintf(stderr, "max+1 index failed: %d\n", ret);
132 return T_EXIT_FAIL;
133 }
134
135 rw = base + max_index - 1;
136 memcpy(rw, &brief_wait, sizeof(brief_wait));
137 ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, max_index - 1);
138 if (ret != -ETIME) {
139 fprintf(stderr, "last index failed: %d\n", ret);
140 return T_EXIT_FAIL;
141 }
142
143 offset = 0UL - sizeof(long);
144 ret = test_wait_reg_offset(ring, 1, offset);
145 if (ret != -EFAULT) {
146 fprintf(stderr, "overflow offset failed: %d\n", ret);
147 return T_EXIT_FAIL;
148 }
149
150 offset = size - sizeof(long);
151 rw = (void *)base + offset;
152 copy_size = overallocated ? sizeof(brief_wait) : sizeof(long);
153 memcpy(rw, &brief_wait, copy_size);
154
155 ret = test_wait_reg_offset(ring, 1, offset);
156 if (ret != -EFAULT) {
157 fprintf(stderr, "OOB offset failed: %d\n", ret);
158 return T_EXIT_FAIL;
159 }
160
161 offset = 1;
162 rw_ptr = (void *) base + offset;
163 memcpy(rw_ptr, &brief_wait, sizeof(brief_wait));

Callers 2

test_wait_argFunction · 0.70
test_region_buffer_typesFunction · 0.70

Calls 2

test_wait_reg_offsetFunction · 0.85

Tested by

no test coverage detected