示例#1
0
void TestPlugin::initialize()
{
    NamedList* httpdconf = 0;
    Output("Initializing module TestHttpBase");
    Configuration cfg;
    cfg = Engine::configFile("httpserver");
    cfg.load();
    for (unsigned int i = 0; i < cfg.sections(); i++) {
	httpdconf = cfg.getSection(i);
	String name = httpdconf ? httpdconf->c_str() : "";
	if (! name.startSkip("listener ",false))
	    continue;
	name.trimBlanks();
	httpdconf->String::operator=(name);
	break; // XXX only first listener
    }
    if (m_first)
	m_testThread = new TestThread;
    m_testThread->configure(*httpdconf);
    if (m_first) {
	m_first = false;
	m_testThread->startup();
	Engine::install(new TestHandler("http.request"));
    }
//    delete httpdconf;
}
示例#2
0
int main(int argc, char** argv)
{ 
	InitDTLibrary();
	try
	{	
		vector<TestThread*> threads;
		for (int i = 0; i < 1; i++) {
			TestThread *thread = new TestThread (argc, argv);
			threads.push_back (thread);
			
			thread->start();
		}
		
		for (int j=0; j < threads.size(); j++) {
			threads[j]->join();
		}
		
	}
	catch(Poco::Exception &e)
	{
		cout << e.what() << endl;
	}
	catch (Exception &exp)
	{
		cout << exp.toString().getCStr() << endl;
	}
	
	return 0;
}
示例#3
0
void test1()
{
    trace_log(DBG,"------------------test1-----------------");
    TestThread test;
    test.Start();
    //sleep(2);
}
示例#4
0
void SystemInfo::detectThreads() {
  // Threads type
#ifdef _WIN32
  threadsType = ThreadsType::WINDOWS_THREADS;

#elif __linux__
  // Test for LinuxThreads which has a different PID for each thread
  struct TestThread : public Thread {
    unsigned pid;
    TestThread() : pid(0) {}
    void run() {pid = SystemUtilities::getPID();}
  };

  TestThread testThread;
  testThread.start();
  testThread.join();

  if (testThread.pid != SystemUtilities::getPID())
    threadsType = ThreadsType::LINUX_THREADS;
  else threadsType = ThreadsType::POSIX_THREADS;

#else // __linux__
  // Assume POSIX
  threadsType = ThreadsType::POSIX_THREADS;
#endif
}
示例#5
0
int main(int argc, char** argv)
{
	TestThread t;
	t.start();
	t.block();
	std::cout << "(Main)" << std::endl;
	t.cancel();
	return 0;
}
示例#6
0
void ThreadTest::thread_test01()
{
	TestThread t;
	t.start();

	::usleep(1000);

	t.stop();
	t.join();

	CPPUNIT_ASSERT_EQUAL(1, (int)t._finally);
}
    void cancelExport()
    {
        TestThread cancelThread;
        QLandmarkFileHandlerGpx handler(&(cancelThread.m_cancel));
        QLandmark lm;
        QList<QLandmark> lms;
        for (int i=0; i < 50000; ++i) {
            lm.setName(QString("LM%1").arg(0));
            lms.append(lm);
        }

        handler.setWaypoints(lms);
        cancelThread.start();
        QFile file(m_exportFile);
        QVERIFY(!handler.exportData(&file));
        QCOMPARE(handler.error(), QLandmarkManager::CancelError);
        cancelThread.wait();
    }
PRIntn main(PRIntn argc, char **agrv)
{
    PRStatus status;
    PRIntn count = 100;
    RCThread *thread[10];
    while (--count > 0)
    {
        TestThread *thread = new TestThread(RCThread::joinable, count);
        status = thread->Start();  /* have to remember to start it */
        PR_ASSERT(PR_SUCCESS == status);
        status = thread->Join();  /* this should work */
        PR_ASSERT(PR_SUCCESS == status);
    }
    while (++count < 100)
    {
        TestThread *thread = new TestThread(RCThread::unjoinable, count);
        status = thread->Start();  /* have to remember to start it */
        PR_ASSERT(PR_SUCCESS == status);
    }

    {
        Foo1 *foo1 = new Foo1();
        PR_ASSERT(NULL != foo1);
        delete foo1;
    }

    {
        for (count = 0; count < 10; ++count)
        {
            thread[count] = new TestThread( RCThread::joinable, count);
            status = thread[count]->Start();  /* have to remember to start it */
            PR_ASSERT(PR_SUCCESS == status);
        }
        for (count = 0; count < 10; ++count)
        {
            PRStatus rv = thread[count]->Join();
            PR_ASSERT(PR_SUCCESS == rv);
        }
    }

    (void)RCPrimordialThread::Cleanup();

    return 0;
}  /* main */
示例#9
0
void TestPlugin1::initialize()
{
    Output("Initializing module TestPlugin1");
    Configuration *cfg = new Configuration(Engine::configFile("test1"));
    noisy = cfg->getBoolValue("general","noisy");
    int n = cfg->getIntValue("general","threads");
    delete cfg;
    Engine::install(new TestHandler("engine.halt"));
    Engine::install(new TestHandler(""));
    Engine::enqueue(new Message("test.queued1"));
    Engine::enqueue(new Message("test.queued2"));
    if (m_first) {
	m_first = false;
	for (int i=0; i<n; i++) {
	    ::usleep(10000);
	    TestThread *t = new TestThread;
	    t->startup();
	}
    }
}
示例#10
0
int main(int argc, char *argv[])
{
	try
	{
		TestThread* t = new TestThread;

		int i = 3;
		while(true)
		{
			sleep(i++);

			t->Notify();
		}


		sleep(1000);
	}
	catch(const LWPR::Exception& e)
	{
		fprintf(stderr, "%s\n", e.what());
	}

	return 0;
}
示例#11
0
void GetCurrentProcessThreadCountTest(bool printInfo)
{
    dword before = GetCurrentProcessThreadCount();

    {
        TestThread thread;
        thread.wait();
    }

    dword after = GetCurrentProcessThreadCount();

    if (printInfo)
    {
        using namespace std;

        cout << std::endl
             << "Threads in process : " << before << endl
             << "Create & destroy 2 threads" << endl
             << "Threads in process: " << after << endl;
    }

    TUT_ASSERT(before == after);
    TUT_ASSERT(GInsideThreadCount == (before + 1));
}
示例#12
0
    void basicTests()
    {
        TestSink sink {*this};
        TestThread thread;
        sink.threshold (beast::severities::Severity::kAll);
        beast::Journal journal {sink};
        TestHandler handler;
        auto s = make_Server (handler,
            thread.get_io_service(), journal);
        std::vector<Port> list;
        list.resize(1);
        list.back().port = testPort;
        list.back().ip = boost::asio::ip::address::from_string (
            "127.0.0.1");
        list.back().protocol.insert("http");
        s->ports (list);

        test_request();
        //test_keepalive();
        //s->close();
        s = nullptr;

        pass();
    }
