| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Wrapper for tests that are run on builders.""" | 7 """Wrapper for tests that are run on builders.""" |
| 8 | 8 |
| 9 import fileinput | 9 import fileinput |
| 10 import optparse | 10 import optparse |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 print_cmd=False, error_message='Failed to download %s' % zip_url) | 120 print_cmd=False, error_message='Failed to download %s' % zip_url) |
| 121 | 121 |
| 122 ModifyBootDesc(download_folder) | 122 ModifyBootDesc(download_folder) |
| 123 | 123 |
| 124 # Put url in version file so we don't have to do this every time. | 124 # Put url in version file so we don't have to do this every time. |
| 125 fh = open(versioned_url_path, 'w+') | 125 fh = open(versioned_url_path, 'w+') |
| 126 fh.write(zip_url) | 126 fh.write(zip_url) |
| 127 fh.close() | 127 fh.close() |
| 128 | 128 |
| 129 | 129 |
| 130 def RunAUTestHarness(board, channel, latest_url_base, zip_server_base): | 130 def RunAUTestHarness(board, channel, latest_url_base, zip_server_base, |
| 131 no_graphics, type, remote): |
| 131 """Runs the auto update test harness. | 132 """Runs the auto update test harness. |
| 132 | 133 |
| 133 The auto update test harness encapsulates testing the auto-update mechanism | 134 The auto update test harness encapsulates testing the auto-update mechanism |
| 134 for the latest image against the latest official image from the channel. This | 135 for the latest image against the latest official image from the channel. This |
| 135 also tests images with suite_Smoke (built-in as part of its verification | 136 also tests images with suite_Smoke (built-in as part of its verification |
| 136 process). | 137 process). |
| 137 | 138 |
| 138 Args: | 139 Args: |
| 139 board: the board for the latest image. | 140 board: the board for the latest image. |
| 140 channel: the channel to run the au test harness against. | 141 channel: the channel to run the au test harness against. |
| 141 latest_url_base: base url for getting latest links. | 142 latest_url_base: base url for getting latest links. |
| 142 zip_server_base: base url for zipped images. | 143 zip_server_base: base url for zipped images. |
| 144 no_graphics: boolean - If True, disable graphics during vm test. |
| 145 type: which test harness to run. Possible values: real, vm. |
| 146 remote: ip address for real test harness run. |
| 143 """ | 147 """ |
| 144 crosutils_root = os.path.join(os.path.dirname(__file__), '..') | 148 crosutils_root = os.path.join(os.path.dirname(__file__), '..') |
| 145 download_folder = os.path.abspath('latest_download') | 149 download_folder = os.path.abspath('latest_download') |
| 146 zip_url = GetLatestZipUrl(board, channel, latest_url_base, zip_server_base) | 150 zip_url = GetLatestZipUrl(board, channel, latest_url_base, zip_server_base) |
| 147 GrabZipAndExtractImage(zip_url, download_folder, _IMAGE_TO_EXTRACT) | 151 GrabZipAndExtractImage(zip_url, download_folder, _IMAGE_TO_EXTRACT) |
| 148 | 152 |
| 153 no_graphics_flag = '' |
| 154 if no_graphics: no_graphics_flag = '--no_graphics' |
| 155 |
| 149 # Tests go here. | 156 # Tests go here. |
| 150 latest_image = RunCommand(['./get_latest_image.sh', '--board=%s' % board], | 157 latest_image = RunCommand(['./get_latest_image.sh', '--board=%s' % board], |
| 151 cwd=crosutils_root, redirect_stdout=True, | 158 cwd=crosutils_root, redirect_stdout=True, |
| 152 print_cmd=True) | 159 print_cmd=True).strip() |
| 153 | 160 |
| 154 RunCommand(['bin/cros_au_test_harness', | 161 RunCommand(['bin/cros_au_test_harness', |
| 155 '--base_image=%s' % os.path.join(download_folder, | 162 '--base_image=%s' % os.path.join(download_folder, |
| 156 _IMAGE_TO_EXTRACT), | 163 _IMAGE_TO_EXTRACT), |
| 157 '--target_image=%s' % latest_image, | 164 '--target_image=%s' % os.path.join(latest_image, |
| 158 '--board=%s' % board], cwd=crosutils_root) | 165 _IMAGE_TO_EXTRACT), |
| 166 no_graphics_flag, |
| 167 '--board=%s' % board, |
| 168 '--type=%s' % type, |
| 169 '--remote=%s' % remote, |
| 170 ], cwd=crosutils_root) |
| 159 | 171 |
| 160 | 172 |
| 161 def main(): | 173 def main(): |
| 162 parser = optparse.OptionParser() | 174 parser = optparse.OptionParser() |
| 163 parser.add_option('-b', '--board', | 175 parser.add_option('-b', '--board', |
| 164 help='board for the image to compare against.') | 176 help='board for the image to compare against.') |
| 165 parser.add_option('-c', '--channel', | 177 parser.add_option('-c', '--channel', |
| 166 help='channel for the image to compare against.') | 178 help='channel for the image to compare against.') |
| 167 parser.add_option('-l', '--latestbase', | 179 parser.add_option('-l', '--latestbase', |
| 168 help='Base url for latest links.') | 180 help='Base url for latest links.') |
| 169 parser.add_option('-z', '--zipbase', | 181 parser.add_option('-z', '--zipbase', |
| 170 help='Base url for hosted images.') | 182 help='Base url for hosted images.') |
| 183 parser.add_option('--no_graphics', action='store_true', default=False, |
| 184 help='Disable graphics for the vm test.') |
| 185 parser.add_option('--type', default='vm', |
| 186 help='type of test to run: [vm, real]. Default: vm.') |
| 187 parser.add_option('--remote', default='0.0.0.0', |
| 188 help='For real tests, ip address of the target machine.') |
| 189 |
| 171 # Set the usage to include flags. | 190 # Set the usage to include flags. |
| 172 parser.set_usage(parser.format_help()) | 191 parser.set_usage(parser.format_help()) |
| 173 (options, args) = parser.parse_args() | 192 (options, args) = parser.parse_args() |
| 174 | 193 |
| 175 if args: | 194 if args: |
| 176 parser.error('Extra args found %s.' % args) | 195 parser.error('Extra args found %s.' % args) |
| 177 | 196 |
| 178 if not options.board: | 197 if not options.board: |
| 179 parser.error('Need board for image to compare against.') | 198 parser.error('Need board for image to compare against.') |
| 180 | 199 |
| 181 if not options.channel: | 200 if not options.channel: |
| 182 parser.error('Need channel for image to compare against.') | 201 parser.error('Need channel for image to compare against.') |
| 183 | 202 |
| 184 if not options.latestbase: | 203 if not options.latestbase: |
| 185 parser.error('Need latest url base to get images.') | 204 parser.error('Need latest url base to get images.') |
| 186 | 205 |
| 187 if not options.zipbase: | 206 if not options.zipbase: |
| 188 parser.error('Need zip url base to get images.') | 207 parser.error('Need zip url base to get images.') |
| 189 | 208 |
| 190 RunAUTestHarness(options.board, options.channel, options.latestbase, | 209 RunAUTestHarness(options.board, options.channel, options.latestbase, |
| 191 options.zipbase) | 210 options.zipbase, options.no_graphics, options.type, |
| 211 options.remote) |
| 192 | 212 |
| 193 | 213 |
| 194 if __name__ == '__main__': | 214 if __name__ == '__main__': |
| 195 main() | 215 main() |
| OLD | NEW |