def testFirmwareLocales(self): # This file is probably in src/platform2/regions src_root = os.environ.get( 'CROS_WORKON_SRCROOT', os.path.join(os.path.dirname(__file__), '..', '..', '..')) bmpblk_dir = os.path.join(src_root, 'src', 'platform', 'bmpblk') if not os.path.exists(bmpblk_dir): logging.warn('Skipping testFirmwareLocales, since %r is missing', bmpblk_dir) return bmp_locale_dir = os.path.join(bmpblk_dir, 'strings', 'locale') for r in regions.BuildRegionsDict(include_all=True).values(): checked_paths = [] for l in r.locales: paths = [os.path.join(bmp_locale_dir, l)] if '-' in l: paths.append( os.path.join(bmp_locale_dir, l.partition('-')[0])) if any([os.path.exists(x) for x in paths]): break checked_paths += paths else: if r.region_code in regions.REGIONS: self.fail('For region %r, none of %r exists' % (r.region_code, checked_paths)) else: logging.warn( 'For region %r, none of %r exists; ' 'just a warning since this region is not confirmed', r.region_code, checked_paths)
def testZoneInfo(self): all_regions = regions.BuildRegionsDict(include_all=True) # Make sure all time zones are present in /usr/share/zoneinfo. all_zoneinfos = [os.path.join('/usr/share/zoneinfo', tz) for r in all_regions.values() for tz in r.time_zones] missing = [z for z in all_zoneinfos if not os.path.exists(z)] self.assertFalse(missing, ('Missing zoneinfo files; are timezones misspelled?: %r' % missing))
def testTimeZones(self): for r in regions.BuildRegionsDict(include_all=True).values(): for tz in r.time_zones: if tz not in self.time_zones: if r.region_code in regions.REGIONS: self.fail( 'Missing time zones: %r; does a new time zone need to be added ' 'to CrOS, or does testdata need to be updated?' % tz) else: # This is an unconfirmed region; just print a warning. logging.warn(_WARN_UNKNOWN_DATA_IN_UNCONFIRMED_REGION, 'time zone', tz, r.region_code)
def testLocales(self): missing = [] for r in regions.BuildRegionsDict(include_all=True).values(): for l in r.locales: if l not in self.locales: if r.region_code in regions.REGIONS: missing.append(l) else: logging.warn(_WARN_UNKNOWN_DATA_IN_UNCONFIRMED_REGION, 'locale', l, r.region_code) self.assertFalse( missing, ('Missing locale; does testdata need to be updated?: %r' % missing))
def testInputMethods(self): # Verify that every region is present in the dict. for r in regions.BuildRegionsDict(include_all=True).values(): for k in r.keyboards: resolved_method = self._ResolveInputMethod(k) # Make sure the keyboard method is present. if resolved_method not in self.input_methods: if r.region_code in regions.REGIONS: self.fail('Missing keyboard layout %r (resolved from %r)' % ( resolved_method, k)) else: # This is an unconfirmed region; just print a warning. logging.warn(_WARN_UNKNOWN_DATA_IN_UNCONFIRMED_REGION, 'keyboard', k, r.region_code)
def testNumericIds(self): """Make sure numeric IDs are unique and all regions have a numeric ID.""" numeric_ids = set() for region in regions.BuildRegionsDict(include_all=True).values(): if region.numeric_id is not None: self.assertNotIn(region.numeric_id, numeric_ids, 'Duplicate numeric ID %d in %s' % ( region.numeric_id, region.region_code)) numeric_ids.add(region.numeric_id) # Confirmed regions only if region.region_code in regions.REGIONS: self.assertIsNotNone(region.numeric_id, 'Region %s has no numeric ID assigned' % ( region.region_code))
def testFirmwareLocales(self): bmpblk_dir = os.path.join( os.environ.get('CROS_WORKON_SRCROOT'), 'src', 'platform', 'bmpblk') if not os.path.exists(bmpblk_dir): logging.warn('Skipping testFirmwareLocales, since %r is missing', bmpblk_dir) return bmp_locale_dir = os.path.join(bmpblk_dir, 'strings', 'locale') for r in regions.BuildRegionsDict(include_all=True).values(): for l in r.locales: paths = [os.path.join(bmp_locale_dir, l)] if '-' in l: paths.append(os.path.join(bmp_locale_dir, l.partition('-')[0])) if not any([os.path.exists(x) for x in paths]): if r.region_code in regions.REGIONS: self.fail( 'For region %r, none of %r exists' % (r.region_code, paths)) else: logging.warn('For region %r, none of %r exists; ' 'just a warning since this region is not confirmed', r.region_code, paths)