1 #!/usr/bin/env python2.3
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 exitstatus
= os
.WEXITSTATUS(status
)
30 assert exitstatus
!= 0
32 response
= root
.spawnvpe(os
.P_WAIT
, 'true', ['true'])
34 assert response
.result
== 0
36 response
= root
.getuid()
38 assert response
.result
== 0
40 response
= root
.setuid(os
.getuid())
42 assert response
.result
is None
44 response
= root
.getuid()
46 assert response
.result
== os
.getuid()
54 suite
= unittest
.makeSuite(TestSU
)
55 if __name__
== '__main__':