diff options
author | Namyoon Woo <namyoon@chromium.org> | 2019-07-17 16:32:51 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-07-18 22:31:01 +0000 |
commit | 2e24a0b7e37d80aac75a6b9ceffbfc463456df7c (patch) | |
tree | 9f6f21712dec55029f8f9d6d8d4bbd2444574ce3 | |
parent | d70b6e539651b0a8d9d1102a1cce84536d639e5f (diff) | |
download | chrome-ec-2e24a0b7e37d80aac75a6b9ceffbfc463456df7c.tar.gz |
util: uart_stress_tester checks if the given ports exist
During initialization, uart_stress_tester checks each of ports
exists, and raises an error if not.
BUG=None
BRANCH=None
TEST=ran on fleex.
$ uart_stress_tester.py /dev/ttyUSBX -t 120
Error: [Errno 2] No such file or directory: '/dev/ttyUSBX'
$ ./util/uart_stress_tester.py ./util/uart_stress_tester.py -t 120
Error: ./util/uart_stress_tester.py is not a character device.
Change-Id: I989a9e767796b04b059861aea2a3412877c1d739
Signed-off-by: Namyoon Woo <namyoon@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1706626
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rwxr-xr-x | util/uart_stress_tester.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/util/uart_stress_tester.py b/util/uart_stress_tester.py index 2dd5e12515..13828fe84e 100755 --- a/util/uart_stress_tester.py +++ b/util/uart_stress_tester.py @@ -23,6 +23,8 @@ from chromite.lib import cros_logging as logging import argparse import atexit import serial +import os +import stat import sys import threading import time @@ -381,10 +383,20 @@ class ChargenTest(object): ports: List of UART ports to test. duration: Time to keep testing in seconds. cr50_workload: True if a workload should be generated on cr50 + + Raises: + ChargenTestError: if any of ports is not a valid character device. """ # Save the arguments self.ports = ports + for port in ports: + try: + mode = os.stat(port).st_mode + except OSError as e: + raise ChargenTestError(e) + if not stat.S_ISCHR(mode): + raise ChargenTestError('%s is not a character device.' % port) if duration <= 0: raise ChargenTestError('Input error: duration is not positive.') |