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
1diff --git a/checkbox_support/scripts/usb_read_write.py b/checkbox_support/scripts/usb_read_write.py
2index 9dc63ff..a1edc23 100644
3--- a/checkbox_support/scripts/usb_read_write.py
4+++ b/checkbox_support/scripts/usb_read_write.py
5@@ -36,7 +36,7 @@ PLAINBOX_SESSION_SHARE = os.environ.get('PLAINBOX_SESSION_SHARE', '')
6 FOLDER_TO_MOUNT = tempfile.mkdtemp()
7 REPETITION_NUM = 5 # number to repeat the read/write test units.
8 # Prepare a random file which size is RANDOM_FILE_SIZE.
9-RANDOM_FILE_SIZE = 104857600 # 100 MiB
10+RANDOM_FILE_SIZE = 104857600 # 100 MiB
11 mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
12 mem_mib = mem_bytes/(1024.**2)
13 # On systems with less than 1 GiB of RAM, only generate a 20 MiB file
14@@ -257,6 +257,8 @@ def write_test_unit(random_file, idx=""):
15 :param random_file: a RandomData object created to be written
16 :return: a float in MB/s to denote writing speed
17 """
18+ # Clear dmesg so we can check for I/O errors later
19+ subprocess.check_output(['dmesg', '-C'])
20 target_file = os.path.join(
21 FOLDER_TO_MOUNT, os.path.basename(random_file.tfile.name)) + idx
22 process = subprocess.Popen([
23@@ -271,7 +273,6 @@ def write_test_unit(random_file, idx=""):
24 logging.debug(list_dd_message)
25 try:
26 dd_speed = float(list_dd_message[2].split(" ")[-2])
27- print("PASS: WRITING TEST: %s" % target_file)
28 except:
29 # Example:
30 # ['dd: writing to ‘/tmp/tmp08osy45j/tmpnek46on30’: Input/output error'
31@@ -279,6 +280,15 @@ def write_test_unit(random_file, idx=""):
32 # (20 MB) copied, 99.647 s, 200 kB/s', '']
33 print("ERROR: {}".format(list_dd_message))
34 sys.exit(1)
35+ dmesg = subprocess.run(['dmesg'], stdout=subprocess.PIPE)
36+ # lp:1852510 - check there weren't any i/o errors sent to dmesg when the
37+ # test files were sync'ed to the disk
38+ if 'I/O error' in dmesg.stdout.decode():
39+ print("ERROR: I/O errors found in dmesg")
40+ sys.exit(1)
41+ else:
42+ logging.debug('No I/O errors found in dmesg')
43+ print("PASS: WRITING TEST: %s" % target_file)
44 return dd_speed
45
46

Subscribers

People subscribed via source and target branches