Lines Matching +full:reg +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0
33 if (fd == -1) in trace_bytes()
34 return -1; in trace_bytes()
39 if (got == -1) in trace_bytes()
40 return -1; in trace_bytes()
69 return -1; in skip_until_empty_line()
78 return -1; in get_print_fmt()
103 return -1; in get_print_fmt()
113 if (fd == -1) in wait_for_delete()
134 if (fd == -1) in clear()
135 return -1; in clear()
137 if (ioctl(fd, DIAG_IOCSUNREG, &unreg) == -1) in clear()
141 if (ioctl(fd, DIAG_IOCSDEL, "__test_event") == -1) { in clear()
155 return -1; in clear()
160 struct user_reg reg = {0}; in check_print_fmt() local
173 if (fd == -1) in check_print_fmt()
176 reg.size = sizeof(reg); in check_print_fmt()
177 reg.name_args = (__u64)event; in check_print_fmt()
178 reg.enable_bit = 31; in check_print_fmt()
179 reg.enable_addr = (__u64)check; in check_print_fmt()
180 reg.enable_size = sizeof(*check); in check_print_fmt()
183 ret = ioctl(fd, DIAG_IOCSREG, ®); in check_print_fmt()
187 printf("Reg failed in fmt\n"); in check_print_fmt()
211 USER_EVENT_FIXTURE_SETUP(return, self->umount); in FIXTURE_SETUP()
213 self->status_fd = open(status_file, O_RDONLY); in FIXTURE_SETUP()
214 ASSERT_NE(-1, self->status_fd); in FIXTURE_SETUP()
216 self->data_fd = open(data_file, O_RDWR); in FIXTURE_SETUP()
217 ASSERT_NE(-1, self->data_fd); in FIXTURE_SETUP()
219 self->enable_fd = -1; in FIXTURE_SETUP()
223 USER_EVENT_FIXTURE_TEARDOWN(self->umount); in FIXTURE_TEARDOWN()
225 close(self->status_fd); in FIXTURE_TEARDOWN()
226 close(self->data_fd); in FIXTURE_TEARDOWN()
228 if (self->enable_fd != -1) { in FIXTURE_TEARDOWN()
229 write(self->enable_fd, "0", sizeof("0")); in FIXTURE_TEARDOWN()
230 close(self->enable_fd); in FIXTURE_TEARDOWN()
233 if (clear(&self->check) != 0) in FIXTURE_TEARDOWN()
238 struct user_reg reg = {0}; in TEST_F() local
241 reg.size = sizeof(reg); in TEST_F()
242 reg.name_args = (__u64)"__test_event u32 field1; u32 field2"; in TEST_F()
243 reg.enable_bit = 31; in TEST_F()
244 reg.enable_addr = (__u64)&self->check; in TEST_F()
245 reg.enable_size = sizeof(self->check); in TEST_F()
249 unreg.disable_addr = (__u64)&self->check; in TEST_F()
252 ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); in TEST_F()
253 ASSERT_EQ(0, reg.write_index); in TEST_F()
256 ASSERT_EQ(-1, ioctl(self->data_fd, DIAG_IOCSREG, ®)); in TEST_F()
260 reg.enable_bit = 30; in TEST_F()
261 ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); in TEST_F()
262 ASSERT_EQ(0, reg.write_index); in TEST_F()
265 reg.enable_bit = 29; in TEST_F()
266 reg.name_args = (__u64)"__test_event u32 field1;"; in TEST_F()
267 ASSERT_EQ(-1, ioctl(self->data_fd, DIAG_IOCSREG, ®)); in TEST_F()
271 self->enable_fd = open(enable_file, O_RDWR); in TEST_F()
272 ASSERT_NE(-1, self->enable_fd); in TEST_F()
273 ASSERT_NE(-1, write(self->enable_fd, "0", sizeof("0"))) in TEST_F()
276 ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1"))) in TEST_F()
277 ASSERT_EQ(1 << reg.enable_bit, self->check); in TEST_F()
280 ASSERT_NE(-1, write(self->enable_fd, "0", sizeof("0"))) in TEST_F()
281 ASSERT_EQ(0, self->check); in TEST_F()
283 /* File still open should return -EBUSY for delete */ in TEST_F()
284 ASSERT_EQ(-1, ioctl(self->data_fd, DIAG_IOCSDEL, "__test_event")); in TEST_F()
288 ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSUNREG, &unreg)); in TEST_F()
290 ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSUNREG, &unreg)); in TEST_F()
292 /* Delete should have been auto-done after close and unregister */ in TEST_F()
293 close(self->data_fd); in TEST_F()
299 struct user_reg reg = {0}; in TEST_F() local
304 reg.size = sizeof(reg); in TEST_F()
305 reg.name_args = (__u64)"__test_event u32 field1; u32 field2"; in TEST_F()
306 reg.enable_bit = 31; in TEST_F()
307 reg.enable_addr = (__u64)&self->check; in TEST_F()
308 reg.enable_size = sizeof(self->check); in TEST_F()
313 io[0].iov_base = ®.write_index; in TEST_F()
314 io[0].iov_len = sizeof(reg.write_index); in TEST_F()
321 ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); in TEST_F()
322 ASSERT_EQ(0, reg.write_index); in TEST_F()
323 ASSERT_EQ(0, self->check); in TEST_F()
328 ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3)); in TEST_F()
330 io[0].iov_base = ®.write_index; in TEST_F()
331 io[0].iov_len = sizeof(reg.write_index); in TEST_F()
333 /* Write should return -EBADF when event is not enabled */ in TEST_F()
334 ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3)); in TEST_F()
338 self->enable_fd = open(enable_file, O_RDWR); in TEST_F()
339 ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1"))) in TEST_F()
342 ASSERT_NE(1 << reg.enable_bit, self->check); in TEST_F()
346 ASSERT_NE(-1, writev(self->data_fd, (const struct iovec *)io, 3)); in TEST_F()
351 reg.write_index = -1; in TEST_F()
352 ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3)); in TEST_F()
357 struct user_reg reg = {0}; in TEST_F() local
361 reg.size = sizeof(reg); in TEST_F()
362 reg.name_args = (__u64)"__test_event"; in TEST_F()
363 reg.enable_bit = 31; in TEST_F()
364 reg.enable_addr = (__u64)&self->check; in TEST_F()
365 reg.enable_size = sizeof(self->check); in TEST_F()
367 io[0].iov_base = ®.write_index; in TEST_F()
368 io[0].iov_len = sizeof(reg.write_index); in TEST_F()
371 ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); in TEST_F()
372 ASSERT_EQ(0, reg.write_index); in TEST_F()
373 ASSERT_EQ(0, self->check); in TEST_F()
376 self->enable_fd = open(enable_file, O_RDWR); in TEST_F()
377 ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1"))) in TEST_F()
380 ASSERT_EQ(1 << reg.enable_bit, self->check); in TEST_F()
384 ASSERT_NE(-1, writev(self->data_fd, (const struct iovec *)io, 1)); in TEST_F()
390 struct user_reg reg = {0}; in TEST_F() local
395 reg.size = sizeof(reg); in TEST_F()
396 reg.name_args = (__u64)"__test_event u64 anon"; in TEST_F()
397 reg.enable_bit = 31; in TEST_F()
398 reg.enable_addr = (__u64)&self->check; in TEST_F()
399 reg.enable_size = sizeof(self->check); in TEST_F()
401 anon = mmap(NULL, l, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); in TEST_F()
404 io[0].iov_base = ®.write_index; in TEST_F()
405 io[0].iov_len = sizeof(reg.write_index); in TEST_F()
410 ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); in TEST_F()
411 ASSERT_EQ(0, reg.write_index); in TEST_F()
414 self->enable_fd = open(enable_file, O_RDWR); in TEST_F()
415 ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1"))) in TEST_F()
418 ASSERT_NE(-1, writev(self->data_fd, (const struct iovec *)io, 2)); in TEST_F()
420 /* Faulted data should zero fill and work */ in TEST_F()
422 ASSERT_NE(-1, writev(self->data_fd, (const struct iovec *)io, 2)); in TEST_F()
427 struct user_reg reg = {0}; in TEST_F() local
430 char data[8]; in TEST_F() local
433 reg.size = sizeof(reg); in TEST_F()
434 reg.name_args = (__u64)"__test_event __rel_loc char[] data"; in TEST_F()
435 reg.enable_bit = 31; in TEST_F()
436 reg.enable_addr = (__u64)&self->check; in TEST_F()
437 reg.enable_size = sizeof(self->check); in TEST_F()
440 ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); in TEST_F()
441 ASSERT_EQ(0, reg.write_index); in TEST_F()
442 ASSERT_EQ(0, self->check); in TEST_F()
444 io[0].iov_base = ®.write_index; in TEST_F()
445 io[0].iov_len = sizeof(reg.write_index); in TEST_F()
448 io[2].iov_base = data; in TEST_F()
449 bytes = snprintf(data, sizeof(data), "Test") + 1; in TEST_F()
453 ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 1)); in TEST_F()
457 self->enable_fd = open(enable_file, O_RDWR); in TEST_F()
458 ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1"))) in TEST_F()
461 ASSERT_EQ(1 << reg.enable_bit, self->check); in TEST_F()
463 /* Full in-bounds write should work */ in TEST_F()
466 ASSERT_NE(-1, writev(self->data_fd, (const struct iovec *)io, 3)); in TEST_F()
472 ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3)); in TEST_F()
477 ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3)); in TEST_F()
482 ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3)); in TEST_F()
487 ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3)); in TEST_F()
490 /* Non-Null should fault */ in TEST_F()
491 memset(data, 'A', sizeof(data)); in TEST_F()
493 ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3)); in TEST_F()
500 ret = check_print_fmt("__test_event __rel_loc char[] data", in TEST_F()
501 "print fmt: \"data=%s\", __get_rel_str(data)", in TEST_F()
502 &self->check); in TEST_F()
505 ret = check_print_fmt("__test_event __data_loc char[] data", in TEST_F()
506 "print fmt: \"data=%s\", __get_str(data)", in TEST_F()
507 &self->check); in TEST_F()
510 ret = check_print_fmt("__test_event s64 data", in TEST_F()
511 "print fmt: \"data=%lld\", REC->data", in TEST_F()
512 &self->check); in TEST_F()
515 ret = check_print_fmt("__test_event u64 data", in TEST_F()
516 "print fmt: \"data=%llu\", REC->data", in TEST_F()
517 &self->check); in TEST_F()
520 ret = check_print_fmt("__test_event s32 data", in TEST_F()
521 "print fmt: \"data=%d\", REC->data", in TEST_F()
522 &self->check); in TEST_F()
525 ret = check_print_fmt("__test_event u32 data", in TEST_F()
526 "print fmt: \"data=%u\", REC->data", in TEST_F()
527 &self->check); in TEST_F()
530 ret = check_print_fmt("__test_event int data", in TEST_F()
531 "print fmt: \"data=%d\", REC->data", in TEST_F()
532 &self->check); in TEST_F()
535 ret = check_print_fmt("__test_event unsigned int data", in TEST_F()
536 "print fmt: \"data=%u\", REC->data", in TEST_F()
537 &self->check); in TEST_F()
540 ret = check_print_fmt("__test_event s16 data", in TEST_F()
541 "print fmt: \"data=%d\", REC->data", in TEST_F()
542 &self->check); in TEST_F()
545 ret = check_print_fmt("__test_event u16 data", in TEST_F()
546 "print fmt: \"data=%u\", REC->data", in TEST_F()
547 &self->check); in TEST_F()
550 ret = check_print_fmt("__test_event short data", in TEST_F()
551 "print fmt: \"data=%d\", REC->data", in TEST_F()
552 &self->check); in TEST_F()
555 ret = check_print_fmt("__test_event unsigned short data", in TEST_F()
556 "print fmt: \"data=%u\", REC->data", in TEST_F()
557 &self->check); in TEST_F()
560 ret = check_print_fmt("__test_event s8 data", in TEST_F()
561 "print fmt: \"data=%d\", REC->data", in TEST_F()
562 &self->check); in TEST_F()
565 ret = check_print_fmt("__test_event u8 data", in TEST_F()
566 "print fmt: \"data=%u\", REC->data", in TEST_F()
567 &self->check); in TEST_F()
570 ret = check_print_fmt("__test_event char data", in TEST_F()
571 "print fmt: \"data=%d\", REC->data", in TEST_F()
572 &self->check); in TEST_F()
575 ret = check_print_fmt("__test_event unsigned char data", in TEST_F()
576 "print fmt: \"data=%u\", REC->data", in TEST_F()
577 &self->check); in TEST_F()
580 ret = check_print_fmt("__test_event char[4] data", in TEST_F()
581 "print fmt: \"data=%s\", REC->data", in TEST_F()
582 &self->check); in TEST_F()