Exemplo n.º 1
0
int main()
{
    printf("hello world\n");

    if(SetUp() < 0)
    { 
        TearDown();
        return -1;
    }

    GetPortMappingNum();

    //int i = 0;
    //for(i=0; i<30; i++)
    //{
    //    GetPortMappingByIndex(i);
    //}

    GetPortMapping(16738, "TCP");
    GetPortMapping(16738, "UDP");

    AddPortMapping(16738, 16738, "TCP", g_lanaddr);
    AddPortMapping(16738, 16738, "UDP", g_lanaddr);
    AddPortMapping(16738, 16738, "TCP", "192.168.1.120");
    AddPortMapping(16738, 16738, "UDP", "192.168.1.120");

    TearDown();

    return 0;
}
Exemplo n.º 2
0
TEST_F(MindMapModelTest, sortChangeParent)
{
	Mindmapmodel->createMindMap("Root");
	Mindmapmodel->createNode("Node1");
	Mindmapmodel->insertNodeChild(0, 1);
	Mindmapmodel->createNode("Node2");
	Mindmapmodel->insertNodeChild(1, 2);
	Mindmapmodel->createNode("Node3");
	Mindmapmodel->insertNodeSibling(1, 3);
	ASSERT_FALSE(Mindmapmodel->sortChangeParent(Mindmapmodel->MindMap[1]->getNodeList(), FIRST_NODE, 3));
	TearDown();
	SetUp();
	Mindmapmodel->createMindMap("Root");
	Mindmapmodel->createNode("Node1");
	Mindmapmodel->insertNodeChild(0, 1);
	Mindmapmodel->createNode("Node2");
	Mindmapmodel->insertNodeChild(1, 2);
	Mindmapmodel->createNode("Node3");
	Mindmapmodel->insertNodeSibling(1, 3);
	ASSERT_TRUE(Mindmapmodel->sortChangeParent(Mindmapmodel->MindMap[1]->getNodeList(), FIRST_NODE, 2));
	TearDown();
	SetUp();
	Mindmapmodel->createMindMap("Root");
	Mindmapmodel->createNode("Node1");
	Mindmapmodel->insertNodeChild(0, 1);
	Mindmapmodel->createNode("Node2");
	Mindmapmodel->insertNodeChild(1, 2);
	Mindmapmodel->createNode("Node3");
	Mindmapmodel->insertNodeChild(2, 3);
	ASSERT_TRUE(Mindmapmodel->sortChangeParent(Mindmapmodel->MindMap[1]->getNodeList(), FIRST_NODE, 3));
}
    void RattlerRemovalServiceTests::RemoveRattlers_ForMixedPacking_CorrectParticlesRemoved()
    {
        SetUp();

        // The second particle is outside
        const FLOAT_TYPE diameter = 1.0;
        const SpatialVector c0 = {{4, 4, 0}};
        const SpatialVector c1 = {{7, 7, 0}};
        const SpatialVector c2 = {{5, 4, 0}};
        const SpatialVector c3 = {{5, 5, 0}};
        particles[0] = DomainParticle(0, diameter, c0);
        particles[1] = DomainParticle(1, diameter, c1);
        particles[2] = DomainParticle(2, diameter, c2);
        particles[3] = DomainParticle(3, diameter, c3);

        rattlerRemovalService->SetParticles(particles);

        vector<bool> rattlerMask(particlesCount);
        rattlerRemovalService->FillRattlerMask(0.999, &rattlerMask);

        boost::array<bool, 4> expectedRattlerMask = {{false, true, false, false}};
        Assert::AreVectorsEqual(expectedRattlerMask, rattlerMask, "RemoveRattlers_ForMixedPacking_CorrectParticlesRemoved");

        TearDown();
    }
    void RattlerRemovalServiceTests::RemoveRattlers_ForLoosePacking_AllParticlesRemoved()
    {
        SetUp();

        // Diameter of each particle is very small
        const FLOAT_TYPE diameter = 0.1;
        const SpatialVector c0 = {{4, 4, 0}};
        const SpatialVector c1 = {{4, 5, 0}};
        const SpatialVector c2 = {{5, 4, 0}};
        const SpatialVector c3 = {{5, 5, 0}};
        particles[0] = DomainParticle(0, diameter, c0);
        particles[1] = DomainParticle(1, diameter, c1);
        particles[2] = DomainParticle(2, diameter, c2);
        particles[3] = DomainParticle(3, diameter, c3);

        rattlerRemovalService->SetParticles(particles);

        vector<bool> rattlerMask(particlesCount);
        rattlerRemovalService->FillRattlerMask(0.999, &rattlerMask);

        boost::array<bool, 4> expectedRattlerMask = {{true, true, true, true}};
        Assert::AreVectorsEqual(expectedRattlerMask, rattlerMask, "RemoveRattlers_ForLoosePacking_AllParticlesRemoved");

        TearDown();
    }
