Add noise testing "mode" to the new FW test
This adds a mode parameter to the test suite much like it had before.
You can select (default)performance to just run accuracy tests, noise
to only run noise tests or full to run everything you can.
This expands the definitions of the noise tests to include a full
sweep of frequencies like we've been doing with the test now, and
adds some helpful error/warning messages if the user puts in the
wrong arguments on accident.
(Note that the test still doesn't support using a robot since the new
one is coming so soon, it seems like a waste of time to work through
all of that just to re-do it in a month)
BUG=chromium:431777
TEST=manually tested with the function generator. The modes all worked
and the noise tests used the Function generator as expected.
Change-Id: I49f07c062c3814df00df0a22dbaa99fdd08cf777
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/247161
diff --git a/main.py b/main.py
index 5e1f612..21c017c 100644
--- a/main.py
+++ b/main.py
@@ -14,6 +14,7 @@
def parse_arguments():
VALID_DUT_TYPES = ['chromeos', 'android', 'replay']
+ VALID_MODES = ['performance', 'noise', 'full']
VALID_PROTOCOLS = [mt.MTA, mt.MTB, 'auto']
parser = optparse.OptionParser()
@@ -43,6 +44,10 @@
default=False, action='store_true',
help=('Indicate that you have an HP 33120A function '
'generator to automate the electric noise tests.'))
+ parser.add_option('-m', '--mode', dest='mode', default='performance',
+ help=('Which mode to run the test suite in. Options are '
+ '(performance, noise, or full) with performance as '
+ 'the default selection.'))
# Test suite settings
parser.add_option('-i', '--iterations', dest='num_iterations', default=1,
@@ -61,6 +66,10 @@
print 'ERROR: invalid protocol "%s"' % options.protocol
print 'valid protocols are: %s' % str(VALID_PROTOCOLS)
sys.exit(1)
+ if options.mode not in VALID_MODES:
+ print 'ERROR: invalid mode "%s"' % options.mode
+ print 'valid modes are: %s' % str(VALID_MODES)
+ sys.exit(1)
return options, args
diff --git a/test_suite.py b/test_suite.py
index c22e70d..7323c6f 100644
--- a/test_suite.py
+++ b/test_suite.py
@@ -51,6 +51,8 @@
# Compute the list of tests to run
self.tests = tests.generate_test_list(options)
+ if not self.tests:
+ print color.Fore.RED + 'Warning: No tests selected!'
self.curr_test = 0
self.curr_variation = 0
self.curr_iteration = 1
@@ -70,7 +72,8 @@
repeatedly until it returns False to go through all tests, variations,
and iterations.
"""
-
+ if self.curr_test >= len(self.tests):
+ return False
test = self.tests[self.curr_test]
# Print the header for this new test and variation
diff --git a/tests/constants.py b/tests/constants.py
index bf1ec56..c3b344d 100644
--- a/tests/constants.py
+++ b/tests/constants.py
@@ -72,12 +72,9 @@
GV.FAST = 'fast'
GV.FULL_SPEED = 'full_speed'
GV.GESTURE_SPEED = [GV.SLOW, GV.NORMAL, GV.FAST, GV.FULL_SPEED]
-# constants about noise frequency
-GV.LOW_FREQUENCY = '5000Hz'
-GV.MED_FREQUENCY = '500000Hz'
-GV.HIGH_FREQUENCY = '1000000Hz'
# constants used in the extended frequency sweep.
-GV.NOISE_FREQUENCIES = [GV.LOW_FREQUENCY, GV.MED_FREQUENCY, GV.HIGH_FREQUENCY]
+GV.NOISE_SHORT_FREQUENCIES = ['%dHz' % f for f in range(0, 1000000, 100000)]
+GV.NOISE_EXTENDED_FREQUENCIES = ['%dHz' % f for f in range(0, 1000000, 400)]
# constants about noise waveform
GV.SQUARE_WAVE = FunctionGenerator.SQUARE_WAVE
GV.SINE_WAVE = FunctionGenerator.SIN_WAVE
diff --git a/tests/test.py b/tests/test.py
index 1bb8805..12166e8 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -44,7 +44,7 @@
if variation:
formatters = ()
for v in variation:
- formatters += self.subprompt[v]
+ formatters += self.subprompt.get(v, (v,))
prompt = self.prompt.format(*formatters)
return prompt
@@ -63,7 +63,7 @@
for value in variation:
if value in GV.NOISE_WAVEFORMS:
form = value
- elif value in GV.NOISE_FREQUENCIES:
+ elif value in GV.NOISE_SHORT_FREQUENCIES + GV.NOISE_EXTENDED_FREQUENCIES:
frequency = int(value.replace('Hz', ''))
elif value in GV.NOISE_AMPLITUDES:
amplitude = int(value.replace('V', ''))
diff --git a/tests/test_configurations.py b/tests/test_configurations.py
index c76b0bb..dea5334 100644
--- a/tests/test_configurations.py
+++ b/tests/test_configurations.py
@@ -10,6 +10,9 @@
the place to do it.
"""
+import colorama as color
+import sys
+
from constants import GV
from test import Test
from validator import *
@@ -46,11 +49,11 @@
ONE_FINGER_TRACKING_FROM_CENTER = 'one_finger_tracking_from_center'
# Basic tests are ones that require no special hardware to perform
-BASIC_TESTS = [ONE_FINGER_TRACKING, ONE_FINGER_TO_EDGE, TWO_FINGER_TRACKING,
- FINGER_CROSSING, ONE_FINGER_SWIPE, TWO_FINGER_SWIPE, PINCH_TO_ZOOM,
- ONE_FINGER_TAP, TWO_FINGER_TAP, THREE_FINGER_TAP, FOUR_FINGER_TAP,
- FIVE_FINGER_TAP, ONE_FINGER_PHYSICAL_CLICK, TWO_FINGER_PHYSICAL_CLICK,
- STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
+PERFORMANCE_TESTS = [ONE_FINGER_TRACKING, ONE_FINGER_TO_EDGE,
+ TWO_FINGER_TRACKING, FINGER_CROSSING, ONE_FINGER_SWIPE, TWO_FINGER_SWIPE,
+ PINCH_TO_ZOOM, ONE_FINGER_TAP, TWO_FINGER_TAP, THREE_FINGER_TAP,
+ FOUR_FINGER_TAP, FIVE_FINGER_TAP, ONE_FINGER_PHYSICAL_CLICK,
+ TWO_FINGER_PHYSICAL_CLICK, STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
FAT_FINGER_MOVE_WITH_RESTING_FINGER, DRAG_EDGE_THUMB,
TWO_CLOSE_FINGERS_TRACKING, RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
TWO_FAT_FINGERS_TRACKING, FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS,
@@ -58,7 +61,7 @@
]
# These tests require a function generator connected to a probe so the
# test suite can simulate electrical noise conditions.
-FN_GEN_TESTS = [NOISE_LINE, NOISE_STATIONARY]
+NOISE_TESTS = [NOISE_LINE, NOISE_STATIONARY]
# Define the pass/fail criteria for the various validators
@@ -81,27 +84,17 @@
NOISE_STATIONARY:
Test(
name=NOISE_STATIONARY,
- variations=((GV.LOW_FREQUENCY, GV.MED_FREQUENCY, GV.HIGH_FREQUENCY),
- (GV.HALF_AMPLITUDE, GV.MAX_AMPLITUDE),
+ variations=(tuple(GV.NOISE_EXTENDED_FREQUENCIES),
+ (GV.MAX_AMPLITUDE,),
(GV.SQUARE_WAVE,),
- (GV.TL, GV.TR, GV.BL, GV.BR, GV.TS, GV.BS, GV.LS, GV.RS,
- GV.CENTER),
+ (GV.TL, GV.BR, GV.CENTER),
),
prompt='Hold one finger on the {3} of the touch surface with a '
'{0} {1} {2} in noise.',
subprompt={
GV.TL: ('top left corner',),
- GV.TR: ('top right corner',),
- GV.BL: ('bottom left corner',),
GV.BR: ('bottom right corner',),
- GV.TS: ('top edge',),
- GV.BS: ('bottom side',),
- GV.LS: ('left hand side',),
- GV.RS: ('right hand side',),
GV.CENTER: ('center',),
- GV.LOW_FREQUENCY: ('5kHz',),
- GV.MED_FREQUENCY: ('500kHz',),
- GV.HIGH_FREQUENCY: ('1MHz',),
GV.HALF_AMPLITUDE: ('10Vpp',),
GV.MAX_AMPLITUDE: ('20Vpp',),
GV.SQUARE_WAVE: ('square wave',),
@@ -115,21 +108,15 @@
NOISE_LINE:
Test(
name=NOISE_LINE,
- variations=((GV.LOW_FREQUENCY, GV.MED_FREQUENCY, GV.HIGH_FREQUENCY),
- (GV.HALF_AMPLITUDE, GV.MAX_AMPLITUDE),
+ variations=(tuple(GV.NOISE_SHORT_FREQUENCIES),
+ (GV.HALF_AMPLITUDE, GV.MAX_AMPLITUDE,),
(GV.SQUARE_WAVE,),
(GV.BLTR,),
- (GV.NORMAL,),
),
prompt='Draw a straight line from {3} with a {0} {1} {2} in noise.',
subprompt={
- GV.LOW_FREQUENCY: ('5kHz',),
- GV.MED_FREQUENCY: ('500kHz',),
- GV.HIGH_FREQUENCY: ('1MHz',),
- GV.HALF_AMPLITUDE: ('10Vpp',),
GV.MAX_AMPLITUDE: ('20Vpp',),
GV.SQUARE_WAVE: ('square wave',),
- GV.NORMAL: ('',),
GV.BLTR: ('bottom left to top right',),
},
validators=(
@@ -639,8 +626,33 @@
def generate_test_list(options):
- """ Returns a list of all the legal Test objects, given the options """
- test_names = BASIC_TESTS
- if options.has_fn_gen:
- test_names.extend(FN_GEN_TESTS)
+ """ Returns a list of all the legal Test objects, given the options. """
+ test_names = []
+
+ # Performance tests don't require any special equiptment, so for any mode
+ # that includes them, they should always be run.
+ if options.mode in ['full', 'performance']:
+ test_names.extend(PERFORMANCE_TESTS)
+
+ # Noise tests can only be run with a function generator, so we check that
+ # they are both selected and that the function generator is present.
+ if options.mode in ['full', 'noise']:
+ if not options.has_fn_gen:
+ print (color.Fore.RED + 'WARNING: To run noise tests, you need a '
+ 'function generator. Use -f to tell the test suite to look for '
+ 'one, otherwise all noise tests will be skipped!')
+ else:
+ if not options.has_robot:
+ print (color.Fore.RED + 'WARNING: You have selected to run a noise '
+ 'test without a robot. This adds MANY HOURS of additional tests '
+ 'that you will have to do by hand!')
+ choice = None
+ while not choice or choice[0] not in ['n', 'y']:
+ choice = raw_input('Do you REALLY want to do this? (y or n) ').lower()
+ if choice[0] == 'n':
+ sys.exit(1)
+
+ test_names.extend(NOISE_TESTS)
+
+ # Take that generated list of names and lookup the actual Test objects.
return [tests_dict[test_name] for test_name in test_names]