File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -268,11 +268,34 @@ def test_os_dup(tmpdir):
268
268
# numpy will read a bunch of python files but we only care about the
269
269
# numpy file
270
270
target_filename = "single_array.npy"
271
- report = darshan . DarshanReport ( path_to_log , filter_patterns = [ target_filename ], filter_mode = 'include' )
271
+
272
272
# common stuff done. Real check for the "dup via fcntl" issue
273
273
274
274
io_module = "POSIX"
275
275
key = "POSIX_BYTES_WRITTEN"
276
- value = report .records [io_module ].to_dict ()[0 ]["counters" ][key ]
277
- print (f"key '{ key } ' has value of '{ value } '" )
278
- assert value == 928
276
+
277
+ # check if log file exists
278
+ if not os .path .isfile (path_to_log ) :
279
+ print (f"Darshan log file '{ path_to_log } ' does not exist" )
280
+ else :
281
+ print (f"Darshan log file '{ path_to_log } '" )
282
+
283
+ try :
284
+ with darshan .DarshanReport (path_to_log , filter_patterns = [target_filename ], filter_mode = 'include' ) as report :
285
+ try :
286
+ records = report .records [io_module ].to_dict ()
287
+ if len (records ) > 0 :
288
+ try :
289
+ value = records [0 ]["counters" ][key ]
290
+ print (f"key '{ key } ' has value of '{ value } '" )
291
+ assert value == 528
292
+ except KeyError :
293
+ print (f"Error: record key '{ key } ' was not found." )
294
+ else :
295
+ print (f"I/O module '{ io_module } ' for file '{ target_filename } ' has no record" )
296
+ except KeyError :
297
+ print (f"I/O module '{ io_module } ' not found" )
298
+ except KeyError :
299
+ print (f"I/O module '{ io_module } ' not found" )
300
+ except RuntimeError :
301
+ print (f"Error: The file '{ path_to_log } ' was not found." )
You can’t perform that action at this time.
0 commit comments