History

selftests/bpf: Fix overflow tests to reflect iter size increase

bpf iter size increase to PAGE_SIZE << 3 means overflow tests assuming page size need to be bumped also.

Alan Maguire committed 6 years ago

Commit eb58bbf1 parent af653201 file · +7 −7Browse files

Unified · Split

tools/testing/selftests/bpf/prog_tests/bpf_iter.c+7−7
@@ -352,7 +352,7 @@ static void test_overflow(bool test_e2big_overflow, bool ret1) · 351 unmodified lines
352 struct bpf_map_info map_info = {};352 struct bpf_map_info map_info = {};
353 struct bpf_iter_test_kern4 *skel;353 struct bpf_iter_test_kern4 *skel;
354 struct bpf_link *link;354 struct bpf_link *link;
355 __u32 page_size;355 __u32 iter_size;
356 char *buf;356 char *buf;
357 357
358 skel = bpf_iter_test_kern4__open();358 skel = bpf_iter_test_kern4__open();
@@ -374,19 +374,19 @@ static void test_overflow(bool test_e2big_overflow, bool ret1) · 15 unmodified lines
374 "map_creation failed: %s\n", strerror(errno)))374 "map_creation failed: %s\n", strerror(errno)))
375 goto free_map1;375 goto free_map1;
376 376
377 /* bpf_seq_printf kernel buffer is one page, so one map377 /* bpf_seq_printf kernel buffer is 8 pages, so one map
378 * bpf_seq_write will mostly fill it, and the other map378 * bpf_seq_write will mostly fill it, and the other map
379 * will partially fill and then trigger overflow and need379 * will partially fill and then trigger overflow and need
380 * bpf_seq_read restart.380 * bpf_seq_read restart.
381 */381 */
382 page_size = sysconf(_SC_PAGE_SIZE);382 iter_size = sysconf(_SC_PAGE_SIZE) << 3;
383 383
384 if (test_e2big_overflow) {384 if (test_e2big_overflow) {
385 skel->rodata->print_len = (page_size + 8) / 8;385 skel->rodata->print_len = (iter_size + 8) / 8;
386 expected_read_len = 2 * (page_size + 8);386 expected_read_len = 2 * (iter_size + 8);
387 } else if (!ret1) {387 } else if (!ret1) {
388 skel->rodata->print_len = (page_size - 8) / 8;388 skel->rodata->print_len = (iter_size - 8) / 8;
389 expected_read_len = 2 * (page_size - 8);389 expected_read_len = 2 * (iter_size - 8);
390 } else {390 } else {
391 skel->rodata->print_len = 1;391 skel->rodata->print_len = 1;
392 expected_read_len = 2 * 8;392 expected_read_len = 2 * 8;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t