Merge ~jocave/checkbox-support:usb-write-dmesg-check into checkbox-support:master

Proposed by Jonathan Cave
Status: Merged
Approved by: Jonathan Cave
Approved revision: f6e8d63a366bf933534133b3646a315708189471
Merged at revision: 874221c12da0dc7ed4a5e1076d65ba41697f2b13
Proposed branch: ~jocave/checkbox-support:usb-write-dmesg-check
Merge into: checkbox-support:master
Diff against target: 44 lines (+12/-2)
1 file modified
checkbox_support/scripts/usb_read_write.py (+12/-2)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+377997@code.launchpad.net

Description of the change

Much like the improvement added to udisks2 based usb read/write test in https://code.launchpad.net/~pwlars/plainbox-provider-checkbox/+git/plainbox-provider-checkbox/+merge/376861, this adds a check of dmesg output for I/O errors.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/checkbox_support/scripts/usb_read_write.py b/checkbox_support/scripts/usb_read_write.py
index 9dc63ff..a1edc23 100644
--- a/checkbox_support/scripts/usb_read_write.py
+++ b/checkbox_support/scripts/usb_read_write.py
@@ -36,7 +36,7 @@ PLAINBOX_SESSION_SHARE = os.environ.get('PLAINBOX_SESSION_SHARE', '')
36FOLDER_TO_MOUNT = tempfile.mkdtemp()36FOLDER_TO_MOUNT = tempfile.mkdtemp()
37REPETITION_NUM = 5 # number to repeat the read/write test units.37REPETITION_NUM = 5 # number to repeat the read/write test units.
38# Prepare a random file which size is RANDOM_FILE_SIZE.38# Prepare a random file which size is RANDOM_FILE_SIZE.
39RANDOM_FILE_SIZE = 104857600 # 100 MiB39RANDOM_FILE_SIZE = 104857600 # 100 MiB
40mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')40mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
41mem_mib = mem_bytes/(1024.**2)41mem_mib = mem_bytes/(1024.**2)
42# On systems with less than 1 GiB of RAM, only generate a 20 MiB file42# On systems with less than 1 GiB of RAM, only generate a 20 MiB file
@@ -257,6 +257,8 @@ def write_test_unit(random_file, idx=""):
257 :param random_file: a RandomData object created to be written257 :param random_file: a RandomData object created to be written
258 :return: a float in MB/s to denote writing speed258 :return: a float in MB/s to denote writing speed
259 """259 """
260 # Clear dmesg so we can check for I/O errors later
261 subprocess.check_output(['dmesg', '-C'])
260 target_file = os.path.join(262 target_file = os.path.join(
261 FOLDER_TO_MOUNT, os.path.basename(random_file.tfile.name)) + idx263 FOLDER_TO_MOUNT, os.path.basename(random_file.tfile.name)) + idx
262 process = subprocess.Popen([264 process = subprocess.Popen([
@@ -271,7 +273,6 @@ def write_test_unit(random_file, idx=""):
271 logging.debug(list_dd_message)273 logging.debug(list_dd_message)
272 try:274 try:
273 dd_speed = float(list_dd_message[2].split(" ")[-2])275 dd_speed = float(list_dd_message[2].split(" ")[-2])
274 print("PASS: WRITING TEST: %s" % target_file)
275 except:276 except:
276 # Example:277 # Example:
277 # ['dd: writing to ‘/tmp/tmp08osy45j/tmpnek46on30’: Input/output error'278 # ['dd: writing to ‘/tmp/tmp08osy45j/tmpnek46on30’: Input/output error'
@@ -279,6 +280,15 @@ def write_test_unit(random_file, idx=""):
279 # (20 MB) copied, 99.647 s, 200 kB/s', '']280 # (20 MB) copied, 99.647 s, 200 kB/s', '']
280 print("ERROR: {}".format(list_dd_message))281 print("ERROR: {}".format(list_dd_message))
281 sys.exit(1)282 sys.exit(1)
283 dmesg = subprocess.run(['dmesg'], stdout=subprocess.PIPE)
284 # lp:1852510 - check there weren't any i/o errors sent to dmesg when the
285 # test files were sync'ed to the disk
286 if 'I/O error' in dmesg.stdout.decode():
287 print("ERROR: I/O errors found in dmesg")
288 sys.exit(1)
289 else:
290 logging.debug('No I/O errors found in dmesg')
291 print("PASS: WRITING TEST: %s" % target_file)
282 return dd_speed292 return dd_speed
283293
284294

Subscribers

People subscribed via source and target branches