Exemple #1
0
 def do_Mcast(self, args):
     command = docopt(str(self.doc), args)
     e = ExecHelper()
     e.reset("Mcast")
     if command['server']:
         cmd = "python /tmp/mcastfirmware/server.py %s" % (
             command['<filepath>'])
         e.Spawn(cmd)
     elif command['client']:
         cmd = "python /tmp/mcastfirmware/client.py"
         e.Execute(cmd)
     e.Log(e.r.getOutput())
Exemple #2
0
 def do_Process(self, args):
     command = docopt(str(self.doc), args)
     e = ExecHelper()
     e.reset("Process")
     if command["monitor"]:
         psopts = "/bin/ps -C %s o pcpu,pmem --cumulative --no-heading" % (
             command["<name>"])
         e.Log("Executing monitor " + psopts)
         counter = 0
         cpu = float(0)
         mem = float(0)
         while (counter < int(command["<duration>"])):
             pcpu, pmem = self.parse(e.RetOutput(psopts))
             cpu = cpu + pcpu
             mem = mem + pmem
             time.sleep(1)
             counter = counter + 1
         output = "%s consumed %s%% cpu and %s %% memory" % (
             command["<name>"], cpu / counter, mem / counter)
         e.Log(output)
         print output
         if cpu > 0 or mem > 0:
             e.setExecCodes("Process monitor", output, "Pass")
         else:
             e.setExecCodes("Process monitor", output, "Fail")
     elif command["kill"]:
         killopts = "/usr/bin/killall %s" % (command["<name>"])
         e.Log(killopts)
         e.EvalRetVal(killopts)
     elif command["spawn"]:
         spawnopts = ' '.join(command["PATH"])
         e.Log(spawnopts)
         e.Spawn(spawnopts)
     elif command["exec"]:
         execopts = ' '.join(command["PATH"])
         e.Log(execopts)
         execopts = "/bin/sh -c '%s' " % (execopts)
         e.EvalRetVal(execopts)
     elif command["forfeit"]:
         execopts = ' '.join(command["PATH"])
         e.Log(execopts)
         execopts = "/bin/sh -c '%s' " % (execopts)
         e.EvalRetVal(execopts)
         e.r.setRetVal("Fail")
     elif command["thrive"]:
         execopts = ' '.join(command["PATH"])
         e.Log(execopts)
         execopts = "/bin/sh -c '%s' " % (execopts)
         e.EvalRetVal(execopts)
         e.r.setRetVal("Pass")
     elif command["alive"]:
         killopts = "/usr/bin/killall -s 0 %s" % (command["<name>"])
         e.Log(killopts)
         e.EvalRetVal(killopts)
     elif command["dead"]:
         killopts = "pidof %s" % (command["<name>"])
         e.Log(killopts)
         e.EvalRetVal(killopts, 1)
     elif command["pid"]:
         execopts = "pidof %s" % (command["<name>"])
         e.Log(execopts)
         e.EvalRetVal(execopts)
     elif command["output"]:
         #  Process output contains 1360x78  xdpyinfo  | grep dimensions
         execopts = ' '.join(command["PATH"])
         e.Log(execopts)
         execopts = "/bin/sh -c '%s' " % (execopts)
         output = e.RetOutput(execopts)
         if command['<expectation>'] in output:
             e.setExecCodes(execopts, output, "Pass")
         else:
             e.setExecCodes(execopts, output, "Fail")
     e.Log(e.r.getOutput())
     print e.r.getRetVal()
