Ejemplo n.º 1
0
Archivo: batch.c Proyecto: r6144/wine
static void run_test(const char *cmd_data, DWORD cmd_size, const char *exp_data, DWORD exp_size)
{
    const char *out_data;
    DWORD out_size;

    if(!run_cmd(cmd_data, cmd_size))
        return;

    out_size = map_file("test.out", &out_data);
    if(out_size) {
        test_output(out_data, out_size, exp_data, exp_size);
        UnmapViewOfFile(out_data);
    }
    DeleteFileA("test.out");
    DeleteFileA("test.err");
}
Ejemplo n.º 2
0
rtems_task Init(
  rtems_task_argument argument
)
{
  puts( "\n\n*** HEAP WALK TEST ***" );

  test_system_not_up();
  test_check_control();
  test_check_free_list();
  test_freshly_initialized();
  test_main_loop();
  test_check_free_block();
  test_output();

  puts( "*** END OF HEAP WALK TEST ***" );
  rtems_test_exit(0);
}
Ejemplo n.º 3
0
int main()
{
	bert_encoder_t *encoder = test_encoder(output,OUTPUT_SIZE);
	bert_data_t *data;

	if (!(data = bert_data_create_atom(EXPECTED)))
	{
		test_fail("malloc failed");
	}

	test_encoder_push(encoder,data);

	bert_data_destroy(data);
	bert_encoder_destroy(encoder);

	test_output();
	return 0;
}
Ejemplo n.º 4
0
void RingBufferPoolTest::testGetAvailableData()
{
    TITLE();
    std::string test_id = "getData putData";
    std::string false_id = "false id";

    auto mainRingBuffer = rbPool_->getRingBuffer(RingBufferPool::DEFAULT_ID);
    auto testRingBuffer = rbPool_->createRingBuffer(test_id);

    rbPool_->bindCallID(test_id, RingBufferPool::DEFAULT_ID);

    ring::AudioSample test_sample1 = 12;
    ring::AudioSample test_sample2 = 13;

    AudioBuffer test_input1(&test_sample1, 1, AudioFormat::MONO());
    AudioBuffer test_input2(&test_sample2, 1, AudioFormat::MONO());
    AudioBuffer test_output(1, AudioFormat::MONO());
    AudioBuffer test_output_large(100, AudioFormat::MONO());

    // put by RingBufferPool::DEFAULT_ID get by test_id without preleminary put
    CPPUNIT_ASSERT(rbPool_->availableForGet(test_id) == 0);
    CPPUNIT_ASSERT(rbPool_->getAvailableData(test_output, test_id) == 0);

    // put by RingBufferPool::DEFAULT_ID, get by test_id
    mainRingBuffer->put(test_input1);
    CPPUNIT_ASSERT(rbPool_->availableForGet(test_id) == 1);

    // get by RingBufferPool::DEFAULT_ID without preliminary input
    CPPUNIT_ASSERT(rbPool_->availableForGet(test_id) == 0);
    CPPUNIT_ASSERT(rbPool_->getData(test_output_large, test_id) == 0);

    // put by test_id get by test_id
    testRingBuffer->put(test_input2);
    CPPUNIT_ASSERT(rbPool_->availableForGet(test_id) == 1);
    CPPUNIT_ASSERT(rbPool_->getData(test_output_large, test_id) == 1);
    CPPUNIT_ASSERT(rbPool_->availableForGet(test_id) == 0);
    CPPUNIT_ASSERT((*test_output_large.getChannel(0))[0] == test_sample2);

    // get by false id
    CPPUNIT_ASSERT(rbPool_->getData(test_output_large, false_id) == 0);

    rbPool_->unBindCallID(test_id, RingBufferPool::DEFAULT_ID);
}
Ejemplo n.º 5
0
TEST(MeshLib, AddTopLayerToPrismMesh)
{
    std::unique_ptr<MeshLib::Mesh> const mesh (MeshLib::MeshGenerator::generateRegularTriMesh(5, 5));
    std::unique_ptr<MeshLib::Mesh> const mesh2 (MeshLib::addLayerToMesh(*mesh, 5, "mesh", true));
    double const height (1);
    std::unique_ptr<MeshLib::Mesh> const result (MeshLib::addLayerToMesh(*mesh2, height, "mesh", true));

    ASSERT_EQ(mesh2->getNumberOfNodes()/2.0 * 3, result->getNumberOfNodes());
    ASSERT_EQ(mesh2->getNumberOfElements()/2.0 * 3, result->getNumberOfElements());

    std::array<unsigned, 7> const n_elems (MeshLib::MeshInformation::getNumberOfElementTypes(*result));
    ASSERT_EQ(50, n_elems[1]); // tests if 50 tris are present
    ASSERT_EQ(100, n_elems[6]); // tests if 50 prisms are present

    MathLib::Vector3 const dir(0, 0, -1);
    std::unique_ptr<MeshLib::Mesh> test_input (
        MeshLib::MeshSurfaceExtraction::getMeshSurface(*mesh2, dir, 90));
    std::unique_ptr<MeshLib::Mesh> test_output (
        MeshLib::MeshSurfaceExtraction::getMeshSurface(*result, dir, 90));
    AddLayerValidation::testZCoords3D(*test_input, *test_output, height);
    AddLayerValidation::validate(*result, true);
}
Ejemplo n.º 6
0
static void run_test(const char *cmd_data, DWORD cmd_size, const char *exp_data, DWORD exp_size)
{
    const char *out_data, *actual_cmd_data;
    DWORD out_size, actual_cmd_size;

    actual_cmd_data = convert_input_data(cmd_data, cmd_size, &actual_cmd_size);
    if(!actual_cmd_size || !actual_cmd_data)
        goto cleanup;

    if(!run_cmd(actual_cmd_data, actual_cmd_size))
        goto cleanup;

    out_size = map_file("test.out", &out_data);
    if(out_size) {
        test_output(out_data, out_size, exp_data, exp_size);
        UnmapViewOfFile(out_data);
    }
    DeleteFileA("test.out");
    DeleteFileA("test.err");

cleanup:
    HeapFree(GetProcessHeap(), 0, (LPVOID)actual_cmd_data);
}
Ejemplo n.º 7
0
void RingBufferPoolTest::testGetPutData()
{
    TITLE();

    std::string test_id = "incoming rtp session";

    auto mainRingBuffer = rbPool_->getRingBuffer(RingBufferPool::DEFAULT_ID);
    auto testRingBuffer = rbPool_->createRingBuffer(test_id);

    rbPool_->bindCallID(test_id, RingBufferPool::DEFAULT_ID);

    ring::AudioSample test_sample1 = 12;
    ring::AudioSample test_sample2 = 13;

    AudioBuffer test_input1(&test_sample1, 1, AudioFormat::MONO());
    AudioBuffer test_input2(&test_sample2, 1, AudioFormat::MONO());
    AudioBuffer test_output(100, AudioFormat::MONO());

    // get by test_id without preleminary put
    CPPUNIT_ASSERT(rbPool_->getData(test_output, test_id) == 0);

    // put by RingBufferPool::DEFAULT_ID, get by test_id
    mainRingBuffer->put(test_input1);
    CPPUNIT_ASSERT(rbPool_->getData(test_output, test_id) == 1);
    CPPUNIT_ASSERT(test_sample1 == (*test_output.getChannel(0))[0]);

    // get by RingBufferPool::DEFAULT_ID without preleminary put
    CPPUNIT_ASSERT(rbPool_->getData(test_output, RingBufferPool::DEFAULT_ID) == 0);

    // put by test_id, get by RingBufferPool::DEFAULT_ID
    testRingBuffer->put(test_input2);
    CPPUNIT_ASSERT(rbPool_->getData(test_output, RingBufferPool::DEFAULT_ID) == 1);
    CPPUNIT_ASSERT(test_sample2 == (*test_output.getChannel(0))[0]);

    rbPool_->unBindCallID(test_id, RingBufferPool::DEFAULT_ID);
}
Ejemplo n.º 8
0
TEST(MeshLib, AddBottomLayerToPrismMesh)
{
	std::unique_ptr<MeshLib::Mesh> const mesh (MeshLib::MeshGenerator::generateRegularTriMesh(5, 5));
	std::unique_ptr<MeshLib::Mesh> const mesh2 (MeshLib::addLayerToMesh(*mesh, 5, "mesh", true));
	double const height (1);
	std::string const& mat_name ("MaterialIDs");
	boost::optional<MeshLib::PropertyVector<int>&> mats =
		mesh2->getProperties().createNewPropertyVector<int>(mat_name, MeshLib::MeshItemType::Cell);
	if (mats)
	{
		mats->resize(mesh2->getNElements());
		std::fill_n(mats->begin(), mesh2->getNElements(), 0);
	}

	std::unique_ptr<MeshLib::Mesh> const result (MeshLib::addLayerToMesh(*mesh2, height, "mesh", false));
	ASSERT_EQ(mesh2->getNNodes()/2.0 * 3, result->getNNodes());
	ASSERT_EQ(mesh2->getNElements()/2.0 * 3, result->getNElements());

	std::array<unsigned, 7> const n_elems (MeshLib::MeshInformation::getNumberOfElementTypes(*result));
	ASSERT_EQ(mesh->getNElements(), n_elems[1]); // tests if 50 tris are present
	ASSERT_EQ(2 * mesh->getNElements(), n_elems[6]); // tests if 50 prisms are present
	ASSERT_EQ(1, result->getProperties().getPropertyVectorNames().size());
	boost::optional<MeshLib::PropertyVector<int>&> new_mats =
		result->getProperties().getPropertyVector<int>(mat_name);
	ASSERT_EQ(result->getNElements(), new_mats->size());
	ASSERT_EQ(mesh2->getNElements(), std::count(new_mats->cbegin(), new_mats->cend(), 0));
	ASSERT_EQ(mesh->getNElements(), std::count(new_mats->cbegin(), new_mats->cend(), 1));

	MathLib::Vector3 const dir(0, 0, 1);
	std::unique_ptr<MeshLib::Mesh> test_input (
		MeshLib::MeshSurfaceExtraction::getMeshSurface(*mesh2, dir, 90));
	std::unique_ptr<MeshLib::Mesh> test_output (
		MeshLib::MeshSurfaceExtraction::getMeshSurface(*result, dir, 90));
	AddLayerValidation::testZCoords3D(*test_input, *test_output, -1 * height);
	AddLayerValidation::validate(*result, true);
}
Ejemplo n.º 9
0
int main(void) {

    initialize();
    unsigned char b = 'x';

    write_duty(0);
    motoron=0;
    direction = CW;

    LED1 = 1;
    LED2 = 1;
    LED3 = 1;
    LED4 = 1;

    printf("%s %s\rHi! Welcome to the current control menu. Please press the number corresponding to your choice.\r1 = Idle\r2 = PWM Select\r3 = Tuning\r4 = Activate PI controller\r\n", __DATE__, __TIME__);


    while(1) { //The actual running menu portion is currently commented out to test the controller output.

        test_output();
        delay_ms(10000);
        LED1=!LED1;



//MENU

        /*if (USER){
            motoron=0;
            LED1=!LED1;
        }

        b = read_UART();    //read command from UART

        if (b=='1'){
            printf("Motor is in Idle mode.\r\n");
            write_duty(0);
            b='x';
        }

        if (b=='2'){
            printf("PWM mode selected. the motor is running at 10 percent duty.\rpress 'u' to increase it by 10, or press 'd' to decrease it by 10.\rpress'q' to quit.\r\n");
            motoron=1;
            write_duty(100);
            kick();
        while (b=='2'){
            int x = read_UART();
            if (x=='u'){
                write_duty(read_duty()+100);
            }
            else if (x=='d'){
                write_duty(read_duty()-100);
            }
            else if (x=='q'){
                write_duty(0);
                motoron=0;
                b='x';
                printf("PWM mode exited.\r\n");
            }
            }
            }

        if (b=='3'){
            printf("Tuning mode selected.");
            tune='1';
            track_wave(refcurrent);
            motoron=1;
            write_duty(10);
            kick();
            timer1_on();
            while(1);
        }

        if (b=='4'){
            printf("PI controller activated.");
        	run='1';
            motoron=1;
            write_duty(10);
            kick();
            timer1_on();
            while(1);
        }

        else if (b=='x'){
            LED4=!LED4;
            continue;
        }*/
    }



}
Ejemplo n.º 10
0
static int run_test(const unsigned char *k,
                    const unsigned char *h,
                    const unsigned long long hlen,
                    const unsigned char *expected_m,
                    unsigned long long mlen,
                    const unsigned char *expected_c,
                    const unsigned long long expected_clen, 
                    const unsigned char *expected_t)
{
    poet_ctx_t ctx;
    const unsigned long long expected_mlen = mlen;
    unsigned char* c = (expected_clen == 0) ? 
        NULL : (unsigned char*)malloc((size_t)expected_clen);
    unsigned char* m = (mlen == 0) ? 
        NULL : (unsigned char*)malloc((size_t)mlen);
    unsigned char t[TAGLEN];
    unsigned long long clen;

    keysetup(&ctx, k);
    process_header(&ctx, h, hlen);
    encrypt_final(&ctx, expected_m, mlen, c, &clen, t);

    if (clen != expected_clen) {
        printf("Expected ciphertext length %llu, but was %llu bytes \n", 
            expected_clen, clen);
    }

    if (memcmp(expected_c, c, expected_clen)
        || memcmp(expected_t, t, TAGLEN)) {
        test_output(&ctx, k, KEYLEN, h, hlen, expected_m, mlen, 
            c, expected_clen, t, TAGLEN);
        puts("Encryption produced incorrect result");
        free(m);
        free(c);
        return -1;
    }

    keysetup(&ctx, k);
    process_header(&ctx, h, hlen);

    const int result = decrypt_final(&ctx, c, clen, t, m, &mlen);

    if (mlen != expected_mlen) {
        printf("Expected plaintext length %llu, but was %llu bytes \n", 
            expected_mlen, mlen);
    }

    test_output(&ctx, k, KEYLEN, h, hlen, m, mlen, c, expected_clen, t, TAGLEN);

    if (memcmp(expected_m, m, expected_mlen)) {
        puts("Decryption produced incorrect result");
        free(m);
        free(c);
        return -1;
    }
    
    if (result != 0) {
        puts("Verification failed");
    }
    
    free(m);
    free(c);
    return result;
}
void PostProcessingWriter<ELEMENT_DIM, SPACE_DIM>::WriteOutputDataToHdf5(const std::vector<std::vector<double> >& rDataPayload,
                                                                         const std::string& rDatasetName,
                                                                         const std::string& rDatasetUnit,
                                                                         const std::string& rUnlimitedVariableName,
                                                                         const std::string& rUnlimitedVariableUnit)
{
    DistributedVectorFactory* p_factory = mrMesh.GetDistributedVectorFactory();
    FileFinder test_output("", RelativeTo::ChasteTestOutput);
    Hdf5DataWriter writer(*p_factory,
                          mDirectory.GetRelativePath(test_output),  // Path relative to CHASTE_TEST_OUTPUT
                          mHdf5File,
                          false, // to wiping
                          true,  // to extending
                          rDatasetName); // dataset name

    /* Probe define mode. We asked to extend, so if the writer is currently in define mode it means the
     * dataset doesn't exist yet and needs creating. If it is NOT in define mode, it means the dataset
     * exists, so we'll empty it and calculate new postprocessing data. */
    int apd_id;
    if ( writer.IsInDefineMode() )
    {
        apd_id = writer.DefineVariable(rDatasetName, rDatasetUnit);
        writer.DefineFixedDimension(mrMesh.GetNumNodes());
        writer.DefineUnlimitedDimension(rUnlimitedVariableName, rUnlimitedVariableUnit);
        if (mHdf5DataWriterChunkSize>0u)
        {
            /* Pass target chunk size through to writer. (We don't do the
             * alignment one as well because that can only be done for a new
             * file and PostProcessingWriter can only add to an existing file.)
             */
            writer.SetTargetChunkSize(mHdf5DataWriterChunkSize);
        }
        writer.EndDefineMode();
    }
    else
    {
        apd_id = writer.GetVariableByName(rDatasetName);
        writer.EmptyDataset();
    }

    //Determine the maximum number of paces
    unsigned local_max_paces = 0u;
    for (unsigned node_index = 0; node_index < rDataPayload.size(); ++node_index)
    {
        if (rDataPayload[node_index].size() > local_max_paces)
        {
             local_max_paces = rDataPayload[node_index].size();
        }
    }

    unsigned max_paces = 0u;
    MPI_Allreduce(&local_max_paces, &max_paces, 1, MPI_UNSIGNED, MPI_MAX, PETSC_COMM_WORLD);

    for (unsigned pace_idx = 0; pace_idx < max_paces; pace_idx++)
    {
        Vec apd_vec = p_factory->CreateVec();
        DistributedVector distributed_vector = p_factory->CreateDistributedVector(apd_vec);
        for (DistributedVector::Iterator index = distributed_vector.Begin();
             index!= distributed_vector.End();
             ++index)
        {
            unsigned node_idx = index.Local;
            // pad with -999 if no pace defined at this node
            if (pace_idx < rDataPayload[node_idx].size() )
            {
                distributed_vector[index] = rDataPayload[node_idx][pace_idx];
            }
            else
            {
                distributed_vector[index] = -999.0;
            }
        }
        writer.PutVector(apd_id, apd_vec);
        PetscTools::Destroy(apd_vec);
        writer.PutUnlimitedVariable(pace_idx);
        writer.AdvanceAlongUnlimitedDimension();
    }
    writer.Close();
}