Blame | Last modification | View Log | Download | RSS feed
#!/usr/bin/python## Tests that esh can run commands in the foreground#import sys, imp, atexitsys.path.append("/home/courses/cs3214/software/pexpect-dpty/");import pexpect, shellio, signal, time, os, re, proc_check#Ensure the shell process is terminateddef force_shell_termination(shell_process):c.close(force=True)#pulling in the regular expression and other definitionsdefinitions_scriptname = sys.argv[1]def_module = imp.load_source('', definitions_scriptname)# start shellc = pexpect.spawn(def_module.shell, drainpty=True, logfile=None)atexit.register(force_shell_termination, shell_process=c)# set timeout for all following 'expect*' calls to 4 secondsc.timeout = 4# ensure that shell prints expected promptassert c.expect(def_module.prompt) == 0, "Shell did not print expected prompt"# run a commandc.sendline("/usr/bin/gcc")assert c.expect("gcc: no input files") == 0, "Shell did not start gcc"# make sure shell returns to promptassert c.expect(def_module.prompt) == 0, "Shell did not print expected prompt"# send EOFc.sendeof()# send SIGINT in case the EOF doesn't quit their shellc.sendintr()shellio.success()