@@ -231,3 +231,44 @@ def test_forked_process_mpi(tmpdir):
231231 # regression test for gh-786, mpi version
232232 darshan_install_path = os .environ .get ("DARSHAN_INSTALL_PATH" )
233233 do_forked_process_test (tmpdir , darshan_install_path )
234+
235+ def test_os_dup (tmpdir ):
236+ # numpy calls Python's os.dup() which in turn was duplicating a file
237+ # descriptor via fcntl
238+ n_ranks = 1
239+ root_path = os .environ .get ("DARSHAN_ROOT_PATH" )
240+ darshan_install_path = os .environ .get ("DARSHAN_INSTALL_PATH" )
241+ test_script_path = os .path .join (root_path ,
242+ "darshan-test" ,
243+ "python_mpi_scripts" ,
244+ "runtime_prog_issue_690.py" )
245+ darshan_lib_path = os .path .join (darshan_install_path ,
246+ "lib" ,
247+ "libdarshan.so" )
248+
249+ with tmpdir .as_cwd ():
250+ cwd = os .getcwd ()
251+ subprocess .check_output (["mpirun" ,
252+ "--allow-run-as-root" ,
253+ "-n" ,
254+ f"{ n_ranks } " ,
255+ "-x" ,
256+ f"LD_PRELOAD={ darshan_lib_path } " ,
257+ "-x" ,
258+ f"DARSHAN_LOGPATH={ cwd } " ,
259+ "python" ,
260+ f"{ test_script_path } " ])
261+
262+ log_file_list = glob .glob ("*.darshan" )
263+ # only a single log file should be generated
264+ # by darshan
265+ assert len (log_file_list ) == 1
266+ path_to_log = os .path .join (cwd , log_file_list [0 ])
267+ # numpy will read a bunch of python files but we only care about the
268+ # numpy file
269+ report = darshan .DarshanReport (path_to_log , filter_patterns = [".npy" ], filter_mode = 'include' )
270+ print ("report:" , report )
271+
272+ # common stuff done. Real check for the "dup via fcntl" issue
273+ posix_counters = report .records ['POSIX' ].to_dict ()[0 ]["counters" ]
274+ assert posix_counters ['POSIX_BYTES_WRITTEN' ] == 928
0 commit comments