Exemple #3
0
    def do_Selenium(self, args):
        command = docopt(str(self.doc), args)
        e = ExecHelper()
        e.reset("Selenium")
        if command["start"]:
            e.Spawn("python ./agent/cli/bin/SeleniumWorker.py %s" %
                    (command['<which>']))
            time.sleep(5)
            retval, output = self.ReadWorkerResult()
        elif command["stop"]:
            self.SendWorkerCommand("stop")
            retval, output = self.ReadWorkerResult()
        elif command["clickcss"]:
            self.SendWorkerCommand("clickcss " + command['<which>'] + "")
            retval, output = self.ReadWorkerResult()
        elif command["clickname"]:
            self.SendWorkerCommand("clickname " + command['<which>'] + "")
            retval, output = self.ReadWorkerResult()
        elif command["clickid"]:
            self.SendWorkerCommand("clickid " + command['<which>'] + "")
            retval, output = self.ReadWorkerResult()
        elif command["clickxpath"]:
            self.SendWorkerCommand("clickxpath " + command['<which>'] + "")
            retval, output = self.ReadWorkerResult()
        elif command["clickmenuitem"]:
            self.SendWorkerCommand("clickmenuitem " + command['<which>'] + "")
            retval, output = self.ReadWorkerResult()
        elif command["clearcss"]:
            self.SendWorkerCommand("clearcss " + command['<which>'] + "")
            retval, output = self.ReadWorkerResult()
        elif command["clearname"]:
            self.SendWorkerCommand("clearname " + command['<which>'] + "")
            retval, output = self.ReadWorkerResult()
        elif command["clearid"]:
            self.SendWorkerCommand("clearid " + command['<which>'] + "")
            retval, output = self.ReadWorkerResult()
        elif command["clearxpath"]:
            self.SendWorkerCommand("clearxpath " + command['<which>'] + "")
            retval, output = self.ReadWorkerResult()
        elif command["open"]:
            self.SendWorkerCommand("open " + command['<which>'] + "")
            retval, output = self.ReadWorkerResult()
        elif command["fillcss"]:
            self.SendWorkerCommand("fillcss " + command['<which>'] + " " +
                                   ' '.join(command['WHAT']) + "")
            retval, output = self.ReadWorkerResult()
        elif command["fillname"]:
            self.SendWorkerCommand("fillname " + command['<which>'] + " " +
                                   ' '.join(command['WHAT']) + "")
            retval, output = self.ReadWorkerResult()
        elif command["fillid"]:
            self.SendWorkerCommand("fillid " + command['<which>'] + " " +
                                   ' '.join(command['WHAT']) + "")
            retval, output = self.ReadWorkerResult()
        elif command["fillxpath"]:
            self.SendWorkerCommand("fillxpath " + command['<which>'] + " " +
                                   ' '.join(command['WHAT']) + "")
            retval, output = self.ReadWorkerResult()
        elif command["counttags"]:
            self.SendWorkerCommand("counttags " + command['<which>'] + " " +
                                   ' '.join(command['WHAT']) + "")
            retval, output = self.ReadWorkerResult()
        elif command["namecontains"]:
            self.SendWorkerCommand("namecontains " + command['<which>'] + " " +
                                   ' '.join(command['WHAT']) + "")
            retval, output = self.ReadWorkerResult()
        elif command["idcontains"]:
            self.SendWorkerCommand("idcontains " + command['<which>'] + " " +
                                   ' '.join(command['WHAT']) + "")
            retval, output = self.ReadWorkerResult()
        elif command["csscontains"]:
            self.SendWorkerCommand("csscontains " + command['<which>'] + " " +
                                   ' '.join(command['WHAT']) + "")
            retval, output = self.ReadWorkerResult()
        elif command["xpathcontains"]:
            self.SendWorkerCommand("xpathcontains " + command['<which>'] +
                                   " " + ' '.join(command['WHAT']) + "")
            retval, output = self.ReadWorkerResult()
        elif command["pagecontains"]:
            self.SendWorkerCommand("pagecontains " + "null" + " " +
                                   ' '.join(command['WHAT']) + "")
            retval, output = self.ReadWorkerResult()
        else:
            retval, output = "Fail", "Invalid command"

        e.Log(output)
        e.setExecCodes(args, output, retval)