#!/usr/bin/python # # Test the XOR plugin. # import sys, imp, atexit sys.path.append("/home/courses/cs3214/software/pexpect-dpty/"); sys.path.append("../../eshtests/pexpect-dpty/"); import pexpect, shellio, signal, time, os, re, proc_check from stat import ST_MODE #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] 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, drainpty=True, logfile=logfile, args=['-p', 'plugins/']) atexit.register(force_shell_termination, shell_process=c) # Use sleep allow us to peek into the # file descriptors and verify the fds are set up correctly # and that extraneous file descriptors are closed. c.sendline("xor 6 8") (arg1, arg2, result) = \ shellio.parse_regular_expression(c, "(\d*) xor (\d*) = (\d*)") assert arg1 == '6', "Expected the 1st argument to be 6." assert arg2 == '8', "Expected the 2nd argument to be 8." assert result == '14', "Expected the result to be 14." shellio.success()