[qmtest] sudo?

Mark Mitchell mark at codesourcery.com
Fri Mar 7 19:01:29 UTC 2003


On Thu, 2003-03-06 at 17:34, John Schmitt wrote:
> 
> I wrote a class that inherited from qm.test.classes.command.ExecTest and
> it works the way I expect.
> 
> Some of the tests I want to run require that they run as root.  How do I
> make ExecTest.RunProgram() pre-pend sudo to my command?  

You'd have to make the command itself begin with "sudo".  You should be
able to do that programmatically in your test class, if you add a
boolean field for "needs to run as root".

> I was surprised that Executable.Spawn() added some information (absolute
> path stuff) to its 'path' variable.  Is that really desired?  Wouldn't
> you want to leave that to the test-writer?

Probably -- but I think that doesn't work correctly on Windows.

> Anyway, interactively invoking Python and then execing sudo didn't do
> what I thought it would do.  It actually terminates my Python session.
> Is that expected?

Yes, that's what exec does.  Our book on "Advanced Linux Programming",
also available online at:

  http://www.advancedlinuxprogramming.com

might be a good reference.

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com




More information about the qmtest mailing list