Exemplo n.º 1
0

# run a program requiring exclusive access
c.sendline("vi exclusive_vi")

# The following call is necessary to ensure that the SIGTSTP
# we are sending below via 'sendcontrol' reaches the 'sleep' child.
proc_check.wait_until_child_is_in_foreground(c)

#checks the number of active child processes
#using a timeout based process count
proc_check.count_children_timeout(c, 1, 1)

#checks the number of active child processes
#at this moment in time
proc_check.count_active_children(c, 1)

# send SIGTSTP to 'sleep'
c.sendcontrol('z')

# shell should pick up that 'sleep' was stopped and respond with job status
# it should output a line such as [6]+  Stopped                 (sleep 60)
# (note that the provided regexp assumes the job name appears in parentheses,
# adjust your eshoutput.py if needed)
(jobid, statusmsg, cmdline) = \
        shellio.parse_regular_expression(c, def_module.job_status_regex)
assert statusmsg == def_module.jobs_status_msg['stopped'], "Shell did not report stopped job"

# move job into foreground
c.sendline(def_module.builtin_commands['fg'] % jobid)
Exemplo n.º 2
0
# set timeout for all following 'expect*' calls to 2 seconds
c.timeout = 2

# ensure that shell prints expected prompt
assert c.expect(def_module.prompt) == 0, "Shell did not print expected prompt"

# run a command
c.sendline("sleep 60")

# The following call is necessary to ensure that the SIGINT
# we are sending below reaches the 'sleep' child.
# This is NOT a bullet-proof fix, you may fail on occasion!
time.sleep(1)

#checks that our process is running
proc_check.count_active_children(c, 1)

# send SIGINT
c.sendintr()

#prompt check
assert c.expect(def_module.prompt) == 0, "Shell did not print expected prompt"

#checks that the process was ended
proc_check.count_active_children(c, 0)

c.sendline("exit")

assert c.expect_exact("exit\r\n") == 0, "Shell output extraneous characters"

shellio.success()
Exemplo n.º 3
0
# ensure that the shell prints the expected prompt
assert c.expect(def_module.prompt) == 0, "Shell did not print expected prompt"



#Add another job
c.sendline("sleep 300 &")

# pick up the background job output
(jobid, pid) = shellio.parse_regular_expression(c, def_module.bgjob_regex)

assert c.expect(def_module.prompt) == 0, "Shell did not print expected prompt"

#Both jobs need to be active and running before the jobs command is
#sent.  if this isn't so, the test is failed.
proc_check.count_active_children(c, 2)



#Recheck the jobs list
c.sendline(def_module.builtin_commands['jobs'])

#Check the jobs list
(jobid, status_message, command_line) = \
            shellio.parse_regular_expression(c, def_module.job_status_regex) 
(jobid2, status_message2, command_line2) = \
            shellio.parse_regular_expression(c, def_module.job_status_regex)

# Check that the jobs list contains both jobs in some order

#check the first possible order of job statuses, and then