Revision 7b0bf9cd test/ganeti.utils.process_unittest.py

b/test/ganeti.utils.process_unittest.py
225 225
    timeout = 0.2
226 226
    (out, err, status, ta) = \
227 227
      utils.process._RunCmdPipe(cmd, {}, False, "/", False,
228
                                timeout, _linger_timeout=0.2)
228
                                timeout, None, _linger_timeout=0.2)
229 229
    self.assert_(status < 0)
230 230
    self.assertEqual(-status, signal.SIGKILL)
231 231

  
......
308 308
    self.assertRaises(errors.ProgrammerError, utils.RunCmd, ["true"],
309 309
                      output="/dev/null", interactive=True)
310 310

  
311
  def testNocloseFds(self):
312
    """Test selective fd retention (noclose_fds)"""
313
    temp = open(self.fname, "r+")
314
    try:
315
      temp.write("test")
316
      temp.seek(0)
317
      cmd = "read -u %d; echo $REPLY" % temp.fileno()
318
      result = utils.RunCmd(["/bin/bash", "-c", cmd])
319
      self.assertEqual(result.stdout.strip(), "")
320
      temp.seek(0)
321
      result = utils.RunCmd(["/bin/bash", "-c", cmd],
322
                            noclose_fds=[temp.fileno()])
323
      self.assertEqual(result.stdout.strip(), "test")
324
    finally:
325
      temp.close()
326

  
311 327

  
312 328
class TestRunParts(testutils.GanetiTestCase):
313 329
  """Testing case for the RunParts function"""

Also available in: Unified diff