예제 #1
0
TEST(FileSystemIterator, multipleFiles)
{
    TestDirectory rootDir(File("foobarfolder"));
    rootDir.addFile("foobar1.txt");
    rootDir.addFile("foobar2.txt");
    rootDir.addFile("foobar3.txt");
    rootDir.addFile("foobar4.txt");
    rootDir.addFile("foobar5.txt");

    HashSet<String> filenames;
    filenames.put("foobar1.txt");
    filenames.put("foobar2.txt");
    filenames.put("foobar3.txt");
    filenames.put("foobar4.txt");
    filenames.put("foobar5.txt");


    FileSystemIterator iter(rootDir.getFile());
    while (iter.isValid())
    {
        EXPECT_TRUE(filenames.hasElement(iter->getFileName()));
        filenames.remove(iter->getFileName());
        iter.next();
    }
    EXPECT_EQ(0u, filenames.count());
}
예제 #2
0
void
CheckHeapTracer::onChild(const JS::GCCellPtr& thing)
{
    Cell* cell = thing.asCell();
    if (visited.lookup(cell))
        return;

    if (!visited.put(cell)) {
        oom = true;
        return;
    }

    if (!IsGCThingValidAfterMovingGC(cell)) {
        failures++;
        fprintf(stderr, "Stale pointer %p\n", cell);
        const char* name = contextName();
        for (int index = parentIndex; index != -1; index = stack[index].parentIndex) {
            const WorkItem& parent = stack[index];
            cell = parent.thing.asCell();
            fprintf(stderr, "  from %s %p %s edge\n",
                    GCTraceKindToAscii(cell->getTraceKind()), cell, name);
            name = parent.name;
        }
        fprintf(stderr, "  from root %s\n", name);
        return;
    }

    WorkItem item(thing, contextName(), parentIndex);
    if (!stack.append(item))
        oom = true;
}
예제 #3
0
static void
MaybeTraceGroup(ObjectGroup *group)
{
    if (tracedGroups.has(group))
        return;

    MaybeTraceClass(group->clasp());
    TraceEvent(TraceEventGroupInfo, uint64_t(group));
    TraceAddress(group->clasp());
    TraceInt(group->flags());

    MOZ_ALWAYS_TRUE(tracedGroups.put(group));
}
예제 #4
0
static void
MaybeTraceClass(const Class *clasp)
{
    if (tracedClasses.has(clasp))
        return;

    TraceEvent(TraceEventClassInfo, uint64_t(clasp));
    TraceString(clasp->name);
    TraceInt(clasp->flags);
    TraceInt(clasp->finalize != nullptr);

    MOZ_ALWAYS_TRUE(tracedClasses.put(clasp));
}
예제 #5
0
파일: GCTrace.cpp 프로젝트: Akesure/jxcore
static void
MaybeTraceType(TypeObject *type)
{
    if (tracedTypes.has(type))
        return;

    MaybeTraceClass(type->clasp());
    TraceEvent(TraceEventTypeInfo, uint64_t(type));
    TraceAddress(type->clasp());
    TraceInt(type->flags());

    MOZ_ALWAYS_TRUE(tracedTypes.put(type));
}
예제 #6
0
  static
  int
  readdir(const Branches        &branches_,
          const char            *dirname_,
          void                  *buf_,
          const fuse_fill_dir_t  filler_)
  {
    HashSet names;
    string basepath;
    struct stat st = {0};

    for(size_t i = 0, ei = branches_.size(); i != ei; i++)
      {
        int rv;
        int dirfd;
        DIR *dh;

        basepath = fs::path::make(&branches_[i].path,dirname_);

        dh = fs::opendir(basepath);
        if(!dh)
          continue;

        dirfd     = fs::dirfd(dh);
        st.st_dev = fs::devid(dirfd);
        if(st.st_dev == (dev_t)-1)
          st.st_dev = i;

        rv = 0;
        for(struct dirent *de = fs::readdir(dh); de && !rv; de = fs::readdir(dh))
          {
            rv = names.put(de->d_name);
            if(rv == 0)
              continue;

            st.st_ino  = de->d_ino;
            st.st_mode = DTTOIF(de->d_type);

            fs::inode::recompute(&st);

            rv = filler_(buf_,de->d_name,&st,NO_OFFSET);
            if(rv)
              return (fs::closedir(dh),-ENOMEM);
          }

        fs::closedir(dh);
      }

    return 0;
  }
