@@ -294,3 +294,41 @@ TEST_F(TestPosc, TempfileUpdate) {
294294 ASSERT_EQ (rv, -ENOENT) << " Unexpected error when stating POSC file: "
295295 << strerror (errno);
296296}
297+
298+ TEST_F (TestPosc, CreateENOENT) {
299+ XrdSysLogger logger (2 , 0 );
300+ XrdOucEnv env;
301+
302+ XrdVERSIONINFODEF (XrdOssDefault, Oss, XrdVNUMBER, XrdVERSION);
303+
304+ XrdOss *default_oss =
305+ XrdOssDefaultSS (&logger, GetConfigFile ().c_str (), XrdOssDefault);
306+
307+ ASSERT_NE (default_oss, nullptr ) << " Failed to get Posc OSS instance" ;
308+
309+ std::unique_ptr<XrdSysError> log (new XrdSysError (&logger, " posc_" ));
310+ PoscFileSystem *posc_fs_raw;
311+ try {
312+ posc_fs_raw = new PoscFileSystem (default_oss, std::move (log),
313+ GetConfigFile ().c_str (), &env);
314+ } catch (const std::exception &e) {
315+ FAIL () << " Failed to create PoscFileSystem: " << e.what ();
316+ }
317+ std::unique_ptr<PoscFileSystem> posc_fs (posc_fs_raw);
318+
319+ std::unique_ptr<XrdOssDF> fp (posc_fs->newFile ());
320+ ASSERT_NE (fp, nullptr ) << " Failed to create new file object" ;
321+
322+ auto rv = fp->Open (" /subdir/testfile.txt" , O_CREAT | O_RDWR, 0644 , env);
323+ ASSERT_NE (rv, 0 ) << " Open should have failed" ;
324+ ASSERT_EQ (rv, -ENOENT)
325+ << " Open on non-existent path should have resulted in ENOENT: "
326+ << strerror (-rv);
327+
328+ posc_fs->Mkdir (" /subdir" , 0755 , 1 , &env);
329+
330+ rv = fp->Open (" /subdir/testfile.txt" , O_CREAT | O_RDWR, 0644 , env);
331+ ASSERT_EQ (rv, 0 ) << " Open on newly created directory failed: "
332+ << strerror (-rv);
333+ ASSERT_EQ (fp->Close (), 0 ) << " Failed to close file" ;
334+ }
0 commit comments