@@ -96,28 +96,52 @@ def test_ata_info(self):
96
96
# non-existing device
97
97
msg = r".*Error getting ATA SMART info: /dev/.*: Unable to detect device type"
98
98
with self .assertRaisesRegex (GLib .GError , msg ):
99
- BlockDev .smart_ata_get_info ("/dev/nonexistent" )
99
+ BlockDev .smart_ata_get_info ("/dev/nonexistent" , None )
100
+ msg = r".*Error getting ATA SMART info: /dev/.*: Unknown device type 'xxx'"
101
+ with self .assertRaisesRegex (GLib .GError , msg ):
102
+ BlockDev .smart_ata_get_info ("/dev/nonexistent" , [BlockDev .ExtraArg .new ("--device=xxx" , "" )])
103
+ msg = r".*Error getting ATA SMART info: Smartctl open device: /dev/.* failed: No such device"
104
+ with self .assertRaisesRegex (GLib .GError , msg ):
105
+ BlockDev .smart_ata_get_info ("/dev/nonexistent" , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
100
106
101
107
# LIO device (SCSI)
102
108
self ._setup_lio ()
103
109
self .addCleanup (self ._clean_lio )
104
110
msg = r"Error parsing smartctl JSON data: The member .ata_smart_data. is not defined in the object at the current position."
105
111
with self .assertRaisesRegex (GLib .GError , msg ):
106
- BlockDev .smart_ata_get_info (self .lio_dev )
112
+ BlockDev .smart_ata_get_info (self .lio_dev , None )
113
+ with self .assertRaisesRegex (GLib .GError , msg ):
114
+ BlockDev .smart_ata_get_info (self .lio_dev , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
115
+ msg = r"Error getting ATA SMART info: Device open failed or device did not return an IDENTIFY DEVICE structure."
116
+ with self .assertRaisesRegex (GLib .GError , msg ):
117
+ BlockDev .smart_ata_get_info (self .lio_dev , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
118
+ msg = r"Error getting ATA SMART info: Read NVMe Identify Controller failed: NVME_IOCTL_ADMIN_CMD: Invalid argument"
119
+ with self .assertRaisesRegex (GLib .GError , msg ):
120
+ BlockDev .smart_ata_get_info (self .lio_dev , [BlockDev .ExtraArg .new ("--device=nvme" , "" )])
107
121
108
122
# loop device
109
123
self ._setup_loop ()
110
124
self .addCleanup (self ._clean_loop )
111
125
msg = r".*Error getting ATA SMART info: /dev/.*: Unable to detect device type"
112
126
with self .assertRaisesRegex (GLib .GError , msg ):
113
- BlockDev .smart_ata_get_info (self .loop_dev )
127
+ BlockDev .smart_ata_get_info (self .loop_dev , None )
128
+ msg = r"Error getting ATA SMART info: Device open failed or device did not return an IDENTIFY DEVICE structure."
129
+ with self .assertRaisesRegex (GLib .GError , msg ):
130
+ BlockDev .smart_ata_get_info (self .loop_dev , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
131
+ with self .assertRaisesRegex (GLib .GError , msg ):
132
+ BlockDev .smart_ata_get_info (self .loop_dev , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
114
133
115
134
# scsi_debug
116
135
self ._setup_scsi_debug ()
117
136
self .addCleanup (self ._clean_scsi_debug )
118
137
msg = r"Error parsing smartctl JSON data: The member .ata_smart_data. is not defined in the object at the current position."
119
138
with self .assertRaisesRegex (GLib .GError , msg ):
120
- BlockDev .smart_ata_get_info (self .scsi_debug_dev )
139
+ BlockDev .smart_ata_get_info (self .scsi_debug_dev , None )
140
+ with self .assertRaisesRegex (GLib .GError , msg ):
141
+ BlockDev .smart_ata_get_info (self .scsi_debug_dev , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
142
+ msg = r"Error getting ATA SMART info: Device open failed or device did not return an IDENTIFY DEVICE structure."
143
+ with self .assertRaisesRegex (GLib .GError , msg ):
144
+ BlockDev .smart_ata_get_info (self .scsi_debug_dev , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
121
145
122
146
@tag_test (TestTags .CORE )
123
147
def test_ata_real_dumps_fake_tool (self ):
@@ -213,15 +237,28 @@ def test_smart_enable_disable(self):
213
237
BlockDev .smart_set_enabled ("/dev/nonexistent" , False )
214
238
with self .assertRaisesRegex (GLib .GError , msg ):
215
239
BlockDev .smart_set_enabled ("/dev/nonexistent" , True )
240
+ msg = r"Error setting SMART functionality: Smartctl open device: /dev/.* failed: No such device"
241
+ with self .assertRaisesRegex (GLib .GError , msg ):
242
+ BlockDev .smart_set_enabled ("/dev/nonexistent" , False , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
243
+ with self .assertRaisesRegex (GLib .GError , msg ):
244
+ BlockDev .smart_set_enabled ("/dev/nonexistent" , True , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
216
245
217
246
# LIO device (SCSI)
218
247
self ._setup_lio ()
219
248
self .addCleanup (self ._clean_lio )
220
249
msg = r"Error setting SMART functionality: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure."
221
250
with self .assertRaisesRegex (GLib .GError , msg ):
222
251
BlockDev .smart_set_enabled (self .lio_dev , False )
252
+ with self .assertRaisesRegex (GLib .GError , msg ):
253
+ BlockDev .smart_set_enabled (self .lio_dev , False , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
223
254
# smartctl doesn't report failure when turning SMART on
224
255
BlockDev .smart_set_enabled (self .lio_dev , True )
256
+ BlockDev .smart_set_enabled (self .lio_dev , True , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
257
+ msg = r"Error setting SMART functionality: Device open failed or device did not return an IDENTIFY DEVICE structure."
258
+ with self .assertRaisesRegex (GLib .GError , msg ):
259
+ BlockDev .smart_set_enabled (self .lio_dev , False , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
260
+ with self .assertRaisesRegex (GLib .GError , msg ):
261
+ BlockDev .smart_set_enabled (self .lio_dev , True , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
225
262
226
263
# loop device
227
264
self ._setup_loop ()
@@ -232,12 +269,28 @@ def test_smart_enable_disable(self):
232
269
BlockDev .smart_set_enabled (self .loop_dev , False )
233
270
with self .assertRaisesRegex (GLib .GError , msg ):
234
271
BlockDev .smart_set_enabled (self .loop_dev , True )
272
+ msg = r"Error setting SMART functionality: Device open failed or device did not return an IDENTIFY DEVICE structure."
273
+ with self .assertRaisesRegex (GLib .GError , msg ):
274
+ BlockDev .smart_set_enabled (self .loop_dev , False , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
275
+ with self .assertRaisesRegex (GLib .GError , msg ):
276
+ BlockDev .smart_set_enabled (self .loop_dev , True , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
277
+ with self .assertRaisesRegex (GLib .GError , msg ):
278
+ BlockDev .smart_set_enabled (self .loop_dev , False , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
279
+ with self .assertRaisesRegex (GLib .GError , msg ):
280
+ BlockDev .smart_set_enabled (self .loop_dev , True , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
235
281
236
282
# scsi_debug
237
283
self ._setup_scsi_debug ()
238
284
self .addCleanup (self ._clean_scsi_debug )
239
285
BlockDev .smart_set_enabled (self .scsi_debug_dev , False )
240
286
BlockDev .smart_set_enabled (self .scsi_debug_dev , True )
287
+ BlockDev .smart_set_enabled (self .scsi_debug_dev , False , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
288
+ BlockDev .smart_set_enabled (self .scsi_debug_dev , True , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
289
+ msg = r"Error setting SMART functionality: Device open failed or device did not return an IDENTIFY DEVICE structure."
290
+ with self .assertRaisesRegex (GLib .GError , msg ):
291
+ BlockDev .smart_set_enabled (self .scsi_debug_dev , False , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
292
+ with self .assertRaisesRegex (GLib .GError , msg ):
293
+ BlockDev .smart_set_enabled (self .scsi_debug_dev , True , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
241
294
242
295
@tag_test (TestTags .CORE )
243
296
def test_smart_selftest (self ):
@@ -247,32 +300,48 @@ def test_smart_selftest(self):
247
300
raise unittest .SkipTest ("smartctl executable not found in $PATH, skipping." )
248
301
249
302
# non-existing device
250
- msg = r"Error executing SMART self-test: /dev/.*: Unable to detect device type"
251
303
for t in [BlockDev .SmartSelfTestOp .OFFLINE , BlockDev .SmartSelfTestOp .SHORT ,
252
304
BlockDev .SmartSelfTestOp .LONG , BlockDev .SmartSelfTestOp .CONVEYANCE ,
253
305
BlockDev .SmartSelfTestOp .ABORT ]:
306
+ msg = r"Error executing SMART self-test: /dev/.*: Unable to detect device type"
254
307
with self .assertRaisesRegex (GLib .GError , msg ):
255
308
BlockDev .smart_device_self_test ("/dev/nonexistent" , t )
309
+ msg = r"Error executing SMART self-test: /dev/.*: Unknown device type 'xxx'"
310
+ with self .assertRaisesRegex (GLib .GError , msg ):
311
+ BlockDev .smart_device_self_test ("/dev/nonexistent" , t , [BlockDev .ExtraArg .new ("--device=xxx" , "" )])
312
+ msg = r"Error executing SMART self-test: Smartctl open device: /dev/.* failed: No such device"
313
+ with self .assertRaisesRegex (GLib .GError , msg ):
314
+ BlockDev .smart_device_self_test ("/dev/nonexistent" , t , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
256
315
257
316
# LIO device (SCSI)
258
317
self ._setup_lio ()
259
318
self .addCleanup (self ._clean_lio )
260
- msg = r"Error executing SMART self-test: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure."
261
319
for t in [BlockDev .SmartSelfTestOp .OFFLINE , BlockDev .SmartSelfTestOp .SHORT ,
262
320
BlockDev .SmartSelfTestOp .LONG , BlockDev .SmartSelfTestOp .ABORT ]:
321
+ msg = r"Error executing SMART self-test: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure."
263
322
with self .assertRaisesRegex (GLib .GError , msg ):
264
323
BlockDev .smart_device_self_test (self .lio_dev , t )
324
+ with self .assertRaisesRegex (GLib .GError , msg ):
325
+ BlockDev .smart_device_self_test (self .lio_dev , t , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
326
+ msg = r"Error executing SMART self-test: Device open failed or device did not return an IDENTIFY DEVICE structure."
327
+ with self .assertRaisesRegex (GLib .GError , msg ):
328
+ BlockDev .smart_device_self_test (self .lio_dev , t , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
265
329
BlockDev .smart_device_self_test (self .lio_dev , BlockDev .SmartSelfTestOp .CONVEYANCE )
266
330
267
331
# loop device
268
332
self ._setup_loop ()
269
333
self .addCleanup (self ._clean_loop )
270
- msg = r"Error executing SMART self-test: /dev/.*: Unable to detect device type"
271
334
for t in [BlockDev .SmartSelfTestOp .OFFLINE , BlockDev .SmartSelfTestOp .SHORT ,
272
335
BlockDev .SmartSelfTestOp .LONG , BlockDev .SmartSelfTestOp .CONVEYANCE ,
273
336
BlockDev .SmartSelfTestOp .ABORT ]:
337
+ msg = r"Error executing SMART self-test: /dev/.*: Unable to detect device type"
274
338
with self .assertRaisesRegex (GLib .GError , msg ):
275
339
BlockDev .smart_device_self_test (self .loop_dev , t )
340
+ msg = r"Error executing SMART self-test: Device open failed or device did not return an IDENTIFY DEVICE structure."
341
+ with self .assertRaisesRegex (GLib .GError , msg ):
342
+ BlockDev .smart_device_self_test (self .loop_dev , t , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
343
+ with self .assertRaisesRegex (GLib .GError , msg ):
344
+ BlockDev .smart_device_self_test (self .loop_dev , t , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
276
345
277
346
# scsi_debug
278
347
self ._setup_scsi_debug ()
@@ -281,6 +350,10 @@ def test_smart_selftest(self):
281
350
BlockDev .SmartSelfTestOp .LONG , BlockDev .SmartSelfTestOp .CONVEYANCE ,
282
351
BlockDev .SmartSelfTestOp .ABORT ]:
283
352
BlockDev .smart_device_self_test (self .scsi_debug_dev , t )
353
+ BlockDev .smart_device_self_test (self .scsi_debug_dev , t , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
354
+ msg = r"Error executing SMART self-test: Device open failed or device did not return an IDENTIFY DEVICE structure."
355
+ with self .assertRaisesRegex (GLib .GError , msg ):
356
+ BlockDev .smart_device_self_test (self .scsi_debug_dev , t , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
284
357
285
358
@tag_test (TestTags .CORE )
286
359
def test_scsi_info (self ):
@@ -290,29 +363,49 @@ def test_scsi_info(self):
290
363
raise unittest .SkipTest ("smartctl executable not found in $PATH, skipping." )
291
364
292
365
# non-existing device
293
- msg = r".*Error getting SCSI SMART info: Smartctl open device: /dev/.* failed: No such device"
366
+ msg = r"Error getting SCSI SMART info: /dev/.*: Unable to detect device type"
367
+ with self .assertRaisesRegex (GLib .GError , msg ):
368
+ BlockDev .smart_scsi_get_info ("/dev/nonexistent" , None )
369
+ msg = r"Error getting SCSI SMART info: Smartctl open device: /dev/.* failed: No such device"
294
370
with self .assertRaisesRegex (GLib .GError , msg ):
295
- BlockDev .smart_scsi_get_info ("/dev/nonexistent" )
371
+ BlockDev .smart_scsi_get_info ("/dev/nonexistent" , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
372
+ with self .assertRaisesRegex (GLib .GError , msg ):
373
+ BlockDev .smart_scsi_get_info ("/dev/nonexistent" , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
296
374
297
375
# LIO device (SCSI)
298
376
self ._setup_lio ()
299
- msg = r".*Error getting SCSI SMART info: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure."
377
+ msg = r"Error getting SCSI SMART info: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure."
378
+ with self .assertRaisesRegex (GLib .GError , msg ):
379
+ BlockDev .smart_scsi_get_info (self .lio_dev , None )
300
380
with self .assertRaisesRegex (GLib .GError , msg ):
301
- BlockDev .smart_scsi_get_info (self .lio_dev )
381
+ BlockDev .smart_scsi_get_info (self .lio_dev , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
382
+ msg = r"Error getting SCSI SMART info: Device open failed or device did not return an IDENTIFY DEVICE structure."
383
+ with self .assertRaisesRegex (GLib .GError , msg ):
384
+ BlockDev .smart_scsi_get_info (self .lio_dev , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
302
385
303
386
# loop device
304
387
self ._setup_loop ()
305
388
self .addCleanup (self ._clean_loop )
389
+ msg = r"Error getting SCSI SMART info: /dev/.*: Unable to detect device type"
390
+ with self .assertRaisesRegex (GLib .GError , msg ):
391
+ BlockDev .smart_scsi_get_info (self .loop_dev , None )
306
392
msg = r"Error getting SCSI SMART info: Device open failed or device did not return an IDENTIFY DEVICE structure."
307
393
with self .assertRaisesRegex (GLib .GError , msg ):
308
- BlockDev .smart_scsi_get_info (self .loop_dev )
394
+ BlockDev .smart_scsi_get_info (self .loop_dev , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
395
+ with self .assertRaisesRegex (GLib .GError , msg ):
396
+ BlockDev .smart_scsi_get_info (self .loop_dev , [BlockDev .ExtraArg .new ("--device=ata" , "" )])
309
397
310
398
# scsi_debug
311
399
self ._setup_scsi_debug ()
312
400
self .addCleanup (self ._clean_scsi_debug )
313
- msg = r".*Error getting SCSI SMART info: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure."
401
+ msg = r"Error getting SCSI SMART info: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure."
402
+ with self .assertRaisesRegex (GLib .GError , msg ):
403
+ BlockDev .smart_scsi_get_info (self .scsi_debug_dev , None )
404
+ with self .assertRaisesRegex (GLib .GError , msg ):
405
+ BlockDev .smart_scsi_get_info (self .scsi_debug_dev , [BlockDev .ExtraArg .new ("--device=scsi" , "" )])
406
+ msg = r"Error getting SCSI SMART info: Device open failed or device did not return an IDENTIFY DEVICE structure."
314
407
with self .assertRaisesRegex (GLib .GError , msg ):
315
- BlockDev .smart_scsi_get_info (self .scsi_debug_dev )
408
+ BlockDev .smart_scsi_get_info (self .scsi_debug_dev , [ BlockDev . ExtraArg . new ( "--device=ata" , "" )] )
316
409
317
410
@tag_test (TestTags .CORE )
318
411
def test_scsi_real_dumps (self ):
0 commit comments