samples/bpf: syscall_tp_user: Rename num_progs into nr_tests
The variable name num_progs causes confusion because that variable really controls the number of rounds the test should be executed. Rename num_progs into nr_tests for the sake of clarity. Signed-off-by: Jinghao Jia <jinghao@linux.ibm.com> Signed-off-by: Ruowen Qin <ruowenq2@illinois.edu> Signed-off-by: Jinghao Jia <jinghao7@illinois.edu> Link: https://lore.kernel.org/r/20230917214220.637721-3-jinghao7@illinois.edu Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
cf67d28de3
commit
0ee352fe0d
@ -17,9 +17,9 @@
|
||||
|
||||
static void usage(const char *cmd)
|
||||
{
|
||||
printf("USAGE: %s [-i num_progs] [-h]\n", cmd);
|
||||
printf(" -i num_progs # number of progs of the test\n");
|
||||
printf(" -h # help\n");
|
||||
printf("USAGE: %s [-i nr_tests] [-h]\n", cmd);
|
||||
printf(" -i nr_tests # rounds of test to run\n");
|
||||
printf(" -h # help\n");
|
||||
}
|
||||
|
||||
static void verify_map(int map_id)
|
||||
@ -45,14 +45,14 @@ static void verify_map(int map_id)
|
||||
}
|
||||
}
|
||||
|
||||
static int test(char *filename, int num_progs)
|
||||
static int test(char *filename, int nr_tests)
|
||||
{
|
||||
int map0_fds[num_progs], map1_fds[num_progs], fd, i, j = 0;
|
||||
struct bpf_link *links[num_progs * 4];
|
||||
struct bpf_object *objs[num_progs];
|
||||
int map0_fds[nr_tests], map1_fds[nr_tests], fd, i, j = 0;
|
||||
struct bpf_link *links[nr_tests * 4];
|
||||
struct bpf_object *objs[nr_tests];
|
||||
struct bpf_program *prog;
|
||||
|
||||
for (i = 0; i < num_progs; i++) {
|
||||
for (i = 0; i < nr_tests; i++) {
|
||||
objs[i] = bpf_object__open_file(filename, NULL);
|
||||
if (libbpf_get_error(objs[i])) {
|
||||
fprintf(stderr, "opening BPF object file failed\n");
|
||||
@ -101,7 +101,7 @@ static int test(char *filename, int num_progs)
|
||||
close(fd);
|
||||
|
||||
/* verify the map */
|
||||
for (i = 0; i < num_progs; i++) {
|
||||
for (i = 0; i < nr_tests; i++) {
|
||||
verify_map(map0_fds[i]);
|
||||
verify_map(map1_fds[i]);
|
||||
}
|
||||
@ -117,13 +117,13 @@ cleanup:
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int opt, num_progs = 1;
|
||||
int opt, nr_tests = 1;
|
||||
char filename[256];
|
||||
|
||||
while ((opt = getopt(argc, argv, "i:h")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
num_progs = atoi(optarg);
|
||||
nr_tests = atoi(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
@ -134,5 +134,5 @@ int main(int argc, char **argv)
|
||||
|
||||
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
||||
|
||||
return test(filename, num_progs);
|
||||
return test(filename, nr_tests);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user