Generally looks ok to me, though I don't know a great deal about the rules for using seteuid, nor how decorators works. I'm assuming you got those two parts right.
http://cr.opensolaris.org/~bhall/bug-1147/src/tests/pkg5testutils.py.html lines 13-18 and 38-47: I'd expect these lines to either both be in the function returned (like asnonroot), or for neither to be in the function returned (like asroot) but not mixed. Brock Brad Hall wrote: > Hi, > > Link to CR: http://cr.opensolaris.org/~bhall/bug-1147/ > Link to BUG: http://defect.opensolaris.org/bz/show_bug.cgi?id=1147 > > So this is kind of a partial fix to 1147 -- I'm interested if people think > this is the right approach. > > Some tests will fail if they are not run as root so this wad adds decorator > functions (@runasroot, etc) that you can decorate your test functions with if > they require root privs to run. It also adds @runasnonroot, but we don't > actually have any tests like that at the moment. I didn't implement > @runasrootandnonroot yet, but it shouldn't be hard. (And yes, I know the > runasnonroot function is ugly, I'll work on simplifying that) > > class MyTestCase(): > @runasroot > def test_Mytest(): > ... > > If the user isn't root it just spits out that it is skipping those tests (at > the beginning of the test run) and then runs all the tests without that > decorator: > > skipping "cli.t_actions.test_basics_0": must be run as root > skipping "cli.t_actions.test_grouptest": must be run as root > skipping "cli.t_actions.test_usertest": must be run as root > skipping "cli.t_depot.test_bug_1876": must be run as root > skipping "cli.t_pkg_install_basics.test_basics_2": must be run as root > skipping "cli.t_pkg_install_basics.test_basics_3": must be run as root > skipping "cli.t_pkg_install_basics.test_basics_4": must be run as root > skipping "cli.t_pkg_install_basics.test_image_upgrade": must be run as root > skipping "cli.t_commandline.test_info_local_remote": must be run as root > skipping "cli.t_upgrade.test_upgrade1": must be run as root > skipping "cli.t_upgrade.test_upgrade2": must be run as root > > This gets rid of all the ERROR's when running as a normal user, but again I'm > interested in opinions on how to go about this. > > Thanks, > Brad > _______________________________________________ > pkg-discuss mailing list > [email protected] > http://mail.opensolaris.org/mailman/listinfo/pkg-discuss > _______________________________________________ pkg-discuss mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/pkg-discuss
