Lines Matching defs:test

1434 static int load_sysctl_prog_insns(struct sysctl_test *test,
1437 struct bpf_insn *prog = test->insns;
1447 if (test->fixup_value_insn) {
1464 if (fixup_sysctl_value(buf, len, prog, test->fixup_value_insn))
1469 if (ret < 0 && test->result != LOAD_REJECT) {
1477 static int load_sysctl_prog_file(struct sysctl_test *test)
1484 attr.file = test->prog_file;
1488 if (test->result != LOAD_REJECT)
1490 test->prog_file);
1497 static int load_sysctl_prog(struct sysctl_test *test, const char *sysctl_path)
1499 return test->prog_file
1500 ? load_sysctl_prog_file(test)
1501 : load_sysctl_prog_insns(test, sysctl_path);
1505 const struct sysctl_test *test)
1510 fd = open(sysctl_path, test->open_flags | O_CLOEXEC);
1514 if (test->seek && lseek(fd, test->seek, SEEK_SET) == -1) {
1515 log_err("lseek(%d) failed", test->seek);
1519 if (test->open_flags == O_RDONLY) {
1524 if (test->oldval &&
1525 strncmp(buf, test->oldval, strlen(test->oldval))) {
1526 log_err("Read value %s != %s", buf, test->oldval);
1529 } else if (test->open_flags == O_WRONLY) {
1530 if (!test->newval) {
1534 if (write(fd, test->newval, strlen(test->newval)) == -1)
1549 static int run_test_case(int cgfd, struct sysctl_test *test)
1551 enum bpf_attach_type atype = test->attach_type;
1556 printf("Test case: %s .. ", test->descr);
1559 test->sysctl);
1561 progfd = load_sysctl_prog(test, sysctl_path);
1563 if (test->result == LOAD_REJECT)
1570 if (test->result == ATTACH_REJECT)
1577 if (access_sysctl(sysctl_path, test) == -1) {
1578 if (test->result == OP_EPERM && errno == EPERM)
1584 if (test->result != SUCCESS) {