93TEST_CASE( 
"Creating a log file", 
"[libMagAOX::logger::logFileRaw]" )
 
   96    #ifdef XWCTEST_DOXYGEN_REF_PROTECTED 
   99        lfr.createFile( ts1 );
 
  107    SECTION( 
"Two valid timestamps" )
 
  114            std::cerr << 
"\nTESTING-ERROR: testPath is just /tmp, so logName is null.  Can't go on\n";
 
  115            std::cerr << __FILE__ << 
' ' << __LINE__ << 
"\n\n";
 
  121        std::filesystem::remove_all( lfr.
testPath );
 
  127        REQUIRE( rv == mx::error_t::noerror );
 
  128        REQUIRE( std::filesystem::exists( lfr.
testPath ) );
 
  129        REQUIRE( std::filesystem::exists( lfr.
testPath + 
"/2024_11_21/" ) );
 
  130        REQUIRE( std::filesystem::exists( lfr.
testPath + 
"/2024_11_21/" + lfr.
logName() + 
"_20241121063300000000001." +
 
  137        REQUIRE( rv == mx::error_t::noerror );
 
  138        REQUIRE( std::filesystem::exists( lfr.
testPath ) );
 
  139        REQUIRE( std::filesystem::exists( lfr.
testPath + 
"/2025_11_21/" ) );
 
  140        REQUIRE( std::filesystem::exists( lfr.
testPath + 
"/2025_11_21/" + lfr.
logName() + 
"_20251121063300000000050." +
 
  144    SECTION( 
"logPath without permissions" )
 
  147        if( std::filesystem::exists( 
"/lfrtest" ) )
 
  149            std::cerr << 
"\nTESTING-ERROR: path /lsfrtest exists so permission test will be invalid.  Can't go on\n";
 
  150            std::cerr << __FILE__ << 
' ' << __LINE__ << 
"\n\n";
 
  162        REQUIRE( errc != mx::error_t::noerror );
 
  165    SECTION( 
"2nd timestamp is the same as the first, file already exists" )
 
  172            std::cerr << 
"\nTESTING-ERROR: testPath is just /tmp, so logName is null.  Can't go on\n";
 
  173            std::cerr << __FILE__ << 
' ' << __LINE__ << 
"\n\n";
 
  179        std::filesystem::remove_all( lfr.
testPath );
 
  185        REQUIRE( rv == mx::error_t::noerror );
 
  186        REQUIRE( std::filesystem::exists( lfr.
testPath ) );
 
  187        REQUIRE( std::filesystem::exists( lfr.
testPath + 
"/2024_11_21/" ) );
 
  188        REQUIRE( std::filesystem::exists( lfr.
testPath + 
"/2024_11_21/" + lfr.
logName() + 
"_20241121063300000000001." +
 
  195        REQUIRE( rv == mx::error_t::eexist );
 
 
  231TEST_CASE( 
"Writing to a log file", 
"[libMagAOX::logger::logFileRaw]" )
 
  234    #ifdef XWCTEST_DOXYGEN_REF_PROTECTED 
  237        lfr.createFile( ts1 );
 
  239        lfr.writeLog( logbuff );
 
  248    SECTION( 
"Write to existing log" )
 
  255            std::cerr << 
"\nTESTING-ERROR: testPath is just /tmp, so logName is null.  Can't go on\n";
 
  256            std::cerr << __FILE__ << 
' ' << __LINE__ << 
"\n\n";
 
  262        std::filesystem::remove_all( lfr.
testPath );
 
  268        REQUIRE( rv == mx::error_t::noerror );
 
  269        REQUIRE( std::filesystem::exists( lfr.
testPath ) );
 
  270        REQUIRE( std::filesystem::exists( lfr.
testPath + 
"/2024_11_21/" ) );
 
  272        std::string fullPath = lfr.
testPath + 
"/2024_11_21/" + lfr.
logName() + 
"_20241121063300000000001.";
 
  275        REQUIRE( std::filesystem::exists( fullPath ) );
 
  279        std::string          msg( 256, 
't' );
 
  284        REQUIRE( rv == mx::error_t::noerror );
 
  286        REQUIRE( lfr.
close() == mx::error_t::noerror );
 
  288        std::uintmax_t fsz = std::filesystem::file_size( fullPath );
 
  290        REQUIRE( fsz == 1 * ( 256 + 14 ) );
 
  293    SECTION( 
"Write to log that doesn't exist yet" )
 
  300            std::cerr << 
"\nTESTING-ERROR: testPath is just /tmp, so logName is null.  Can't go on\n";
 
  301            std::cerr << __FILE__ << 
' ' << __LINE__ << 
"\n\n";
 
  307        std::filesystem::remove_all( lfr.
testPath );
 
  311        std::string          msg( 256, 
't' );
 
  315        mx::error_t rv = lfr.
writeLog( logbuff );
 
  316        REQUIRE( rv == mx::error_t::noerror );
 
  318        REQUIRE( std::filesystem::exists( lfr.
testPath ) );
 
  319        REQUIRE( std::filesystem::exists( lfr.
testPath + 
"/2024_11_21/" ) );
 
  321        std::string fullPath = lfr.
testPath + 
"/2024_11_21/" + lfr.
logName() + 
"_20241121063300000000002.";
 
  324        REQUIRE( std::filesystem::exists( fullPath ) );
 
  326        REQUIRE( lfr.
close() == mx::error_t::noerror );
 
  328        std::uintmax_t fsz = std::filesystem::file_size( fullPath );
 
  330        REQUIRE( fsz == 1 * ( 256 + 14 ) );
 
  333    SECTION( 
"Write to log twice, does not exceed size" )
 
  340            std::cerr << 
"\nTESTING-ERROR: testPath is just /tmp, so logName is null.  Can't go on\n";
 
  341            std::cerr << __FILE__ << 
' ' << __LINE__ << 
"\n\n";
 
  347        std::filesystem::remove_all( lfr.
testPath );
 
  351        std::string          msg( 256, 
't' );
 
  355        mx::error_t rv = lfr.
writeLog( logbuff );
 
  356        REQUIRE( rv == mx::error_t::noerror );
 
  358        REQUIRE( std::filesystem::exists( lfr.
testPath ) );
 
  359        REQUIRE( std::filesystem::exists( lfr.
testPath + 
"/2024_11_21/" ) );
 
  361        std::string fullPath = lfr.
testPath + 
"/2024_11_21/" + lfr.
logName() + 
"_20241121063300000000002.";
 
  364        REQUIRE( std::filesystem::exists( fullPath ) );
 
  371        REQUIRE( rv == mx::error_t::noerror );
 
  374        std::string fullPath2 = lfr.
testPath + 
"/2024_11_21/" + lfr.
logName() + 
"_20241121063300000000050.";
 
  375        fullPath2 += lfr.
logExt();
 
  377        REQUIRE( !std::filesystem::exists( fullPath2 ) );
 
  381        std::uintmax_t fsz = std::filesystem::file_size( fullPath );
 
  383        REQUIRE( fsz == 2 * ( 256 + 14 ) ); 
 
  386    SECTION( 
"Write to log twice, does exceed size" )
 
  394            std::cerr << 
"\nTESTING-ERROR: testPath is just /tmp, so logName is null.  Can't go on\n";
 
  395            std::cerr << __FILE__ << 
' ' << __LINE__ << 
"\n\n";
 
  401        std::filesystem::remove_all( lfr.
testPath );
 
  405        std::string          msg( 256, 
't' );
 
  409        mx::error_t rv = lfr.
writeLog( logbuff );
 
  410        REQUIRE( rv == mx::error_t::noerror );
 
  412        REQUIRE( std::filesystem::exists( lfr.
testPath ) );
 
  413        REQUIRE( std::filesystem::exists( lfr.
testPath + 
"/2024_11_21/" ) );
 
  415        std::string fullPath = lfr.
testPath + 
"/2024_11_21/" + lfr.
logName() + 
"_20241121063300000000002.";
 
  418        REQUIRE( std::filesystem::exists( fullPath ) );
 
  425        REQUIRE( rv == mx::error_t::noerror );
 
  428        std::string fullPath2 = lfr.
testPath + 
"/2024_11_21/" + lfr.
logName() + 
"_20241121063300000000050.";
 
  429        fullPath2 += lfr.
logExt();
 
  431        REQUIRE( std::filesystem::exists( fullPath2 ) );
 
  434        std::uintmax_t fsz = std::filesystem::file_size( fullPath );
 
  436        REQUIRE( fsz == 1 * ( 256 + 14 ) );
 
  440        fsz = std::filesystem::file_size( fullPath2 );
 
  442        REQUIRE( fsz == 1 * ( 256 + 14 ) );