diff options
author | Shwetha-H-Panduranga <shwetha@gluster.com> | 2011-12-21 12:58:55 +0530 |
---|---|---|
committer | Shwetha-H-Panduranga <shwetha@gluster.com> | 2011-12-21 12:58:55 +0530 |
commit | 50fd16aa865a7230100b71aec0fbbbf767f4652a (patch) | |
tree | 17a947342ce814bdf6232dde9c569d8d5a953702 | |
parent | 7ace3f614ac32c6c0b5121ec8c3f28ea57d22eba (diff) |
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
-rw-r--r-- | libs/utils/atfutils.py | 29 |
1 files changed, 29 insertions, 0 deletions
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): """ """ |