Exemplo n.º 5
0
TEST_F(nearest_neighbor_test, save_load) {
  {
    core::fv_converter::datum d;
    d.string_values_.push_back(std::make_pair("k1", "val"));
    nearest_neighbor_->set_row("1", d);
  }

  // save to a buffer
  msgpack::sbuffer sbuf;
  msgpack::packer<msgpack::sbuffer> packer(sbuf);
  nearest_neighbor_->get_mixable_holder()->pack(packer);

  // restart the driver
  TearDown();
  SetUp();

  // unpack the buffer
  msgpack::unpacked unpacked;
  msgpack::unpack(&unpacked, sbuf.data(), sbuf.size());
  nearest_neighbor_->get_mixable_holder()->unpack(unpacked.get());

  std::vector<std::pair<std::string, float> > res
      = nearest_neighbor_->similar_row("1", 1);
  ASSERT_EQ(1u, res.size());
  EXPECT_EQ("1", res[0].first);
}
Exemplo n.º 6
0
        /// @param iterations Number of iterations to gather data for.
        /// @returns the number of nanoseconds the run took.
        uint64_t Run(std::size_t iterations)
        {
            std::size_t iteration = iterations;
            
            // Set up the testing fixture.
            SetUp();

            // Get the starting time.
            Clock::TimePoint startTime, endTime;

            startTime = Clock::Now();

            // Run the test body for each iteration.
            while (iteration--)
                TestBody();

            // Get the ending time.
            endTime = Clock::Now();

            // Tear down the testing fixture.
            TearDown();

            // Return the duration in nanoseconds.
            return Clock::Duration(startTime, endTime);
        }
Exemplo n.º 7
0
bool VideoOutputOpenGLVAAPI::InputChanged(const QSize &input_size, float aspect,
                              MythCodecID  av_codec_id, void *codec_private,
                              bool &aspect_only)
{
    LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("InputChanged(%1,%2,%3) %4->%5")
            .arg(input_size.width()).arg(input_size.height()).arg(aspect)
            .arg(toString(video_codec_id)).arg(toString(av_codec_id)));

    if (!codec_is_vaapi(av_codec_id))
        return VideoOutputOpenGL::InputChanged(input_size, aspect, av_codec_id,
                                               codec_private, aspect_only);
                                                   
    QMutexLocker locker(&gl_context_lock);

    bool wasembedding = window.IsEmbedding();
    QRect oldrect;
    if (wasembedding)
    {
        oldrect = window.GetEmbeddingRect();
        StopEmbedding();
    }

    bool cid_changed = (video_codec_id != av_codec_id);
    bool res_changed = input_size  != window.GetActualVideoDim();
    bool asp_changed = aspect      != window.GetVideoAspect();
    
    if (!res_changed && !cid_changed)
    {
        if (asp_changed)
        {
            aspect_only = true;
            VideoAspectRatioChanged(aspect);
            MoveResize();
            if (wasembedding)
                EmbedInWidget(oldrect);
        }
        return true;
    }

    if (gCoreContext->IsUIThread())
        TearDown();
    else
        DestroyCPUResources();

    QRect disp = window.GetDisplayVisibleRect();
    if (Init(input_size.width(), input_size.height(),
             aspect, gl_parent_win, disp, av_codec_id))
    {
        if (wasembedding)
            EmbedInWidget(oldrect);
        if (gCoreContext->IsUIThread())
            BestDeint();
        return true;
    }

    LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to re-initialise video output.");
    errorState = kError_Unknown;

    return false;
}
Exemplo n.º 8
0
	void Test::__run()
	{
		LOG("[ RUN      ] %s.%s", name(), method());
		SetUp();

		TestContext &ctx = TestContext::getInstance();
		ctx.setTest(name(), method());

		StopWatch stopwatch;
		stopwatch.start();
		__test();
		stopwatch.stop();
		int ms = stopwatch.getTimeMillisecond();

		passCount_ = ctx.successCount();
		failCount_ = ctx.failCount();

		if(fail() == 0)
		{
			LOG("[       OK ] %s.%s (%d ms)", name(), method(), ms);
		}
		else
		{
			LOG("[  FAILED  ] %s.%s (%d ms)", name(), method(), ms);
		}

		TearDown();
	}
