#!/usr/bin/python # # Test the hex 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 #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("hex 10") (arg, result) = shellio.parse_regular_expression(c, "(\d*)_10 = ([\da-f]*)_16") assert arg == '10', "Expected the 1st argument to be 10." assert result == 'a', "Expected the result to be a." shellio.success()