示例#13
0
文件: tests.cpp 项目: dgu123/nitki
void Run(){

	//Test join after thread has finished
	{
		TestThread t;

		t.start();

		nitki::Thread::sleep(2000);

		t.join();
	}



	//Test join before thread has finished
	{
		TestThread t;

		t.start();

		t.join();
	}
}
示例#14
0
void test_thread ()
{
	TestThread thread;
	thread.start();
	thread.wait();
}
示例#15
0
int main(int argc, char *argv[])
{
    Settings settings;
    bool resolutionFromCmdLine = false;

    if (!readSettingsFromCommandLine(argc, argv, settings))
        return 1;

    if (settings.size().width() > 0 && settings.size().height() > 0)
        resolutionFromCmdLine = true;

    // Start measuring here
    QTime t;
    t.start();
    QApplication app(argc, argv);
    app.setApplicationName("GraphicsViewBenchmark");

    MainView mainView(settings.options().testFlag(Settings::UseOpenGL),
                      settings.options().testFlag(Settings::OutputFps));

    if ((settings.angle() % 360) != 0)
        mainView.rotateContent(settings.angle());

    if (resolutionFromCmdLine) {
        mainView.resize(settings.size().width(), settings.size().height());
        mainView.show();
    }
    else {
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
    mainView.showFullScreen();
#else
    mainView.resize(360, 640);
    mainView.show();
#endif
    }

    // Stop measuring here
    int creationTime = t.elapsed();

    qRegisterMetaType<Theme::Themes>("Theme::Themes");
    qRegisterMetaType<Benchmark::ListType>("Benchmark::ListType");
    qRegisterMetaType<TestFunctionResult*>("TestFunctionResult*");
    qRegisterMetaType<Benchmark*>("Benchmark*");
    qRegisterMetaType<ScriptRunner*>("ScriptRunner*");
    qRegisterMetaType<ResultLogger*>("ResultLogger*");

    TestController tc(settings.outputFileName(), &mainView, ResultLogger::ResultFormat(settings.resultFormat()));
    if (settings.options().testFlag(Settings::UseListItemCache))
        tc.setSubtreeCache(true);
    if(settings.options().testFlag(Settings::NoResourceUsage))
        tc.setCpuMemLogging(false);
    TestThread *tt = new ScriptRunner(settings.scriptName(), &tc, &app);

    tt->addTestFunctionBenchmark("Startup", "Creation time of application and main window (ms).", creationTime);

    QTimer::singleShot(500, tt, SLOT(start()));

    int val = app.exec();

    tt->wait();
    delete tt;

    return val;
}
示例#16
0
    void stressTest()
    {
        struct NullHandler
        {
            bool
            onAccept (Session& session,
                boost::asio::ip::tcp::endpoint endpoint)
            {
                return true;
            }

            Handoff
            onHandoff (Session& session,
                std::unique_ptr <beast::asio::ssl_bundle>&& bundle,
                    http_request_type&& request,
                        boost::asio::ip::tcp::endpoint remote_address)
            {
                return Handoff{};
            }

            Handoff
            onHandoff (Session& session, boost::asio::ip::tcp::socket&& socket,
                http_request_type&& request,
                    boost::asio::ip::tcp::endpoint remote_address)
            {
                return Handoff{};
            }

            void
            onRequest (Session& session)
            {
            }

            void
            onWSMessage(std::shared_ptr<WSSession> session,
                std::vector<boost::asio::const_buffer> const& buffers)
            {
            }

            void
            onClose (Session& session,
                boost::system::error_code const&)
            {
            }

            void
            onStopped (Server& server)
            {
            }
        };

        NullHandler h;
        for(int i = 0; i < 1000; ++i)
        {
            TestThread thread;
            auto s = make_Server(h,
                thread.get_io_service(), {});
            std::vector<Port> list;
            list.resize(1);
            list.back().port = testPort;
            list.back().ip = boost::asio::ip::address::from_string (
                "127.0.0.1");
            list.back().protocol.insert("http");
            s->ports (list);
        }
    }