def process_all(self, request): ssh_con = SSHconnection(hostname, username, password, port) print("request = " + request) test_names = request.split("&") result = {} print(test_names) for test in test_names: test = test.replace("testcase=", "") print(test) if test.find("test_ls") != -1: out, err = ssh_con.execute_command("ls /home/pi") print("output from 'ls /home/pi': " + out) result[test] = out elif test.find("test_cd") != -1: out = " " out, err = ssh_con.execute_command("cd /home") #out, err = ssh_con.execute_command("cd /root") print("output from 'cd /root': " + out) if err != "": result[test] = err else: result[test] = out else: result["result"] = "Unknown test case" print(result) ssh_con.close() return result
def test_ls(): ssh_con = SSHconnection(hostname, username, password, port) out, err = ssh_con.execute_command("ls /home/pi") print("output from Raspberry Pi: " + out) # assert out == "" assert out != "" ssh_con.close()
def test_ls(): ssh_con = SSHconnection(hostname, username, password, port) cmd1 = "ls -l /usr" out, err = ssh_con.execute_command(cmd1) print("output from Linux host {}: ".format(hostname, out)) # assert out == "" assert out != "" ssh_con.close()
def test_any_command(cmd): err = "" ssh_con = SSHconnection(hostname, username, password, port) out, err = ssh_con.execute_command(cmd) if err != "": print(err) print("output from '{}': \n {}".format(cmd, out)) ssh_con.close()
def test_ls_negative(): ssh_con = SSHconnection(hostname, username, password, port) out, err = ssh_con.execute_command("ls /not_exists") if out != "": print("output from Raspberry Pi: " + out) raise FileExistsError("Expect error") assert err == "" ssh_con.close()
def process(self, request): ssh_con = SSHconnection(hostname, username, password, port) print("request = " + request) # Execute test based on test case name if request.find("test_ls") != -1: result, err = ssh_con.execute_command("ls /home/pi") print("output from RP: " + result) else: result = "Unknown test case" ssh_con.close() return result
def test_ls_update(): ssh_con = SSHconnection(hostname, username, password, port) out, err = ssh_con.execute_command("ls /home/pi") print("output from Raspberry Pi: " + out) if out == "": result = "fail" else: result = "pass" testid = 1234 testname = "test_ls" testtime = str(datetime.now()) db.execute("UPDATE testrecords SET testtime = ? WHERE (testid = ?)", (testtime, testid)) db.commit() ssh_con.close() assert out != ""
def test_ls(): ssh_con = SSHconnection(hostname, username, password, port) out, err = ssh_con.execute_command("ls /home/pi") print("output from Raspberry Pi: " + out) if out == "": result = "fail" else: result = "pass" testid = 1234 testname = "test_ls" testtime = str(datetime.now()) db.execute("INSERT INTO testrecords VALUES(?, ?, ?, ?)", (testid, testname, result, testtime)) db.commit() ssh_con.close() assert out != ""
def test_ls_negative(): ssh_con = SSHconnection(hostname, username, password, port) # Pass test: # out, err = ssh_con.execute_command("ls /not_exists") # Fail test: out, err = ssh_con.execute_command("ls /home/pi") if out != "": result = "fail" else: result = "pass" testid = 56872 testname = "test_ls_negative" testtime = str(datetime.now()) print("time = " + testtime) db.execute("INSERT INTO testrecords VALUES(?, ?, ?, ?)", (testid, testname, result, testtime)) db.commit() ssh_con.close()