diff options
author | YiFei Zhu <zhuyifei@google.com> | 2022-09-09 00:49:40 +0000 |
---|---|---|
committer | Martin KaFai Lau <martin.lau@kernel.org> | 2022-09-09 10:40:45 -0700 |
commit | e42921c3c346b1b49068af3f3881322081e1dddd (patch) | |
tree | 51bf73beda4f03c3931dd87c8fe5a5ea029b19fc /tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c | |
parent | 0ffe2412531e95a309d7f0bfe985fc4ca4d39de8 (diff) | |
download | linux-e42921c3c346b1b49068af3f3881322081e1dddd.tar.gz linux-e42921c3c346b1b49068af3f3881322081e1dddd.tar.bz2 linux-e42921c3c346b1b49068af3f3881322081e1dddd.zip |
selftests/bpf: Deduplicate write_sysctl() to test_progs.c
This helper is needed in multiple tests. Instead of copying it over
and over, better to deduplicate this helper to test_progs.c.
test_progs.c is chosen over testing_helpers.c because of this helper's
use of CHECK / ASSERT_*, and the CHECK was modified to use ASSERT_*
so it does not rely on a duration variable.
Suggested-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: YiFei Zhu <zhuyifei@google.com>
Link: https://lore.kernel.org/r/9b4fc9a27bd52f771b657b4c4090fc8d61f3a6b5.1662682323.git.zhuyifei@google.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c b/tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c index 1fa772079967..f24436d33cd6 100644 --- a/tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c +++ b/tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c @@ -54,26 +54,6 @@ static int create_netns(void) return 0; } -static int write_sysctl(const char *sysctl, const char *value) -{ - int fd, err, len; - - fd = open(sysctl, O_WRONLY); - if (CHECK(fd == -1, "open sysctl", "open(%s): %s (%d)\n", - sysctl, strerror(errno), errno)) - return -1; - - len = strlen(value); - err = write(fd, value, len); - close(fd); - if (CHECK(err != len, "write sysctl", - "write(%s, %s): err:%d %s (%d)\n", - sysctl, value, err, strerror(errno), errno)) - return -1; - - return 0; -} - static void print_hdr_stg(const struct hdr_stg *hdr_stg, const char *prefix) { fprintf(stderr, "%s{active:%u, resend_syn:%u, syncookie:%u, fastopen:%u}\n", |