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

Side by Side Diff: build/android/pylib/linker/test_case.py

Issue 59033008: android: Make org.chromium.base.SysUtils.isLowEndDevice() work without native code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatting Created 7 years, 1 month 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Base class for linker-specific test cases. 5 """Base class for linker-specific test cases.
6 6
7 The custom dynamic linker can only be tested through a custom test case 7 The custom dynamic linker can only be tested through a custom test case
8 for various technical reasons: 8 for various technical reasons:
9 9
10 - It's an 'invisible feature', i.e. it doesn't expose a new API or 10 - It's an 'invisible feature', i.e. it doesn't expose a new API or
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 # Note that this behaviour doesn't seem to happen when starting an 547 # Note that this behaviour doesn't seem to happen when starting an
548 # application 'normally', i.e. when using the application launcher to 548 # application 'normally', i.e. when using the application launcher to
549 # start the activity. 549 # start the activity.
550 logging.info('Ignoring system\'s low randomization of browser libraries' + 550 logging.info('Ignoring system\'s low randomization of browser libraries' +
551 ' for regular devices') 551 ' for regular devices')
552 552
553 if not renderer_status: 553 if not renderer_status:
554 return ResultType.FAIL, renderer_logs 554 return ResultType.FAIL, renderer_logs
555 555
556 return ResultType.PASS, logs 556 return ResultType.PASS, logs
557
558
559 class LinkerLowMemoryThresholdTest(LinkerTestCaseBase):
560 """This test checks that the definitions for the low-memory device physical
561 RAM threshold are identical in the base/ and linker sources. Because these
562 two components should absolutely not depend on each other, it's difficult
563 to perform this check correctly at runtime inside the linker test binary
564 without introducing hairy dependency issues in the build, or complicated
565 plumbing at runtime.
566
567 To work-around this, this test looks directly into the sources for a
568 definition of the same constant that should look like:
569
570 #define ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB <number>
571
572 And will check that the values for <number> are identical in all of
573 them."""
574
575 # A regular expression used to find the definition of the threshold in all
576 # sources:
577 _RE_THRESHOLD_DEFINITION = re.compile(
578 r'^\s*#\s*define\s+ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB\s+(\d+)\s*$',
579 re.MULTILINE)
580
581 # The list of source files, relative to DIR_SOURCE_ROOT, which must contain
582 # a line that matches the re above.
583 _SOURCES_LIST = [
584 'base/android/sys_utils.cc',
585 'content/common/android/linker/linker_jni.cc' ]
586
587 def _RunTest(self, adb):
588 failure = False
589 values = []
590 # First, collect all the values in all input sources.
591 re = LinkerLowMemoryThresholdTest._RE_THRESHOLD_DEFINITION
592 for source in LinkerLowMemoryThresholdTest._SOURCES_LIST:
593 source_path = os.path.join(constants.DIR_SOURCE_ROOT, source);
594 if not os.path.exists(source_path):
595 logging.error('Missing source file: ' + source_path)
596 failure = True
597 continue
598 with open(source_path) as f:
599 source_text = f.read()
600 # For some reason, re.match() never works here.
601 source_values = re.findall(source_text)
602 if not source_values:
603 logging.error('Missing low-memory threshold definition in ' + \
604 source_path)
605 logging.error('Source:\n%s\n' % source_text)
606 failure = True
607 continue
608 values += source_values
609
610 # Second, check that they are all the same.
611 if not failure:
612 for value in values[1:]:
613 if value != values[0]:
614 logging.error('Value mismatch: ' + repr(values))
615 failure = True
616
617 if failure:
618 return ResultType.FAIL, 'Incorrect low-end memory threshold definitions!'
619
620 return ResultType.PASS, ''
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698