#!/usr/bin/python # # Block header comment # # 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) #Tests begin here!!! #Tests bears c.sendline("bears") # Two different unique strings in two versions of bears. assert c.expect_exact(['..--', '--.._']) == 0, "Bears did not exist :(" #Tests cats c.sendline("cats") # Two different unique strings in two versions of cats. assert c.expect_exact(['|^|^|^|^|', 'MM']) == 0, "Cats did not exist :(" #Tests dinosaurs c.sendline("dinosaurs") # Two different unique strings in two versions of dinosaurs. assert c.expect_exact(['________________', '_/:|:']) == 0, "Dinosaurs did not exist :(" #Tests dogs c.sendline("dogs") # Two different unique strings in two versions of dogs. assert c.expect_exact(['##', '@']) == 0, "Dogs did not exist :(" #Tests dragons c.sendline("dragons") # Two different unique strings in two versions of dragons. assert c.expect_exact(['_', 'vwv']) == 0, "Dragons did not exist :(" #Tests frogs c.sendline("frogs") # Two different unique strings in two versions of frogs. assert c.expect_exact(['))', 'hjw']) == 0, "Frogs did not exist :(" #Tests pandas c.sendline("pandas") assert c.expect_exact(['T T', '88888888']) == 0, "Pandas aren't real!!! :(" shellio.success()