void FOutputDeviceFile::SetFilename(const TCHAR* InFilename)
{
	// Close any existing file.
	TearDown();

	FCString::Strncpy( Filename, InFilename, ARRAY_COUNT(Filename) );
}
Exemplo n.º 10
0
bool VideoOutputOpenGL::Init(const QSize &video_dim_buf,
                             const QSize &video_dim_disp,
                             float aspect, WId winid,
                             const QRect &win_rect, MythCodecID codec_id)
{
    QMutexLocker locker(&gl_context_lock);
    bool success = true;
    window.SetAllowPreviewEPG(true);
    gl_parent_win = winid;
    success &= VideoOutput::Init(video_dim_buf, video_dim_disp,
                                 aspect, winid,
                                 win_rect, codec_id);
    SetProfile();
    InitPictureAttributes();

    success &= CreateCPUResources();

    if (!gCoreContext->IsUIThread())
    {
        LOG(VB_GENERAL, LOG_NOTICE, LOC +
            "Deferring creation of OpenGL resources");
        gl_valid = false;
    }
    else
    {
        success &= CreateGPUResources();
        success &= CreateVideoResources();
    }

    if (!success)
        TearDown();
    return success;
}
    void ClosestPairProviderTests::RegisterPair_ForFourParticlesAndMovedParticlesAreCloseThroughPeriodic_MovedParticlesAreNearest()
    {
        SetUp();

        //Closest pair is 2-3 with distance 0.5
        const FLOAT_TYPE diameter = 1.0;
        const SpatialVector c0 = {{5, 5, 5}};
        const SpatialVector c1 = {{5.9, 5, 5}};
        const SpatialVector c2 = {{5, 8, 5}};
        const SpatialVector c3 = {{5.5, 8, 5}};
        particles[0] = DomainParticle(0, diameter, c0);
        particles[1] = DomainParticle(1, diameter, c1);
        particles[2] = DomainParticle(2, diameter, c2);
        particles[3] = DomainParticle(3, diameter, c3);

        closestPairProvider->SetParticles(particles);

        closestPairProvider->StartMove(0);
        particles[0].coordinates[Axis::X] = 0.2;
        closestPairProvider->EndMove();

        closestPairProvider->StartMove(1);
        particles[1].coordinates[Axis::X] = 9.99999;
        closestPairProvider->EndMove();
        ParticlePair actualPair = closestPairProvider->FindClosestPair();
        ParticlePair expectedPair(0, 1, 0.2 * 0.2);

        AssertPair(expectedPair, actualPair, "RegisterPair_ForFourParticlesAndMovedParticlesAreCloseThroughPeriodic_MovedParticlesAreNearest");

        TearDown();
    }