예제 #7
0
TEST(FileSystemIterator, defaultAcceptTest)
{
    // setup
    TestDirectory rootDir(File("foobarfolder"));
    rootDir.addFile("foobar1.txt");
    rootDir.addDirectory("foobar")->addFile("foobar2.txt");


    HashSet<String> filenames;
    filenames.put("foobar1.txt");
    filenames.put("foobar");
    filenames.put("foobar2.txt");

    FileSystemIterator iter(rootDir.getFile());

    EXPECT_TRUE(iter.isValid());
    EXPECT_TRUE(filenames.hasElement(iter->getFileName()));
    filenames.remove(iter->getFileName());

    EXPECT_TRUE(iter.next());
    EXPECT_TRUE(filenames.hasElement(iter->getFileName()));
    filenames.remove(iter->getFileName());

    EXPECT_TRUE(iter.next());
    EXPECT_TRUE(filenames.hasElement(iter->getFileName()));
    filenames.remove(iter->getFileName());

    EXPECT_EQ(0u, filenames.count());

    EXPECT_FALSE(iter.next());
    EXPECT_FALSE(iter.isValid());


    // iterate again, but don't finish
    FileSystemIterator iter2(rootDir.getFile());
}
예제 #8
0
TEST(FileSystemIterator, subSubDirs)
{
    TestDirectory rootDir(File("foobarfolder"));
    TestDirectoryPtr subDir1 = rootDir.addDirectory("subdir1");
    TestDirectoryPtr subDir2 = rootDir.addDirectory("subdir2");
    TestDirectoryPtr subDir3 = rootDir.addDirectory("subdir3");

    subDir1->addDirectory("sub1subdir1")->addFile("sub1subdir1file1")->addFile("sub1subdir1file2");
    subDir1->addDirectory("sub1subdir2")->addFile("sub1subdir2file1")->addFile("sub1subdir2file2");
    subDir1->addDirectory("sub1subdir3")->addFile("sub1subdir3file1")->addFile("sub1subdir3file2");

    subDir2->addDirectory("sub2subdir1")->addFile("sub2subdir1file1")->addFile("sub2subdir1file2");
    subDir2->addDirectory("sub2subdir2")->addFile("sub2subdir2file1")->addFile("sub2subdir2file2");
    subDir2->addDirectory("sub2subdir3")->addFile("sub2subdir3file1")->addFile("sub2subdir3file2");

    subDir3->addDirectory("sub3subdir1")->addFile("sub3subdir1file1")->addFile("sub3subdir1file2");
    subDir3->addDirectory("sub3subdir2")->addFile("sub3subdir2file1")->addFile("sub3subdir2file2");
    subDir3->addDirectory("sub3subdir3")->addFile("sub3subdir3file1")->addFile("sub3subdir3file2");


    HashSet<String> filenames;
    filenames.put("subdir1");
    filenames.put("subdir2");
    filenames.put("subdir3");
    filenames.put("sub1subdir1");
    filenames.put("sub1subdir2");
    filenames.put("sub1subdir3");
    filenames.put("sub2subdir1");
    filenames.put("sub2subdir2");
    filenames.put("sub2subdir3");
    filenames.put("sub3subdir1");
    filenames.put("sub3subdir2");
    filenames.put("sub3subdir3");
    filenames.put("sub1subdir1file1");
    filenames.put("sub1subdir2file1");
    filenames.put("sub1subdir3file1");
    filenames.put("sub2subdir1file1");
    filenames.put("sub2subdir2file1");
    filenames.put("sub2subdir3file1");
    filenames.put("sub3subdir1file1");
    filenames.put("sub3subdir2file1");
    filenames.put("sub3subdir3file1");
    filenames.put("sub1subdir1file2");
    filenames.put("sub1subdir2file2");
    filenames.put("sub1subdir3file2");
    filenames.put("sub2subdir1file2");
    filenames.put("sub2subdir2file2");
    filenames.put("sub2subdir3file2");
    filenames.put("sub3subdir1file2");
    filenames.put("sub3subdir2file2");
    filenames.put("sub3subdir3file2");

    FileSystemIterator iter(rootDir.getFile());
    while (iter.isValid())
    {
        EXPECT_TRUE(filenames.hasElement(iter->getFileName()));
        EXPECT_EQ(CAPU_OK, filenames.remove(iter->getFileName()));
        iter.next();
    }
    EXPECT_EQ(0u, filenames.count());

}