int main(int argc, char **argv) { int lc; const char *msg; if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL) { tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); } setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { /* reset tst_count in case we are looping */ tst_count = 0; for (testno = 0; testno < TST_TOTAL; ++testno) { TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid, *tdat[testno].sgid)); if (TEST_RETURN == EXP_RET_VAL) { if (!test_functionality (tdat[testno].exp_rgid->pw_gid, tdat[testno].exp_egid->pw_gid, tdat[testno].exp_sgid->pw_gid)) { tst_resm(TPASS, "Test for %s " "successful", tdat[testno].desc); } else { tst_resm(TFAIL, "Functionality test " "for %s failed", tdat[testno].desc); } } else { tst_resm(TFAIL, "Test for %s failed; returned" " %ld (expected %d), errno %d (expected" " 0)", tdat[testno].desc, TEST_RETURN, EXP_RET_VAL, TEST_ERRNO); } } } cleanup(); tst_exit(); }
static void setresgid_verify(void) { struct stat buf; TEST(SETRESGID(cleanup, -1, ltpuser->pw_gid, -1)); if (TEST_RETURN != 0) { tst_resm(TFAIL | TTERRNO, "setresgid failed unexpectedly"); return; } SAFE_TOUCH(cleanup, "test_file", 0644, NULL); SAFE_STAT(cleanup, "test_file", &buf); if (ltpuser->pw_gid == buf.st_gid) { tst_resm(TPASS, "setresgid succeeded as expected"); } else { tst_resm(TFAIL, "setresgid failed unexpectedly; egid(%d) - st_gid(%d)", ltpuser->pw_gid, buf.st_gid); } }