Exemplo n.º 12
0
bool VideoOutputOpenGL::Init(int width, int height, float aspect, WId winid,
                             const QRect &win_rect, MythCodecID codec_id)
{
    QMutexLocker locker(&gl_context_lock);

    bool success = true;
    // FIXME Mac OS X overlay does not work with preview
    window.SetAllowPreviewEPG(true);
    gl_parent_win = winid;

    VideoOutput::Init(width, height, aspect, winid, win_rect, codec_id);

    SetProfile();
    InitPictureAttributes();
    success &= SetupContext();
    InitDisplayMeasurements(width, height, false);
    success &= CreateBuffers();
    success &= CreatePauseFrame();
    success &= SetupOpenGL();
    InitOSD();
    MoveResize();

    if (!success)
        TearDown();

    return success;
}
    void HcpGeneratorTests::ArrangePacking_ForHcp_NoParticleIntersections()
    {
        SetUp();

        hcpGenerator->ArrangePacking(&particles);

        FLOAT_TYPE minDistanceSquare = FLT_MAX;
        FLOAT_TYPE currentDistanceSquare = 0;

        for (ParticleIndex i = 0; i < context->config->particlesCount - 1; i++)
        {
            for (ParticleIndex j = i + 1; j < context->config->particlesCount; j++)
            {
                currentDistanceSquare = mathService->GetNormalizedDistanceSquare(i, j, particles);
                if (currentDistanceSquare < minDistanceSquare)
                {
                    minDistanceSquare = currentDistanceSquare;
                }
            }
        }

        FLOAT_TYPE minDistance = sqrt(minDistanceSquare);

        Assert::AreAlmostEqual(minDistance, 1.0, "ArrangePacking_ForHcp_NoParticleIntersections");

        TearDown();
    }
Exemplo n.º 14
0
TEST_F(ProxygenTransportTest, push_abort_incomplete) {
  // Push a resource
  Array headers;
  uint8_t pri = 1;

  headers.add(String("hello"), String("world"));  // dict serializtion path
  pushResource(headers, pri);

  // Creates a new transaction and sends headers, but not body
  MockHTTPTransaction pushTxn(TransportDirection::DOWNSTREAM,
                              HTTPCodec::StreamID(1), 1, m_egressQueue,
                              WheelTimerInstance(m_timeouts.get()));
  HTTPPushTransactionHandler* pushHandler = nullptr;
  expectPushPromiseAndHeaders(pushTxn, pri, &pushHandler);
  m_server.deliverMessages();
  sendResponse("12345");

  EXPECT_CALL(pushTxn, sendAbort())
    .WillOnce(Invoke([pushHandler] {
          pushHandler->detachTransaction();
        }));
  // Simulate termination of the VM thread while there is an incomplete push
  // This aborts the incomplete push
  TearDown();
}
Exemplo n.º 15
0
bool VideoOutputVDPAU::Init(int width, int height, float aspect,
                            WId winid, const QRect &win_rect,
                            MythCodecID codec_id)
{
    // Attempt to free up as much video memory as possible
    // only works when using the VDPAU painter for the UI
    MythPainter *painter = GetMythPainter();
    if (painter)
        painter->FreeResources();

    m_win = winid;
    QMutexLocker locker(&m_lock);
    window.SetNeedRepaint(true);
    bool ok = VideoOutput::Init(width, height, aspect, winid, win_rect,codec_id);
    if (db_vdisp_profile)
        db_vdisp_profile->SetVideoRenderer("vdpau");

    InitDisplayMeasurements(width, height, true);
    ParseOptions();
    if (ok) ok = InitRender();
    if (ok) ok = InitBuffers();
    if (!ok)
    {
        TearDown();
        return ok;
    }

    InitPictureAttributes();
    MoveResize();
    LOG(VB_PLAYBACK, LOG_INFO, LOC +
        QString("Created VDPAU context (%1 decode)")
            .arg(codec_is_std(video_codec_id) ? "software" : "GPU"));

    return ok;
}
    void ClosestPairProviderTests::RegisterPair_ForFourParticlesAndMovedParticleIsCloseToNonMoved_ThisPairIsReturned()
    {
        SetUp();

        //Closest pair is 2-3 with distance 0.5
        const FLOAT_TYPE diameter = 1.0;
        const SpatialVector c0 = {{5, 5, 5}};
        const SpatialVector c1 = {{5.5, 5, 5}};
        const SpatialVector c2 = {{5, 8, 5}};
        const SpatialVector c3 = {{5.5, 8, 5}};
        particles[0] = DomainParticle(0, diameter, c0);
        particles[1] = DomainParticle(1, diameter, c1);
        particles[2] = DomainParticle(2, diameter, c2);
        particles[3] = DomainParticle(3, diameter, c3);

        closestPairProvider->SetParticles(particles);
        closestPairProvider->StartMove(0);
        particles[0].coordinates[Axis::Y] = 7.9;
        closestPairProvider->EndMove();
        ParticlePair actualPair = closestPairProvider->FindClosestPair();
        ParticlePair expectedPair(0, 2, 0.1 * 0.1);

        AssertPair(expectedPair, actualPair, "RegisterPair_ForFourParticlesAndMovedParticleIsCloseToNonMoved_ThisPairIsReturned");

        TearDown();
    }
    void ClosestPairProviderTests::UnregisterPair_ForFourParticles_LeftParticlesAreNearest()
    {
        SetUp();

        //Closest pair is 2-3 with distance 0.5
        const FLOAT_TYPE diameter = 1.0;
        const SpatialVector c0 = {{5, 5, 5}};
        const SpatialVector c1 = {{5.9, 5, 5}};
        const SpatialVector c2 = {{5, 8, 5}};
        const SpatialVector c3 = {{5.5, 8, 5}};
        particles[0] = DomainParticle(0, diameter, c0);
        particles[1] = DomainParticle(1, diameter, c1);
        particles[2] = DomainParticle(2, diameter, c2);
        particles[3] = DomainParticle(3, diameter, c3);

        closestPairProvider->SetParticles(particles);
        closestPairProvider->StartMove(2);
        closestPairProvider->StartMove(3);
        ParticlePair actualPair = closestPairProvider->FindClosestPair();
        ParticlePair expectedPair(0, 1, 0.9 * 0.9);

        AssertPair(expectedPair, actualPair, "UnregisterPair_ForFourParticles_LeftParticlesAreNearest");

        TearDown();
    }
