From 50fd16aa865a7230100b71aec0fbbbf767f4652a Mon Sep 17 00:00:00 2001 From: Shwetha-H-Panduranga Date: Wed, 21 Dec 2011 12:58:55 +0530 Subject: Adding new function validate_output to check whether expected_exit_status and the expected_output matches with the output we got rfom the execution of command --- libs/utils/atfutils.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/libs/utils/atfutils.py b/libs/utils/atfutils.py index 86b2484..b19ef38 100644 --- a/libs/utils/atfutils.py +++ b/libs/utils/atfutils.py @@ -43,6 +43,35 @@ def expect(actual_string, expected_string): return matched +def validate_output(output, expected_exit_status, expected_output): + """ + Parameters: + output: This is dictionary which is return value of + executecommand(ssh module) + + expected_exit_status: exit_status we are expecting + + expected_output : output expected from the execution of command + + Returns: + True: if output we got from the command execution matches with + expected_exit_status and expected_output is + + False: if output doesn't match with expected_exit_status or + expected_output + """ + if expected_exit_status is not 0: + exit_status = assert_failure(**output) + else: + exit_status = assert_success(**output) + + output_status = expect(str(output['stdoutdata']), + expected_output) + if output_status is True and (not exit_status): + return 0 + else: + return 1 + def print_stdout(stdoutdata): """ """ -- cgit