summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xutil/uart_stress_tester.py12
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.')