Zhizhou Yang | e598690 | 2017-08-10 17:37:53 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python2 |
| 2 | # |
| 3 | # Copyright 2017 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | """Script to discard all the patches added to Android for this suite""" |
| 7 | |
| 8 | from __future__ import print_function |
| 9 | |
| 10 | import config |
| 11 | import os |
| 12 | import subprocess |
| 13 | |
| 14 | |
| 15 | def discard_git(path): |
Zhizhou Yang | 6236292 | 2017-08-30 16:04:36 -0700 | [diff] [blame] | 16 | try: |
| 17 | subprocess.check_call(['git', '-C', path, 'reset']) |
| 18 | subprocess.check_call(['git', '-C', path, 'clean', '-fdx']) |
| 19 | subprocess.check_call(['git', '-C', path, 'stash']) |
| 20 | print('Patch in %s removed successfully!' % path) |
| 21 | except subprocess.CalledProcessError: |
| 22 | print('Error while removing patch in %s' % path) |
Zhizhou Yang | e598690 | 2017-08-10 17:37:53 -0700 | [diff] [blame] | 23 | |
| 24 | |
Zhizhou Yang | e598690 | 2017-08-10 17:37:53 -0700 | [diff] [blame] | 25 | def dispatch_autotest(): |
Zhizhou Yang | 6236292 | 2017-08-30 16:04:36 -0700 | [diff] [blame] | 26 | autotest_dir = os.path.join(config.android_home, config.autotest_dir) |
| 27 | discard_git(autotest_dir) |
Zhizhou Yang | e598690 | 2017-08-10 17:37:53 -0700 | [diff] [blame] | 28 | |
| 29 | |
| 30 | def dispatch_panorama(): |
Zhizhou Yang | 6236292 | 2017-08-30 16:04:36 -0700 | [diff] [blame] | 31 | panorama_dir = os.path.join(config.android_home, |
| 32 | config.bench_dict['Panorama']) |
| 33 | discard_git(panorama_dir) |
| 34 | try: |
| 35 | subprocess.check_call(['rm', '-rf', panorama_dir]) |
| 36 | print('Panorama benchmark directory deleted successfully!') |
| 37 | except subprocess.CalledProcessError: |
| 38 | print('Error deleting Panorama benchmark directory') |
Zhizhou Yang | e598690 | 2017-08-10 17:37:53 -0700 | [diff] [blame] | 39 | |
| 40 | |
| 41 | def dispatch_synthmark(): |
Zhizhou Yang | 6236292 | 2017-08-30 16:04:36 -0700 | [diff] [blame] | 42 | synthmark_dir = 'synthmark' |
| 43 | try: |
| 44 | subprocess.check_call( |
| 45 | ['rm', '-rf', |
| 46 | os.path.join(config.android_home, synthmark_dir)]) |
| 47 | print('Synthmark patch removed successfully!') |
| 48 | except subprocess.CalledProcessError: |
| 49 | print('Synthmark is not removed. Error occurred.') |
Zhizhou Yang | e598690 | 2017-08-10 17:37:53 -0700 | [diff] [blame] | 50 | |
| 51 | |
| 52 | def main(): |
Zhizhou Yang | 6236292 | 2017-08-30 16:04:36 -0700 | [diff] [blame] | 53 | dispatch_autotest() |
| 54 | dispatch_panorama() |
| 55 | dispatch_synthmark() |
Zhizhou Yang | e598690 | 2017-08-10 17:37:53 -0700 | [diff] [blame] | 56 | |
| 57 | |
| 58 | if __name__ == '__main__': |
Zhizhou Yang | 6236292 | 2017-08-30 16:04:36 -0700 | [diff] [blame] | 59 | main() |