Exemplo n.º 18
0
VideoOutputOpenGL::~VideoOutputOpenGL()
{
    QMutexLocker locker(&gl_context_lock);
    TearDown();

    if (gl_context)
        gl_context->DownRef();
    gl_context = NULL;
}
    void SphericalHarmonicsComputerTests::GetSphericalHarmonicValues_CompareWithAnalyticalForm_lIsOne_mIsZero_IsCorrect()
    {
        SetUp();

        FLOAT_TYPE error = GetSphericalHarmonicsError(1, 0);
        Assert::AreAlmostEqual(error, 0.0, "GetSphericalHarmonicValues_CompareWithAnalyticalForm_lIsOne_mIsZero_IsCorrect");

        TearDown();
    }
Exemplo n.º 20
0
ECode TestCase::RunBare()
{
    ECode ec = NOERROR;
    SetUp();
    ec = RunTest();
    ECode ec1 = TearDown();
    if (ec == NOERROR) ec = ec1;
    return ec;
}
Exemplo n.º 21
0
VideoOutputOpenGL::~VideoOutputOpenGL()
{
    gl_context_lock.lock();
    TearDown();

    if (gl_context)
        gl_context->DownRef();
    gl_context = NULL;
    gl_context_lock.unlock();
}
Exemplo n.º 22
0
VideoOutputOpenGL::~VideoOutputOpenGL()
{
    gl_context_lock.lock();
    TearDown();

    if (gl_context)
        gl_context->DecrRef();
    gl_context = nullptr;
    gl_context_lock.unlock();
}
    void ParticleCollisionServiceTests::GetCollisionTime_FirstParticleMovingAlongXSecondStill_TimeCorrect()
    {
        SetUp();

        FLOAT_TYPE time = particleCollisionService->GetCollisionTime(0, first, second);
        FLOAT_TYPE expectedTime = (second.coordinates[Axis::X] - first.coordinates[Axis::X] - 0.5 * first.diameter - 0.5 * second.diameter) / first.velocity[Axis::X];

        Assert::AreAlmostEqual(time, expectedTime, "GetCollisionTime_FirstParticleMovingAlongXSecondStill_TimeCorrect");
        TearDown();
    }
