Lines Matching +full:self +full:- +full:test

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 /* Basic per-epoll context busy poll test.
5 * Only tests the ioctls, but should be expanded to test two connected hosts in
55 EXPECT_NE(-1, ret) in FIXTURE_SETUP()
58 self->invalid_fd = ret; in FIXTURE_SETUP()
65 ret = close(self->invalid_fd); in FIXTURE_TEARDOWN()
73 ret = ioctl(self->invalid_fd, EPIOCGPARAMS, &self->params); in TEST_F()
75 EXPECT_EQ(-1, ret) in TEST_F()
81 memset(&self->params, 0, sizeof(struct epoll_params)); in TEST_F()
83 ret = ioctl(self->invalid_fd, EPIOCSPARAMS, &self->params); in TEST_F()
85 EXPECT_EQ(-1, ret) in TEST_F()
105 EXPECT_NE(-1, ret) in FIXTURE_SETUP()
108 self->fd = ret; in FIXTURE_SETUP()
110 self->caps = cap_get_proc(); in FIXTURE_SETUP()
111 EXPECT_NE(NULL, self->caps); in FIXTURE_SETUP()
118 ret = close(self->fd); in FIXTURE_TEARDOWN()
121 ret = cap_free(self->caps); in FIXTURE_TEARDOWN()
122 EXPECT_NE(-1, ret) in FIXTURE_TEARDOWN()
131 * kernel, so set params fields to garbage to test this. in TEST_F()
135 self->params.busy_poll_usecs = 0xff; in TEST_F()
136 self->params.busy_poll_budget = 0xff; in TEST_F()
137 self->params.prefer_busy_poll = 1; in TEST_F()
138 self->params.__pad = 0xf; in TEST_F()
140 ret = ioctl(self->fd, EPIOCGPARAMS, &self->params); in TEST_F()
144 EXPECT_EQ(0, self->params.busy_poll_usecs) in TEST_F()
147 EXPECT_EQ(0, self->params.busy_poll_budget) in TEST_F()
150 EXPECT_EQ(0, self->params.prefer_busy_poll) in TEST_F()
153 EXPECT_EQ(0, self->params.__pad) in TEST_F()
156 self->invalid_params = (struct epoll_params *)0xdeadbeef; in TEST_F()
157 ret = ioctl(self->fd, EPIOCGPARAMS, self->invalid_params); in TEST_F()
159 EXPECT_EQ(-1, ret) in TEST_F()
170 memset(&self->params, 0, sizeof(struct epoll_params)); in TEST_F()
172 self->params.__pad = 1; in TEST_F()
174 ret = ioctl(self->fd, EPIOCSPARAMS, &self->params); in TEST_F()
176 EXPECT_EQ(-1, ret) in TEST_F()
177 TH_LOG("EPIOCSPARAMS non-zero __pad should error"); in TEST_F()
180 TH_LOG("EPIOCSPARAMS non-zero __pad errno should be EINVAL"); in TEST_F()
182 self->params.__pad = 0; in TEST_F()
183 self->params.busy_poll_usecs = (uint32_t)INT_MAX + 1; in TEST_F()
185 ret = ioctl(self->fd, EPIOCSPARAMS, &self->params); in TEST_F()
187 EXPECT_EQ(-1, ret) in TEST_F()
193 self->params.__pad = 0; in TEST_F()
194 self->params.busy_poll_usecs = 32; in TEST_F()
195 self->params.prefer_busy_poll = 2; in TEST_F()
197 ret = ioctl(self->fd, EPIOCSPARAMS, &self->params); in TEST_F()
199 EXPECT_EQ(-1, ret) in TEST_F()
205 self->params.__pad = 0; in TEST_F()
206 self->params.busy_poll_usecs = 32; in TEST_F()
207 self->params.prefer_busy_poll = 1; in TEST_F()
210 self->params.busy_poll_budget = UINT16_MAX; in TEST_F()
212 /* test harness should run with CAP_NET_ADMIN, but let's make sure */ in TEST_F()
215 ret = cap_get_flag(self->caps, CAP_NET_ADMIN, CAP_EFFECTIVE, &tmp); in TEST_F()
220 TH_LOG("expecting CAP_NET_ADMIN to be set for the test harness"); in TEST_F()
225 ret = ioctl(self->fd, EPIOCSPARAMS, &self->params); in TEST_F()
233 ret = cap_set_flag(self->caps, CAP_EFFECTIVE, 1, net_admin, CAP_CLEAR); in TEST_F()
237 ret = cap_set_proc(self->caps); in TEST_F()
242 ret = ioctl(self->fd, EPIOCSPARAMS, &self->params); in TEST_F()
244 EXPECT_EQ(-1, ret) in TEST_F()
251 ret = cap_set_flag(self->caps, CAP_EFFECTIVE, 1, net_admin, CAP_SET); in TEST_F()
255 ret = cap_set_proc(self->caps); in TEST_F()
259 self->invalid_params = (struct epoll_params *)0xdeadbeef; in TEST_F()
260 ret = ioctl(self->fd, EPIOCSPARAMS, self->invalid_params); in TEST_F()
262 EXPECT_EQ(-1, ret) in TEST_F()
273 memset(&self->params, 0, sizeof(struct epoll_params)); in TEST_F()
275 self->params.busy_poll_usecs = 25; in TEST_F()
276 self->params.busy_poll_budget = 16; in TEST_F()
277 self->params.prefer_busy_poll = 1; in TEST_F()
279 ret = ioctl(self->fd, EPIOCSPARAMS, &self->params); in TEST_F()
286 memset(&self->params, 0, sizeof(struct epoll_params)); in TEST_F()
288 ret = ioctl(self->fd, EPIOCGPARAMS, &self->params); in TEST_F()
293 EXPECT_EQ(25, self->params.busy_poll_usecs) in TEST_F()
296 EXPECT_EQ(16, self->params.busy_poll_budget) in TEST_F()
299 EXPECT_EQ(1, self->params.prefer_busy_poll) in TEST_F()
302 EXPECT_EQ(0, self->params.__pad) in TEST_F()
311 ret = ioctl(self->fd, invalid_ioctl, &self->params); in TEST_F()
313 EXPECT_EQ(-1, ret) in TEST_F()