diff options
author | Jingjing Liu <jingjingliu@google.com> | 2017-03-23 20:43:56 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-23 20:43:56 +0000 |
commit | c3bfe642eeb6ad98eeb1b181ec9ff6b785059c2a (patch) | |
tree | dc79122d25decbb56b20d50276a6cd1c7a23386c | |
parent | ae7d0852ad2b38993f4c442633d0f928a9915989 (diff) | |
parent | a627049bd0bd745c8e3bf38c962faa0cd0f6de90 (diff) | |
download | adt-infra-c3bfe642eeb6ad98eeb1b181ec9ff6b785059c2a.tar.gz |
Merge "Stabilize test: test_auth_empty_auth_token_file" am: fa8f5ed98a am: dd380614e1
am: a627049bd0
Change-Id: Ie4ec1878f86bff63a64bc7bc82f3be2f2d4dd7fe
-rw-r--r-- | emu_test/test_console/testcase_auth.py | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/emu_test/test_console/testcase_auth.py b/emu_test/test_console/testcase_auth.py index 72364942..d506f233 100644 --- a/emu_test/test_console/testcase_auth.py +++ b/emu_test/test_console/testcase_auth.py @@ -174,20 +174,31 @@ class AuthTest(testcase_base.BaseConsoleTest): # save auth token value and empty contents of auth token file valid_auth_token = util.get_auth_token() - f = open(util.TOKEN_PATH, 'w') - f.close() - # telnet and verify - self.telnet = util.telnet_emulator() - self._verify_auth_command_by_enter_help_command( - util.REGEX_HELP_DISPLAY_AUTH) - - # reset auth token file - f = open(util.TOKEN_PATH, 'w') - f.write(valid_auth_token) - f.close() - - util.exit_emulator_console(self.telnet) + try: + f = open(util.TOKEN_PATH, 'w') + f.close() + + # telnet and verify + self.telnet = util.telnet_emulator() + self._verify_auth_command_by_enter_help_command( + util.REGEX_HELP_DISPLAY_AUTH) + + # reset auth token file + f = open(util.TOKEN_PATH, 'w') + f.write(valid_auth_token) + f.close() + + util.exit_emulator_console(self.telnet) + except IOError as e: + print 'IOError on auth token file.' + finally: + print ('The failure on resetting auth token file back will affact other ' + 'tests running after this test. Hence, reset it again when ' + 'failure happens.') + f = open(util.TOKEN_PATH, 'w') + f.write(valid_auth_token) + f.close() def test_auth_change_auth_token_file_permissions(self): """Test command for: auth <auth_token>. |