Exemplo n.º 24
0
int itc_media_MediaPlayer_main(void)
{
	SetUp();
	if(g_flag){
		itc_media_MediaPlayer_create_destroy_p();
		itc_media_MediaPlayer_create_destroy_n();
	}
	TearDown();
	return 0;
}
    void VelocityServiceTests::FillInitialVelocity_CompareTemperature_ActualTemperatureCorrect()
    {
        SetUp();

        velocityService->FillVelocities(&particles);

        FLOAT_TYPE actualKineticEnergy = velocityService->GetActualKineticEnergy(particles);
        FLOAT_TYPE expectedKineticEnergy = velocityService->GetExpectedKineticEnergy(particles);

        Assert::AreAlmostEqual(actualKineticEnergy, expectedKineticEnergy, "FillInitialVelocity_CompareTemperature_ActualTemperatureCorrect");
        TearDown();
    }
    void HcpGeneratorTests::ArrangePacking_ForHcp_DensityCorrect()
    {
        SetUp();

        FLOAT_TYPE boxVolume = VectorUtilities::GetProduct(context->config->packingSize);
        FLOAT_TYPE particlesVolume = context->config->particlesCount * PI * diameter * diameter * diameter / 6.0;

        FLOAT_TYPE density = particlesVolume / boxVolume;
        FLOAT_TYPE expectedDensity = PI / 3.0 / sqrt(2.0);

        Assert::AreAlmostEqual(expectedDensity, density, "ArrangePacking_ForHcp_DensityCorrect");

        TearDown();
    }
    void ParticleCollisionServiceTests::GetCollisionTime_FirstParticleMovingAlongXSecondStillParticlesGrowQuadratic_TimeCorrect()
    {
        SetUp();
        FLOAT_TYPE ratioGrowthRate = 0.5;
        particleCollisionService->Initialize(1.0, ratioGrowthRate);
        FLOAT_TYPE particleRadiiGrowthRate = 0.5 * ratioGrowthRate * (first.diameter + second.diameter);

        // Collision equation is quadratic these parameters.
        FLOAT_TYPE time = particleCollisionService->GetCollisionTime(0, first, second);
        FLOAT_TYPE expectedTime = (second.coordinates[Axis::X] - first.coordinates[Axis::X] - 0.5 * first.diameter - 0.5 * second.diameter) / (first.velocity[Axis::X] + particleRadiiGrowthRate);

        Assert::AreAlmostEqual(time, expectedTime, "GetCollisionTime_FirstParticleMovingAlongXSecondStillParticlesGrowQuadratic_TimeCorrect");
        TearDown();
    }
Exemplo n.º 28
0
bool CTestSuite::Run(std::set<std::string>& SuitesToRun)
{	
    ClearErrors();

    if(GetParentSuite()!=NULL && SuitesToRun.size()!=0)
    {
        std::string sSuiteName;
        std::string sSuiteDescription;
        GetSuiteInfo(sSuiteName, sSuiteDescription);

        // Check if this suite's name is in list
        std::set<std::string>::iterator it = SuitesToRun.find(sSuiteName);
        if(it==SuitesToRun.end())
            return true; // This suite is not in list
    }

    g_pCurTestSuite = this;

    BeforeTest("SetUp");
    SetUp();
    AfterTest("SetUp");

    if(m_bTestFailed)
        m_bSuiteSetUpFailed = true;

    std::vector<std::string> test_list;
    DoWithMyTests(RUN_TESTS, test_list);

    UINT i;
    for(i=0; i<m_apChildSuites.size(); i++)
    {
        m_apChildSuites[i]->Run(SuitesToRun);
    }

    int nErrors = (int)m_asErrorMsg.size();

    g_pCurTestSuite = this;

    if(BeforeTest("TearDown"))
        TearDown();
    AfterTest("TearDown");

    if(nErrors!=(int)m_asErrorMsg.size())
        return false; // TearDown has failed

    g_pCurTestSuite = NULL;

    return m_asErrorMsg.size()==0?true:false;
}
Exemplo n.º 29
0
    double benchmark2()
    {
        double t0=omp_get_wtime();
        for(int test=0; test<num_test; test++)
        {
#pragma omp parallel for
            for(int i=0;i<num_data; i+=NB)
            {
                AND(&(data1[i]), &(data2[i]), &(result[i]));
            }
        }
        double t1= omp_get_wtime()-t0;
        TearDown();
        return t1/num_test;
    }
    double benchmark1()
    {
        double t0=omp_get_wtime();
        for(int test=0; test<num_test; test++)
        {
#pragma omp parallel for
            for(int i=0;i<num_data; i++)
            {
                result[i] = n_bit_zero_padding(data1[i], n_bit);
            }
        }
        double t1= omp_get_wtime()-t0;
        TearDown();
        return t1/num_test;
    }