Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: gft_hwcomp.py

Issue 6875020: factory_test_tools: fix results for HWQual tests (Closed) Base URL: ssh://gitrw.chromium.org:9222/factory_test_tools.git@master
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2011 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 import glob 7 import glob
8 import imp 8 import imp
9 import os 9 import os
10 import pprint 10 import pprint
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 'part_id_ec_flash_chip', 82 'part_id_ec_flash_chip',
83 ] 83 ]
84 84
85 # _not_test_cids and _to_be_tested_cids will be re-created for each match. 85 # _not_test_cids and _to_be_tested_cids will be re-created for each match.
86 _not_test_cids = [] 86 _not_test_cids = []
87 _to_be_tested_cids = [] 87 _to_be_tested_cids = []
88 88
89 # TODO(hungte) unify the 'not available' style messages 89 # TODO(hungte) unify the 'not available' style messages
90 _not_present = '' 90 _not_present = ''
91 _no_match = 'No match' 91 _no_match = 'No match'
92 _failure_list = [_not_present, _no_match, '']
92 93
93 # Type id for connection management (compatible to flimflam) 94 # Type id for connection management (compatible to flimflam)
94 _type_3g = 'cellular' 95 _type_3g = 'cellular'
95 _type_ethernet = 'ethernet' 96 _type_ethernet = 'ethernet'
96 _type_wireless = 'wifi' 97 _type_wireless = 'wifi'
97 98
98 _flimflam_dir = '/usr/local/lib/flimflam/test' 99 _flimflam_dir = '/usr/local/lib/flimflam/test'
99 100
100 def __init__(self, verbose=False): 101 def __init__(self, verbose=False):
101 self._initialized = False 102 self._initialized = False
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 else: 746 else:
746 fetch_enumerable_component(cid) 747 fetch_enumerable_component(cid)
747 748
748 # Complete the threads 749 # Complete the threads
749 for thread in thread_pools: 750 for thread in thread_pools:
750 thread.start() 751 thread.start()
751 for thread in thread_pools: 752 for thread in thread_pools:
752 thread.join() 753 thread.join()
753 return results 754 return results
754 755
756 def format_failure(self, exact_values, approved_values):
757 message_not_present = 'Not Present'
758 actual = [(message_not_present
759 if value in self._failure_list else value)
760 for value in exact_values]
761 expected = [(message_not_present
762 if value in self._failure_list else value)
763 for value in approved_values]
764 return ['Actual: %s' % ', '.join(set(actual)),
765 'Expected: %s' % ' | '.join(set(expected))]
766
755 def check_enumerable_component(self, cid, exact_values, approved_values): 767 def check_enumerable_component(self, cid, exact_values, approved_values):
756 if '*' in approved_values: 768 if '*' in approved_values:
757 return 769 return
758 770
759 unmatched = [value for value in exact_values 771 unmatched = [value for value in exact_values
760 if value not in approved_values] 772 if value not in approved_values]
761 if not unmatched: 773 if not unmatched:
762 return 774 return
763 775
764 # there's some error, let's try to match them in legacy list 776 # there's some error, let's try to match them in legacy list
765 legacy_approved = filter(self.is_legacy_device_record, approved_values) 777 match_goal = [value for value in approved_values
766 if set(legacy_approved) == set(approved_values): 778 if value not in self._failure_list]
779 legacy_approved = filter(self.is_legacy_device_record, match_goal)
780 if match_goal and (set(legacy_approved) == set(match_goal)):
767 DebugMsg('Start legacy search for cid: ' + cid) 781 DebugMsg('Start legacy search for cid: ' + cid)
768 # safe for legacy match
769 # TODO(hungte) prefetch this list in async batch process. 782 # TODO(hungte) prefetch this list in async batch process.
770 legacy_list = self._get_legacy_device_list() 783 legacy_list = self._get_legacy_device_list()
771 matched = list(set(legacy_list).intersection(set(approved_values))) 784 matched = list(set(legacy_list).intersection(set(match_goal)))
772 if matched: 785 if matched:
773 DebugMsg('Changed detected list: %s->%s' % (self._system[cid], matched)) 786 DebugMsg('Changed detected list: %s->%s' % (self._system[cid], matched))
774 self._system[cid] = matched 787 self._system[cid] = matched
775 return 788 return
776 # update with remaining error. 789 # update with remaining error.
777 self._failures[cid] = unmatched 790 self._failures[cid] = self.format_failure(exact_values, approved_values)
778 791
779 @Memorize 792 @Memorize
780 def verify_probable_component(self, cid, approved_values): 793 def verify_probable_component(self, cid, approved_values):
781 if '*' in approved_values: 794 if '*' in approved_values:
782 return (True, ['*']) 795 return (True, ['*'])
783 796
784 for value in approved_values: 797 for value in approved_values:
785 present = getattr(self, 'probe_' + cid)(value) 798 present = getattr(self, 'probe_' + cid)(value)
786 if present: 799 if present:
787 return (True, [value]) 800 return (True, [value])
788 return (False, [self._no_match]) 801 return (False, [self._no_match])
789 802
790 def check_probable_component(self, cid, approved_values): 803 def check_probable_component(self, cid, approved_values):
791 (probed, value) = self.verify_probable_component(cid, approved_values) 804 (probed, value) = self.verify_probable_component(cid, approved_values)
792 if probed: 805 if probed:
793 self._system[cid] = value 806 self._system[cid] = value
794 else: 807 else:
795 self._failures[cid] = value 808 self._failures[cid] = self.format_failure(value, approved_values)
796 809
797 def pformat(self, obj): 810 def pformat(self, obj):
798 return '\n' + self._pp.pformat(obj) + '\n' 811 return '\n' + self._pp.pformat(obj) + '\n'
799 812
800 def initialize(self, force=False, async=False): 813 def initialize(self, force=False, async=False):
801 if self._initialized and not force: 814 if self._initialized and not force:
802 return 815 return
803 # probe current system components 816 # probe current system components
804 DebugMsg('Starting to detect system components...') 817 DebugMsg('Starting to detect system components...')
805 self._enumerable_system = self.get_all_enumerable_components(async) 818 self._enumerable_system = self.get_all_enumerable_components(async)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 print 'Starting to match system...' 882 print 'Starting to match system...'
870 for arg in compdb_list: 883 for arg in compdb_list:
871 (matched, failures) = components.match_current_system(arg) 884 (matched, failures) = components.match_current_system(arg)
872 print 'Probed (%s):' % arg 885 print 'Probed (%s):' % arg
873 print components.pformat(matched) 886 print components.pformat(matched)
874 print 'Failures (%s):' % arg 887 print 'Failures (%s):' % arg
875 print components.pformat(failures) 888 print components.pformat(failures)
876 889
877 if __name__ == '__main__': 890 if __name__ == '__main__':
878 _main(sys.argv[0], sys.argv[1:]) 891 _main(sys.argv[0], sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698