#!/usr/bin/python # # Test for Fibb # author: Fernando Mendoza(armendo) # 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) ##TESTING## # Testing when incorrect number of arguments c.sendline("fibb"); c.expect("Error trying to load plugin"); c.sendline("fibb 1"); c.expect("Error trying to load plugin"); # Upperbound smaller than lowerbound c.sendline("fibb 2 0"); c.expect("upperBound should be bigger than the lower bound"); # Upperbound bigger than 46(when it is bigger it overflows an integer) c.sendline("fibb 0 100"); c.expect("upperBound should be smaller than 47"); # Negative upper or lower bounds c.sendline("fibb -1 0); c.expect("Only zero or positive numbers are allowed"); shellio.success()