diff --git a/autotest/CheckBak/CheckBak.cpp b/autotest/CheckBak/CheckBak.cpp index 41b75be21..898915b86 100644 --- a/autotest/CheckBak/CheckBak.cpp +++ b/autotest/CheckBak/CheckBak.cpp @@ -16,42 +16,56 @@ CONSOLE_APP_MAIN LOG("Filesystem uses " << n << "%"); ASSERT(n > 10 && n < 80); - for(auto dir : Split("/net/nas1/bak;/net/nas/bak;/bak;/big/bak", ';')) { - FindFile ff(dir + "/*"); - Time tm = Time::Low(); - int64 len = 0; - String fn; - - while(ff) { - if(ff.IsFile()) { - Time tm1 = Time(ff.GetLastWriteTime()); - if(tm1 > tm) { - tm = tm1; - len = ff.GetLength(); - fn = ff.GetPath(); - } - } - ff.Next(); - } - - len = len >> 20; - LOG(fn << ", last time: " << tm << ", size " << len << " MB"); + FindFile ff("/bak/*"); + Time tm = Time::Low(); + int64 len = 0; + String fn; - ASSERT(tm >= GetSysDate() - 1); - ASSERT(len > 2000 && len < 4000); + while(ff) { + if(ff.IsFile()) { + Time tm1 = Time(ff.GetLastWriteTime()); + if(tm1 > tm) { + tm = tm1; + len = ff.GetLength(); + fn = ff.GetPath(); + } + } + ff.Next(); + } - String h = Sys("tar -tvf " + fn); - int q = h.Find("root/website.bak/root/bak/forum.fud"); - ASSERT(q >= 17); - String s = h.Mid(q - 17, 17); - Date d; - // 2014-10-30 01:01:56 - // 0123456789012345678 - d.year = atoi(s); - d.month = atoi(~s + 5); - d.day = atoi(~s + 8); - LOG("forum.fud last date: " << d); - ASSERT(d >= GetSysDate() - 1); + LOG(fn << ", last time: " << tm << ", size " << (len >> 20) << " MB"); + + String h = Sys("tar -tvf " + fn); + q = h.Find("root/website.bak/root/bak/forum.fud"); + ASSERT(q >= 17); + s = h.Mid(q - 17, 17); + Date d; + // 2014-10-30 01:01:56 + // 0123456789012345678 + d.year = atoi(s); + d.month = atoi(~s + 5); + d.day = atoi(~s + 8); + LOG("forum.fud last date: " << d); + ASSERT(d >= GetSysDate() - 1); + ASSERT(tm >= GetSysDate() - 1); + len = len >> 20; + ASSERT(len > 2000 && len < 4000); + + for(auto dir : Split("/net/nas1/bak;/net/nas/bak;/big/bak", ';')) { + FileIn in1(fn); + + String p = dir + '/' + GetFileName(fn); + LOG(p); + FileIn in2(p); + + for(;;) { + if(in1.IsEof()) { + ASSERT(in2.IsEof()); + break; + } + ASSERT(!in2.IsEof()); + ASSERT(in1.Get(1 << 20) == in2.Get(1 << 20)); + } } LOG("------------------- OK");