#!/usr/bin/python # Run with the below command in your src directory # python plugins/134_SuperJobs_test.py eshoutput.py " -p plugins" # import sys, imp, atexit sys.path.append("/home/courses/cs3214/software/pexpect-dpty/"); import pexpect, shellio, signal, time, os, re, proc_check #Ensure the shell process is terminated def force_shell_termination(shell_process): c.close(force=True) #pulling in the regular expression and other definitions definitions_scriptname = sys.argv[1] plugin_dir = sys.argv[2] def_module = imp.load_source('', definitions_scriptname) logfile = None if hasattr(def_module, 'logfile'): logfile = def_module.logfile #spawn an instance of the shell c = pexpect.spawn(def_module.shell + plugin_dir, drainpty=True, logfile=logfile) atexit.register(force_shell_termination, shell_process=c) c.timeout = 2 c.setecho(True) #Add a jobh c.sendline("sleep 300 &") #Add another job c.sendline("sjobs") assert c.expect("Job") == 0, "job prompt did not print" assert c.expect("Status:Running") == 0, "Status section not outputted" assert c.expect("ioInput:") == 0, "ioInput status not found" assert c.expect("ioOutput:") == 0, "ioOutput status not found" assert c.expect("Append:false") == 0, "Append status not found" assert c.expect("Pid:") == 0, "Pid status not found" assert c.expect("sleep 300") == 0, "Command argv not found" assert c.expect("null") == 0, "null values not found" c.sendline("exit") assert c.expect_exact("exit\r\n") == 0, "Shell output extraneous characters" shellio.success()