コード例 #1
0
ファイル: TempDirTest.cpp プロジェクト: jvff/mtrace_gtest
TEST(TempDirTest, getName) {
    const char* tempDir = "/tmp/";
    const int length = strlen(tempDir);
    TempDir dir;

    EXPECT_TRUE(strncmp(tempDir, dir.getPath().c_str(), length) == 0);
}
コード例 #2
0
ファイル: TempDirTest.cpp プロジェクト: jvff/mtrace_gtest
TEST(TempDirTest, tempDirExists) {
    TempDir dir;
    struct stat info;

    EXPECT_EQ(stat(dir.getPath().c_str(), &info), 0);
    EXPECT_TRUE(S_ISDIR(info.st_mode));
}
コード例 #3
0
void ArchiveTestCase<ClassFactoryT>::CreateArchive(wxOutputStream& out,
                                                   const wxString& archiver)
{
    // for an external archiver the test data need to be written to
    // temp files
    TempDir tmpdir;

    // write the files
    TestEntries::iterator i;
    for (i = m_testEntries.begin(); i != m_testEntries.end(); ++i) {
        wxFileName fn(i->first, wxPATH_UNIX);
        TestEntry& entry = *i->second;

        if (fn.IsDir()) {
            fn.Mkdir(0777, wxPATH_MKDIR_FULL);
        } else {
            wxFileName::Mkdir(fn.GetPath(), 0777, wxPATH_MKDIR_FULL);
            wxFFileOutputStream fileout(fn.GetFullPath());
            fileout.Write(entry.GetData(), entry.GetSize());
        }
    }

    for (i = m_testEntries.begin(); i != m_testEntries.end(); ++i) {
        wxFileName fn(i->first, wxPATH_UNIX);
        TestEntry& entry = *i->second;
        wxDateTime dt = entry.GetDateTime();
#ifdef __WXMSW__
        if (fn.IsDir())
            entry.SetDateTime(wxDateTime());
        else
#endif
            fn.SetTimes(NULL, &dt, NULL);
    }

    if ((m_options & PipeOut) == 0) {
        wxFileName fn(tmpdir.GetName());
        fn.SetExt(_T("arc"));
        wxString tmparc = fn.GetPath(wxPATH_GET_SEPARATOR) + fn.GetFullName();

        // call the archiver to create an archive file
        system(wxString::Format(archiver, tmparc.c_str()).mb_str());

        // then load the archive file
        {
            wxFFileInputStream in(tmparc);
            if (in.Ok())
                out.Write(in);
        }

        wxRemoveFile(tmparc);
    }
    else {
        // for the non-seekable test, have the archiver output to "-"
        // and read the archive via a pipe
        PFileInputStream in(wxString::Format(archiver, _T("-")));
        if (in.Ok())
            out.Write(in);
    }
}
コード例 #4
0
ファイル: main.cpp プロジェクト: cryfs/copyfs
int main (int argc, char *argv[])
{
  TempDir dir;
  CopyDevice device(dir.path().c_str());
  FilesystemImpl fsimpl(&device);
  Fuse fuse(&fsimpl);
  std::cout << "CopyFS initialized\nBase directory: " << dir.path().c_str() << std::endl;
  fuse.run(argc, argv);
  return 0;
}
コード例 #5
0
void ArchiveTestCase<ClassFactoryT>::ExtractArchive(wxInputStream& in,
                                                    const wxString& unarchiver)
{
    // for an external unarchiver, unarchive to a tempdir
    TempDir tmpdir;

    if ((m_options & PipeIn) == 0) {
        wxFileName fn(tmpdir.GetName());
        fn.SetExt(wxT("arc"));
        wxString tmparc = fn.GetPath(wxPATH_GET_SEPARATOR) + fn.GetFullName();

        if (m_options & Stub)
            in.SeekI(STUB_SIZE * 2);

        // write the archive to a temporary file
        {
            wxFFileOutputStream out(tmparc);
            if (out.IsOk())
                out.Write(in);
        }

        // call unarchiver
        if ( system(wxString::Format(unarchiver, tmparc.c_str()).mb_str()) == -1 )
        {
            wxLogError("Failed to run unarchiver command \"%s\"", unarchiver);
        }

        wxRemoveFile(tmparc);
    }
    else {
        // for the non-seekable test, have the archiver extract "-" and
        // feed it the archive via a pipe
        PFileOutputStream out(wxString::Format(unarchiver, wxT("-")));
        if (out.IsOk())
            out.Write(in);
    }

    wxString dir = tmpdir.GetName();
    VerifyDir(dir);
}
コード例 #6
0
void DirTest::tearDown( void )
{
  Dir d( _sandbox->path() );
  delete _sandbox;
  CPPUNIT_ASSERT( ! d.exists() );
}
コード例 #7
0
void DirTest::setUp( void )
{
  _sandbox = new TempDir;
  CPPUNIT_ASSERT( _sandbox->exists() );
}