Lines Matching refs:test

34  * Privilege test framework.  Each test is encapsulated on a .c file
35 * exporting a function that implements the test. Each test is run from its
56 * If true, some test or preparatory step failed along the execution of this
66 * Registration table of privilege tests. Each test registers a name, a test
67 * function, and a cleanup function to run after the test has completed,
70 static struct test tests[] = {
364 static int tests_count = sizeof(tests) / sizeof(struct test);
367 expect(const char *test, int error, int expected_error, int expected_errno)
373 warnx("%s: returned 0", test);
378 warn("%s: returned (%d, %d)", test, error, errno);
381 warn("%s: returned (%d, %d)", test, error, errno);
387 setup_dir(const char *test, char *dpathp, uid_t uid, gid_t gid, mode_t mode)
392 err(-1, "test %s: mkdtemp", test);
395 err(-1, "test %s: chown(%s, %d, %d)", test, dpathp, uid,
399 err(-1, "test %s: chmod(%s, 0%o)", test, dpathp, mode);
403 setup_file(const char *test, char *fpathp, uid_t uid, gid_t gid, mode_t mode)
410 err(-1, "test %s: mkstemp", test);
413 err(-1, "test %s: fchown(%s, %d, %d)", test, fpathp, uid,
417 err(-1, "test %s: chmod(%s, 0%o)", test, fpathp, mode);
426 set_creds(const char *test, uid_t uid, gid_t gid)
431 err(-1, "test %s: setegid(%d)", test, gid);
433 err(-1, "test %s: setgroups(%d)", test, gid);
435 err(-1, "test %s: seteuid(%d)", test, uid);
439 enter_jail(const char *test)
450 j.hostname = "test";
460 err(-1, "test %s: jail", test);
464 run_child(struct test *test, int asroot, int injail)
467 setprogname(test->t_name);
469 enter_jail(test->t_name);
471 set_creds(test->t_name, UID_OWNER, GID_OWNER);
472 test->t_test_func(asroot, injail, test);
476 * Run a test in a particular credential context -- always call the setup and
477 * cleanup routines; if setup succeeds, also run the test. Test cleanup must
483 run(struct test *test, int asroot, int injail)
487 if (test->t_setup_func != NULL) {
488 if ((test->t_setup_func)(asroot, injail, test) != 0) {
489 warnx("run(%s, %d, %d) setup failed", test->t_name,
498 warn("run(%s, %d, %d) fork failed", test->t_name, asroot,
503 run_child(test, asroot, injail);
513 warn("test: waitpid %s", test->t_name);
529 if (test->t_cleanup_func != NULL)
530 test->t_cleanup_func(asroot, injail, test);
539 * This test suite will need to become quite a bit more enlightened
549 * Run each test four times, varying whether the process is running
550 * as root and in jail in order to test all possible combinations.