1 #!/usr/bin/env python2.2
2 from __future__
import generators
5 from os
.path
import dirname
, abspath
, join
7 rox_lib
= dirname(dirname(dirname(abspath(sys
.argv
[0]))))
8 sys
.path
.insert(0, join(rox_lib
, 'python'))
10 from rox
import su
, tasks
, g
12 assert os
.getuid() != 0, "Can't run tests as root"
14 class TestSU(unittest
.TestCase
):
17 maker
= su
.SuProxyMaker(
18 'Need to become root to test this module.')
20 root
= maker
.get_root()
22 response
= root
.spawnvpe(os
.P_NOWAIT
, 'false', ['false'])
26 response
= root
.waitpid(pid
, 0)
28 (pid
, status
) = response
.result
29 assert status
== 0x100
31 response
= root
.spawnvpe(os
.P_WAIT
, 'true', ['true'])
33 assert response
.result
== 0
35 response
= root
.getuid()
37 assert response
.result
== 0
39 response
= root
.setuid(os
.getuid())
41 assert response
.result
is None
43 response
= root
.getuid()
45 assert response
.result
== os
.getuid()