Brad,
I like this basic structure. The pkg5testutils.py file uses methods that are not available on Windows (os.getuid, os.seteuid). For Windows, this could be written so that it doesn't try to do any UID changing - it just calls portable.is_admin and then runs what it can.

Tom

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

begin:vcard
fn:Tom Mueller
n:Mueller;Tom
org:Sun Microsystems, Inc.;Update Center Software
adr:;;21915 Hillandale Dr;Elkhorn;NE;68022;USA
email;internet:[EMAIL PROTECTED]
title:Senior Staff Engineer
tel;work:877-250-4011
tel;fax:877-250-4011
tel;home:402-916-9943
x-mozilla-html:TRUE
version:2.1
end:vcard

_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to