Exemplo n.º 1
0
 Framework::ReturnCode Framework::list() const {
     std::stringstream sStr;
     ListTests list_tests;
     list_tests(sStr, get_registry()->makeTest());
     std::cout << sStr.str() << std::endl;
     return SUCCESS;
 }
Exemplo n.º 2
0
/* static */
void GeneratorRegistry::unregister_factory(const std::string &name) {
    GeneratorRegistry &registry = get_registry();
    std::lock_guard<std::mutex> lock(registry.mutex);
    internal_assert(registry.factories.find(name) != registry.factories.end())
        << "Generator not found: " << name;
    registry.factories.erase(name);
}
Exemplo n.º 3
0
/* static */
std::vector<void *> ObjectInstanceRegistry::instances_in_range(void *start, size_t size,
                                                               Kind kind) {
    std::vector<void *> results;

#if __cplusplus > 199711L || _MSC_VER >= 1800
    ObjectInstanceRegistry &registry = get_registry();
    std::lock_guard<std::mutex> lock(registry.mutex);

    std::map<uintptr_t, InstanceInfo>::const_iterator it =
        registry.instances.lower_bound((uintptr_t)start);

    uintptr_t limit_ptr = ((uintptr_t)start) + size;
    while (it != registry.instances.end() && it->first < limit_ptr) {
        if (it->second.kind == kind) {
            results.push_back(it->second.subject_ptr);
        }

        if (it->first > (uintptr_t)start && it->second.size != 0) {
            // Skip over containers that we enclose
            it = registry.instances.lower_bound(it->first + it->second.size);
        } else {
            it++;
        }
    }
#endif

    return results;
}
Exemplo n.º 4
0
    Framework::ReturnCode Framework::run() {
        Ensures(m_program_options.parse_options());

        if (m_program_options.asked_for_help()) {
            return help();
        }

        if (m_program_options.asked_for_list()) {
            return list();
        }

        CPPUNIT_NS::TextUi::TestRunner runner;

        if (m_program_options.asked_to_run_only_some_tests()) {
            Ensures(combine_tests_subset(runner));
        } else if (m_program_options.asked_for_regtest()) {
            Ensures(combine_regtest_subset(runner));
        } else {
            runner.addTest(get_registry()->makeTest());
        }

        CPPUNIT_NS::TestResult controller;

        CPPUNIT_NS::TestResultCollector result;
        controller.addListener(&result);

        CPPUNIT_NS::BriefTestProgressListener progress;
        controller.addListener(&progress);
        runner.run(controller);

        CPPUNIT_NS::CompilerOutputter outputter(&result, std::cerr);
        outputter.write();

        return result.wasSuccessful() ? SUCCESS : FAILURE;
    }
Exemplo n.º 5
0
/* static */
std::unique_ptr<GeneratorBase> GeneratorRegistry::create(const std::string &name,
                                                         const GeneratorParamValues &params) {
    GeneratorRegistry &registry = get_registry();
    std::lock_guard<std::mutex> lock(registry.mutex);
    auto it = registry.factories.find(name);
    user_assert(it != registry.factories.end()) << "Generator not found: " << name;
    return it->second->create(params);
}
Exemplo n.º 6
0
/* static */
std::vector<std::string> GeneratorRegistry::enumerate() {
    GeneratorRegistry &registry = get_registry();
    std::lock_guard<std::mutex> lock(registry.mutex);
    std::vector<std::string> result;
    for (const auto& i : registry.factories) {
        result.push_back(i.first);
    }
    return result;
}
Exemplo n.º 7
0
/* static */
void GeneratorRegistry::register_factory(const std::string &name,
                                         std::unique_ptr<GeneratorFactory> factory) {
    user_assert(is_valid_name(name)) << "Invalid Generator name: " << name;
    GeneratorRegistry &registry = get_registry();
    std::lock_guard<std::mutex> lock(registry.mutex);
    internal_assert(registry.factories.find(name) == registry.factories.end())
        << "Duplicate Generator name: " << name;
    registry.factories[name] = std::move(factory);
}
Exemplo n.º 8
0
/* static */
void ObjectInstanceRegistry::unregister_instance(void *this_ptr) {
#if __cplusplus > 199711L || _MSC_VER >= 1800
    ObjectInstanceRegistry &registry = get_registry();
    std::lock_guard<std::mutex> lock(registry.mutex);
    uintptr_t key = (uintptr_t)this_ptr;
    std::map<uintptr_t, InstanceInfo>::iterator it = registry.instances.find(key);
    internal_assert(it != registry.instances.end());
    if (it->second.registered_for_introspection) {
        Introspection::deregister_heap_object(this_ptr, it->second.size);
    }
    registry.instances.erase(it);
#endif
}
Exemplo n.º 9
0
/* static */
void ObjectInstanceRegistry::register_instance(void *this_ptr, size_t size, Kind kind,
                                               void *subject_ptr, const void *introspection_helper) {
#if __cplusplus > 199711L || _MSC_VER >= 1800
    ObjectInstanceRegistry &registry = get_registry();
    std::lock_guard<std::mutex> lock(registry.mutex);
    uintptr_t key = (uintptr_t)this_ptr;
    internal_assert(registry.instances.find(key) == registry.instances.end());
    if (introspection_helper) {
        registry.instances[key] = InstanceInfo(size, kind, subject_ptr, true);
        Introspection::register_heap_object(this_ptr, size, introspection_helper);
    } else {
        registry.instances[key] = InstanceInfo(size, kind, subject_ptr, false);
    }
#endif
}
Exemplo n.º 10
0
    bool Framework::combine_regtest_subset(CPPUNIT_NS::TextUi::TestRunner &runner) const {
        FindRegTest find_regtest;

        try {
            auto tests_to_run = find_regtest(m_program_options.get_regtest(), get_registry()->makeTest());

            for (auto &test : tests_to_run) {
                runner.addTest(test);
            }
        } catch (const std::exception &e) {
            std::cerr << "Cannot match your regexp: " << e.what() << std::endl;
            return false;
        }

        return true;
    }
Exemplo n.º 11
0
    bool Framework::combine_tests_subset(CPPUNIT_NS::TextUi::TestRunner &runner) const {
        FindTest find_test;

        for (auto &name : m_program_options.get_tests_to_run()) {
            CPPUNIT_NS::Test *test = find_test(name, get_registry()->makeTest());

            if (test == nullptr) {
                std::cerr << "Cannot find test '" << name << "'!" << std::endl;
                return false;
            }

            runner.addTest(test);
        }

        return true;
    }
Exemplo n.º 12
0
s8 wl_display_req(struct client *c,struct msg *m)
{
  s8 r;
  switch(m->req_op){
  case WL_DISPLAY_GET_REGISTRY:
    r=get_registry(c,m);
    break;
  case WL_DISPLAY_SYNC:
    r=sync(c,m);
    break;
  default:
    PERR("client(%d):fatal:display:request unknown opcode %u\n",c->so,
                                                                     m->req_op);
    r=LWL_ERR;
  }
  return r;
}