Exemple #1
0
TEST(TempDirTest, getName) {
    const char* tempDir = "/tmp/";
    const int length = strlen(tempDir);
    TempDir dir;

    EXPECT_TRUE(strncmp(tempDir, dir.getPath().c_str(), length) == 0);
}
Exemple #2
0
TEST(TempDirTest, tempDirExists) {
    TempDir dir;
    struct stat info;

    EXPECT_EQ(stat(dir.getPath().c_str(), &info), 0);
    EXPECT_TRUE(S_ISDIR(info.st_mode));
}
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);
    }
}
Exemple #4
0
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;
}
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);
}
void DirTest::tearDown( void )
{
  Dir d( _sandbox->path() );
  delete _sandbox;
  CPPUNIT_ASSERT( ! d.exists() );
}
void DirTest::setUp( void )
{
  _sandbox = new TempDir;
  CPPUNIT_ASSERT( _sandbox->exists() );
}