示例#1
0
/**
 * \brief Test EEPROM byte erase
 *
 * This test writes two bytes to test pages \ref TEST_ERASE_BYTES_PAGE_1 and
 * \ref TEST_ERASE_BYTES_PAGE_2, then tries to erase one of them in the first
 * page before verifying the erase, then in all pages before verifying that the
 * second page was also erased.
 *
 * \param test Current test case.
 */
static void run_eeprom_erase_byte_test(const struct test_case *test)
{
	uint8_t buffer[EEPROM_PAGE_SIZE];
	bool    success;

	set_buffer(buffer, EEPROM_ERASED);
	buffer[0] = 0xaa;
	buffer[1] = 0xaf;

	/* Write two bytes into first page */
	nvm_eeprom_write_byte(TEST_ERASE_BYTES_PAGE_1 * EEPROM_PAGE_SIZE + 0,
			buffer[0]);
	nvm_eeprom_write_byte(TEST_ERASE_BYTES_PAGE_1 * EEPROM_PAGE_SIZE + 1,
			buffer[1]);

	/* Write two bytes into second page */
	nvm_eeprom_write_byte(TEST_ERASE_BYTES_PAGE_2 * EEPROM_PAGE_SIZE + 0,
			buffer[0]);
	nvm_eeprom_write_byte(TEST_ERASE_BYTES_PAGE_2 * EEPROM_PAGE_SIZE + 1,
			buffer[1]);

	/* Erase first byte of the first page */
	nvm_eeprom_load_byte_to_buffer(0, 0xff);
	nvm_eeprom_erase_bytes_in_page(TEST_ERASE_BYTES_PAGE_1);
	buffer[0] = EEPROM_ERASED;

	success = is_eeprom_page_equal_to_buffer(TEST_ERASE_BYTES_PAGE_1, buffer);
	test_assert_true(test, success, "Byte erase in single page failed");

	/* Erase first byte of all pages */
	nvm_eeprom_load_byte_to_buffer(0, 0xff);
	nvm_eeprom_erase_bytes_in_all_pages();

	success = is_eeprom_page_equal_to_buffer(TEST_ERASE_BYTES_PAGE_2, buffer);
	test_assert_true(test, success, "Byte erase in all pages failed");
}
示例#2
0
/**
 * \brief Test Early Warning of Watchdog module
 *
 * If last reset cause was not Watchdog, following the Watchdog initialization
 * and enabling in the previous test, this function will wait for
 * CONF_WDT_EARLY_WARNING_WAIT_MS and will check if early warning flag is set.
 * Consequently, clear the early warning flag.
 *
 * \param test Current test case.
 */
static void run_wdt_early_warning_test(const struct test_case *test)
{
	/* Check if last reset was by Watchdog module */
	if (wdr_flag == false) {
		/* Wait for Early Warning flag to be set */
		delay_ms(CONF_WDT_EARLY_WARNING_WAIT_MS);

		/* Check if the Early Warning flag is set */
		test_assert_true(test, wdt_is_early_warning() == true,
				"Early Warning failed \n");

		/* Clear the Early Warning flag */
		wdt_clear_early_warning();
	}
}
示例#3
0
void test_copy() {
  state_map_type * state_map = state_map_alloc();
  state_map_iset( state_map , 0 , STATE_INITIALIZED );
  state_map_iset( state_map , 100 , STATE_INITIALIZED );
  {
    state_map_type * copy = state_map_alloc_copy( state_map );
    test_assert_true( state_map_equal( copy , state_map ));

    state_map_iset( state_map , 10 , STATE_INITIALIZED );
    test_assert_false( state_map_equal( copy , state_map ));                      
    
    state_map_free( copy );
  }
  state_map_free( state_map );
}
示例#4
0
/**
 * \brief Test wakeup functions.
 *
 * \param test Current test case.
 */
static void run_picouart_test(const struct test_case *test)
{
	uint8_t value;
	Pm *p_pm = PM;
	struct picouart_dev_inst dev_inst;
	struct picouart_config config;

	/* Init the PICOUART */
	picouart_get_config_defaults(&config);
	picouart_init(&dev_inst, PICOUART, &config);

	/* Enable the PICOUART */
	picouart_enable(&dev_inst);
	delay_ms(30);

	/* PICOUART can wakeup the device. */
	bpm_enable_wakeup_source(BPM, (1 << BPM_BKUPWEN_PICOUART));
	p_pm->PM_AWEN = 1 << PM_AWEN_PICOUART;
	p_pm->PM_IER = PM_IER_WAKE;
	NVIC_SetPriority(PM_IRQn,1);
	NVIC_EnableIRQ(PM_IRQn);

	config.action = PICOUART_ACTION_WAKEUP_ON_STARTBIT;
	picouart_set_config(&dev_inst, &config);
	bm_send_picouart_frame('A', 1);
	bpm_sleep(BPM, BPM_SM_SLEEP_1);

	config.action = PICOUART_ACTION_WAKEUP_ON_FULLFRAME;
	picouart_set_config(&dev_inst, &config);
	bm_send_picouart_frame('T', 5);
	bpm_sleep(BPM, BPM_SM_SLEEP_3);

	config.action = PICOUART_ACTION_WAKEUP_ON_FULLFRAME;
	picouart_set_config(&dev_inst, &config);
	bm_send_picouart_frame('M', 5);
	bpm_sleep(BPM, BPM_SM_WAIT);

	config.action = PICOUART_ACTION_WAKEUP_ON_MATCH;
	config.match = 'L';
	picouart_set_config(&dev_inst, &config);
	bm_send_picouart_frame('L', 10);
	bpm_sleep(BPM, BPM_SM_RET);
	while(!picouart_is_data_ready(&dev_inst)) {
	}
	picouart_read(&dev_inst, &value);
	test_assert_true(test, value == 'L', "Picouart wakeup not work!");

}
示例#5
0
void test_write_gen_kw_export_file(enkf_main_type * enkf_main)
{
  test_assert_not_NULL(enkf_main);
  enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
  test_assert_not_NULL(state);
  enkf_node_type * enkf_node = enkf_state_get_node( state , "MULTFLT" );
  test_assert_not_NULL(enkf_node);
  const enkf_config_node_type * config_node = enkf_node_get_config(enkf_node);
  test_assert_not_NULL(config_node);

  if (GEN_KW == enkf_config_node_get_impl_type(config_node)) {
    enkf_fs_type * fs = enkf_main_get_fs(enkf_main);
    enkf_state_ecl_write(state, fs);
    test_assert_true(util_file_exists("parameters.txt"));
  }
}
示例#6
0
void test_create_from_summary(ecl_grid_type * grid) {
  container_config_type * container_config = container_config_alloc( "Container");
  block_obs_type * block_obs = block_obs_alloc( "ObsKey" , container_config , grid );
  
  test_assert_true( block_obs_is_instance( block_obs ));
  test_assert_int_equal(0 , block_obs_get_size( block_obs ));

  
  block_obs_append_summary_obs( block_obs , 10 , 12 , 8  , "BPR:111,13,9" , 100 , 25);
  test_assert_int_equal(1 , block_obs_get_size( block_obs ));
  block_obs_append_summary_obs( block_obs , 10 , 12 , 9  , "BPR:11,13,10" , 100 , 25);
  test_assert_int_equal(2 , block_obs_get_size( block_obs ));
  block_obs_free( block_obs );

  container_config_free( container_config );
}
示例#7
0
/**
 * \internal
 * \brief Test of tc_init() and tc_get_config_defaults()
 *
 * This test is used to initialize the tcx_module structs and associate the given
 * hw module with the struct. This test should be run at the very beginning of
 * testing as other tests depend on the result of this test.
 */
static void run_init_test(const struct test_case *test)
{
	tc_get_config_defaults(&tc_test0_config);
	enum status_code test1 = tc_init(&tc_test0_module, CONF_TEST_TC0, &tc_test0_config);

	tc_get_config_defaults(&tc_test1_config);
	enum status_code test2 = tc_init(&tc_test1_module, CONF_TEST_TC1, &tc_test1_config);

	if ((test1 == STATUS_OK) && (test2 == STATUS_OK)) {
		tc_init_success = true;
	}

	test_assert_true(test,
			(test2 == STATUS_OK) && (test1 == STATUS_OK),
			"Failed to initialize modules");
}
示例#8
0
static void run_lwmesh_nwk_darareq_test(const struct test_case *test)
{
	unitDataReq();
	while (1) {
		if (result) {
			break;
		}

		if (timeout) {
			test_assert_true(test, 0,
					"AVR2130_LWMesh - NWK Data request failed");
		}

		SYS_TaskHandler();
	}
}
示例#9
0
void test_install_workflow( const char * config_file , const char * job_file ) {
  ert_test_context_type * test_context = ert_test_context_alloc("INSTALL_WORKFLOW" , config_file , NULL );
  const char * wf_file = "WFLOW";

  ert_test_context_install_workflow_job( test_context , "JOB" , job_file );
  {
    FILE * stream = util_fopen( wf_file , "w");
    stringlist_type * args = stringlist_alloc_new( );
    stringlist_append_ref( args , "NewCase");
    ert_test_context_fwrite_workflow_job( stream , "JOB" , args);
    stringlist_free( args );
    fclose( stream );
  }
  test_assert_true( ert_test_context_install_workflow( test_context , "WFLOW" , wf_file ));
  ert_test_context_free( test_context );
}
示例#10
0
void test_run_workflow_job( const char * config_file , const char * job_file ) {
  ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT_JOB" , config_file , NULL );
  stringlist_type * args0 = stringlist_alloc_new( );
  stringlist_type * args1 = stringlist_alloc_new( );

  stringlist_append_ref( args1 , "NewCase");
  test_assert_false( ert_test_context_run_worklow_job( test_context , "NO-this-does-not-exist" , args1));
  ert_test_context_install_workflow_job( test_context , "JOB" , job_file );
  
  test_assert_false( ert_test_context_run_worklow_job( test_context , "JOB" , args0));
  test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args1));
  
  stringlist_free( args0 );
  stringlist_free( args1 );
  ert_test_context_free( test_context );
}
示例#11
0
void test_case_initialized() {
  test_work_area_type * work_area = test_work_area_alloc("enkf_main_case_initialized" );
  {
    enkf_main_type * enkf_main = enkf_main_alloc_empty();
    model_config_type * model_config = enkf_main_get_model_config(enkf_main);
    const char * new_case = "fs/case";
    char * mount_point = util_alloc_sprintf("%s/%s" , model_config_get_enspath(model_config) , new_case);
    enkf_fs_create_fs(mount_point , BLOCK_FS_DRIVER_ID , NULL);

    test_assert_false(enkf_main_case_is_initialized(enkf_main , "does/not/exist" , NULL));
    test_assert_true(enkf_main_case_is_initialized(enkf_main , new_case , NULL));

    enkf_main_free(enkf_main);
  }
  test_work_area_free(work_area);
}
示例#12
0
文件: unit_tests.c 项目: marekr/asf
/**
 * \brief Test the OV7740 initialization.
 *
 * \param test Current test case.
 */
static void ov7740_test_initialization_run(const struct test_case* const test)
{
	volatile uint32_t ul_error = 0;

	ul_error = capture_init();

	/* if initialization test failed, set g_ul_init_error_flag to avoid
	 * other tests to lock up */
	if (ul_error == 1) {
		g_ul_init_error_flag = true;
	}

	/* Check Result of the previous test */
	test_assert_true(test, ul_error == 0,
			"OV7740 initialization test failed!");
}
示例#13
0
/**
 * \brief Test running speed between different arbitration configurations.
 *
 * \param test Current test case.
 */
static void run_hmatrix_test_arbitration(const struct test_case *test)
{
	enum hmatrix_master_id ul_master_id;
	enum hmatrix_slave_id ul_slave_id;
	uint32_t ul_cnt1, ul_cnt2;
	struct hmatrix_master_ch_conf master_config;
	struct hmatrix_slave_ch_conf slave_config;
	hmatrix_prs priority_setting;

	/* Enable the HMATRIX access. */
	hmatrix_enable();
	hmatrix_master_ch_get_config_defaults(&master_config);
	hmatrix_slave_ch_get_config_defaults(&slave_config);

	/* Config all master with default setting */
	for (ul_master_id = HMATRIX_MASTER_ID_CPU_IDCORE;
				ul_master_id < HMATRIX_MASTER_ID_NUM; ul_master_id++) {
			hmatrix_master_ch_set_config(ul_master_id, &master_config);
		}

	/* Compare 1: First, test with Round-Robin arbitration */
	for (ul_slave_id = HMATRIX_SLAVE_ID_FLASH;
			ul_slave_id < HMATRIX_SLAVE_ID_NUM; ul_slave_id++) {
		hmatrix_slave_ch_set_config(ul_slave_id, &slave_config);
	}
	ul_cnt1 = toggle_led_test(1000);

	/* Compare 1: Second, test with fixed arbitration */
	slave_config.arbitration_type = HMATRIX_ARBITRATION_FIXED_PRIORITY;
	priority_setting.HMATRIXB_PRAS = 0x03;
	priority_setting.HMATRIXB_PRBS = 0x00;
	hmatrix_set_slave_priority(HMATRIX_SLAVE_ID_FLASH, &priority_setting);
	hmatrix_slave_ch_set_config(HMATRIX_SLAVE_ID_FLASH, &slave_config);
	priority_setting.HMATRIXB_PRAS = 0x30;
	priority_setting.HMATRIXB_PRBS = 0x00;
	for (ul_slave_id = HMATRIX_SLAVE_ID_PBA;
			ul_slave_id < HMATRIX_SLAVE_ID_NUM; ul_slave_id++) {
		hmatrix_set_slave_priority(ul_slave_id, &priority_setting);
		hmatrix_slave_ch_set_config(ul_slave_id, &slave_config);
	}
	ul_cnt2 = toggle_led_test(1000);

	test_assert_true(test, (ul_cnt1 < ul_cnt2), "running speed test failed!");

	/* Disable the HMATRIX access. */
	hmatrix_disable();
}
示例#14
0
/**
 * \brief Test interrupt is getting triggered in various Sleep mode.
 *
 * This function put the device in Idle and Power Save sleep mode and check
 * whether the ADC conversion complete interrupt is executed only in Idle sleep
 * mode.
 * The device will wakeup from power save mode when Timer/Counter2 overflow
 * occur.
 *
 * \param test Current test case.
 */
static void run_sleep_trigger_test(const struct test_case *test)
{
    /* Disable Global interrupt */
    cpu_irq_disable();
    /* Initialize the lock counts */
    sleepmgr_init();
    /* Initialize the ADC */
    adc_initialisation();
    /* Initialize the Timer/Counter2 */
    timer2_initialisation();
    /* Lock Idle Sleep mode */
    sleepmgr_lock_mode(SLEEPMGR_IDLE);
    /* Clear Timer/Counter2 Register */
    TCNT2 = 0;
    /* Wait for TCNT2 register to get updated */
    while (ASSR & (1 << TCN2UB)) {
    }
    /* Start ADC Conversion */
    adc_start_conversion();
    /* Enable Global interrupt */
    cpu_irq_enable();
    /* Go to sleep in the deepest allowed mode */
    sleepmgr_enter_sleep();
    /* Unlock Idle Sleep mode */
    sleepmgr_unlock_mode(SLEEPMGR_IDLE);
    /* Lock Power Save mode */
    sleepmgr_lock_mode(SLEEPMGR_PSAVE);
    /* Clear Timer/Counter2 Register */
    TCNT2 = 0;
    /* Wait for TCNT2 register to get updated */
    while (ASSR & (1 << TCN2UB)) {
    }
    /* Start ADC Conversion */
    adc_start_conversion();
    /* Go to sleep in the deepest allowed mode */
    sleepmgr_enter_sleep();
    /* Disable ADC */
    adc_disable();
    /* Unlock Power Save mode */
    sleepmgr_unlock_mode(SLEEPMGR_PSAVE);

    /* Disable Global interrupt */
    cpu_irq_disable();

    test_assert_true(test, trigger_count == 2,
                     "ADC interrupt trigger failed.");
}
示例#15
0
/**
 * \brief Get the gravity value of z axis.
 *
 * This test calls the get gravity value API functions and check if the value is in correct range.
 *
 * \param test Current test case.
 */
static void run_test_get_gravity_value(const struct test_case *test)
{
	xyz_g_t xyz_g;

	/* Set MMA7341L normal mode */
	mma7341l_set_mode(MMA7341L_NORMAL_MODE);

	/* Initialize MMA7341L */
	mma7341l_init();

	/* Calibrate MMA7341L */
	mma7341l_calibration();

	xyz_g = mma7341l_get_gravity_value();

	test_assert_true(test, 0.9 < xyz_g.z_g < 1.1, "The gravity value is not in correct range");
}
示例#16
0
/**
 * \internal
 * \brief Test spinning through a spincollection and cancelling
 *
 * This test checks that spinning in a spincollection with two spinners
 * and pressing the back button results in the correct event.
 *
 * \param test Current test case.
 */
static void run_event_back_spincollection_test(const struct test_case *test)
{
	int16_t actual[2];
	uint8_t actual_status_code;
	uint8_t expected_status_code;
	struct gfx_mono_spinctrl spinner;
	struct gfx_mono_spinctrl spinner2;
	struct gfx_mono_spinctrl_spincollection spincollection;

	expected_status_code = GFX_MONO_SPINCTRL_EVENT_BACK;

	// Initialize spinners and spincollection and add spinners to collection
	gfx_mono_spinctrl_init(&spinner, SPINTYPE_INTEGER, spinnertitle2, NULL,
			40, 48, 0);
	gfx_mono_spinctrl_init(&spinner2, SPINTYPE_INTEGER, spinnertitle3, NULL,
			55, 110, 0);
	gfx_mono_spinctrl_spincollection_init(&spincollection);
	gfx_mono_spinctrl_spincollection_add_spinner(&spinner, &spincollection);
	gfx_mono_spinctrl_spincollection_add_spinner(&spinner2, &spincollection);

	// Go down to next spinner
	gfx_mono_spinctrl_spincollection_process_key(&spincollection,
			GFX_MONO_SPINCTRL_KEYCODE_DOWN, actual);
	// Select current spinner
	gfx_mono_spinctrl_spincollection_process_key(&spincollection,
			GFX_MONO_SPINCTRL_KEYCODE_ENTER, actual);
	// Spin spinner
	gfx_mono_spinctrl_spincollection_process_key(&spincollection,
			GFX_MONO_SPINCTRL_KEYCODE_DOWN, actual);
	// Spin spinner
	gfx_mono_spinctrl_spincollection_process_key(&spincollection,
			GFX_MONO_SPINCTRL_KEYCODE_DOWN, actual);
	// Spin spinner
	gfx_mono_spinctrl_spincollection_process_key(&spincollection,
			GFX_MONO_SPINCTRL_KEYCODE_DOWN, actual);
	// Deselect spinner
	gfx_mono_spinctrl_spincollection_process_key(&spincollection,
			GFX_MONO_SPINCTRL_KEYCODE_BACK, actual);
	// Cancel spincollection
	actual_status_code = gfx_mono_spinctrl_spincollection_process_key(
			&spincollection, GFX_MONO_SPINCTRL_KEYCODE_BACK, actual);

	test_assert_true(test, actual_status_code == expected_status_code,
			"Status code mismatch: %d != %d", actual_status_code,
			expected_status_code);
}
示例#17
0
void create_test_area(const char * test_name , bool store) {
  char * pre_cwd = util_alloc_cwd();
  test_work_area_type * work_area = test_work_area_alloc( test_name , store);
  char * work_path = util_alloc_string_copy( test_work_area_get_cwd( work_area ));
  
  test_assert_true( util_is_directory( work_path ));
  test_work_area_free( work_area );
  test_assert_bool_equal( store , util_entry_exists( work_path ));
  
  {
    char * post_cwd = util_alloc_cwd();
    test_assert_string_equal( pre_cwd , post_cwd );
    free( post_cwd );
  }
  free( pre_cwd );
  free( work_path );
}
示例#18
0
/**
 * \brief Test device serial number readout
 *
 * This test reads out the \e LOTNUMn, \e WAFNUM, \e COORDXn and \e COORDYn
 * values from the device signature row and checks that they are not all 0xFF.
 *
 * \param test Current test case.
 */
static void run_device_serial_test(const struct test_case *test)
{
	struct nvm_device_serial dev_sn;
	bool serial_is_set;
	uint8_t byte_index;

	nvm_read_device_serial(&dev_sn);

	serial_is_set = false;
	for (byte_index = 0; byte_index < sizeof(dev_sn.byte); byte_index++) {
		if (dev_sn.byte[byte_index] != 0xff) {
			serial_is_set = true;
			break;
		}
	}
	test_assert_true(test, serial_is_set, "Read device serial as all 0xFF");
}
示例#19
0
文件: unit_tests.c 项目: marekr/asf
/**
 * \brief Test color of the reference picture from OV7740 image sensor.
 *
 * \param test Current test case.
 */
static void ov7740_test_color_run(const struct test_case* const test)
{
	uint32_t ul_error = 0;
	volatile uint32_t ul_index = 25600UL; /* put the index at the middle of
																					* data buffer */

	/* Check if picture color is similar to reference color. There are 8
	 * reference colors
	 * (Black, Blue, Red, Purple, Green, Cyan, Yellow, White) and each of
	 * these contains 80 pixel.
	 * So put the index to the middle of the testing color area of picture
	 * and test this color.
	 */
	/* Test black color */
	ul_error += test_color((uint8_t *)g_auc_data_black_color,
			g_auc_capture_buffer, ul_index + 40 );
	/* Test blue color */
	ul_error += test_color((uint8_t *)g_auc_data_blue_color, g_auc_capture_buffer,
			ul_index + 120);

	/* Test red color */
	ul_error += test_color((uint8_t *)g_auc_data_red_color, g_auc_capture_buffer,
			ul_index + 200);

	/* Test purple color */
	ul_error += test_color((uint8_t *)g_auc_data_purple_color,
			g_auc_capture_buffer, ul_index + 280);

	/* Test green color */
	ul_error += test_color((uint8_t *)g_auc_data_green_color,
			g_auc_capture_buffer, ul_index + 360);

	/* Test cyan color */
	ul_error += test_color((uint8_t *)g_auc_data_cyan_color, g_auc_capture_buffer,
			ul_index + 440);

	/* Test yellow color */
	ul_error += test_color((uint8_t *)g_auc_data_yellow_color,
			g_auc_capture_buffer, ul_index + 520 );

	/* Test white color */
	ul_error += test_color((uint8_t *)g_auc_data_white_color,
			g_auc_capture_buffer, ul_index + 600);
	/* Check Result of previous test */
	test_assert_true(test, ul_error == 0, "OV7740 color test failed!");
}
示例#20
0
void test_kw_io_charlength() {
  test_work_area_type * work_area = test_work_area_alloc("ecl_kw_io_charlength");
  { 
    const char * KW0 = "QWERTYUI";
    const char * KW1 = "ABCDEFGHIJTTTTTTTTTTTTTTTTTTTTTTABCDEFGHIJKLMNOP";
    ecl_kw_type * ecl_kw_out0 = ecl_kw_alloc(KW0 , 5, ECL_FLOAT);
    ecl_kw_type * ecl_kw_out1 = ecl_kw_alloc(KW1 , 5, ECL_FLOAT);
    for (int i=0; i < ecl_kw_get_size( ecl_kw_out1); i++) {
       ecl_kw_iset_float( ecl_kw_out0 , i , i*1.5 );
       ecl_kw_iset_float( ecl_kw_out1 , i , i*1.5 );
    }

    {
       fortio_type * f = fortio_open_writer( "TEST1" , false, ECL_ENDIAN_FLIP );
       test_assert_true( ecl_kw_fwrite( ecl_kw_out0, f ));
       test_assert_false(ecl_kw_fwrite( ecl_kw_out1, f ));
       fortio_fclose( f );
    }

    {
       test_assert_false( util_file_exists( "TEST1"));
    }
   
    {
       FILE * file = util_fopen("TEST2", "w");
       ecl_kw_fprintf_grdecl(ecl_kw_out1 , file);
       fclose(file);
    }
    
    {
       FILE * file = util_fopen("TEST2", "r");
       ecl_kw_type * ecl_kw_in = ecl_kw_fscanf_alloc_grdecl( file , KW1 , -1 , ECL_FLOAT);
       test_assert_string_equal(KW1, ecl_kw_get_header(ecl_kw_in) );
       test_assert_int_equal(5, ecl_kw_get_size( ecl_kw_in) );

       test_assert_double_equal(ecl_kw_iget_as_double(ecl_kw_in, 0), 0.0);
       test_assert_double_equal(ecl_kw_iget_as_double(ecl_kw_in, 4), 6.0);

       fclose(file);
    }
    
    ecl_kw_free( ecl_kw_out0 );
    ecl_kw_free( ecl_kw_out1 );
  }
  test_work_area_free( work_area );
}
示例#21
0
文件: ecl_file.c 项目: Ensembles/ert
void test_loadall(const char * src_file , const char * target_file ) {
  util_copy_file( src_file , target_file );
  {
    ecl_file_type * ecl_file = ecl_file_open( target_file , ECL_FILE_CLOSE_STREAM );

    test_assert_true( ecl_file_load_all( ecl_file ) );
    ecl_file_close( ecl_file );
  }

  {
    ecl_file_type * ecl_file = ecl_file_open( target_file , ECL_FILE_CLOSE_STREAM );
    unlink( target_file );

    test_assert_false( ecl_file_load_all( ecl_file ) );
    ecl_file_close( ecl_file );
  }
}
示例#22
0
/**
 * \brief Test entering and exiting backup mode.
 *
 * \param test Current test case.
 */
static void run_backup_test(const struct test_case *test)
{
	volatile uint32_t wakeup_cause = bpm_get_backup_wakeup_cause(BPM);
	/* Wakeup from backup mode */
	if (wakeup_cause) {
		test_assert_true(test, wakeup_cause & (1 << BPM_BKUPWEN_AST),
			"Unexpected backup wakeup cause, should be AST!");
		return;
	}

	/* Wait for the printf operation to finish before
	setting the device in a power save mode. */
	delay_ms(30);

	/* Enter backup mode */
	bpm_sleep(BPM, BPM_SM_BACKUP);
}
示例#23
0
/**
 * \internal
 * \brief ADC window mode test function
 *
 * This test gives an input voltage outside the window and checks
 * whether the callback is triggered or not.
 *
 * \param test Current test case.
 */
static void run_adc_window_mode_test(const struct test_case *test)
{
	uint16_t timeout_cycles = 0xFFFF;

	/* Set 1V DAC output */
	dac_chan_write(&dac_inst, DAC_CHANNEL_0, DAC_VAL_ONE_VOLT);
	delay_ms(1);

	do {
		timeout_cycles--;
		if (interrupt_flag) {
			break;
		}
	} while (timeout_cycles > 0);
	test_assert_true(test, timeout_cycles > 0,
			"Timeout in window detection");
}
示例#24
0
/**
 * \brief Test AT25DFx initialization procedure.
 *
 * This test calls the initialization function and checks the SerialFlash.
 *
 * \param test Current test case.
 */
static void run_test_at25dfx_init(const struct test_case *test)
{
    at25_status_t status;

    /* Initialize the SerialFlash */
    at25dfx_initialize();

    /* Set the SerialFlash active */
    at25dfx_set_mem_active(AT25DFX_MEM_ID);

    /* Check if the SerialFlash is valid */
    status = at25dfx_mem_check();

    /* Validate the SerialFlash init and check function */
    test_assert_true(test, status == AT25_SUCCESS,
                     "Specific SerialFlash not found!");
}
示例#25
0
文件: test_util.c 项目: blattms/ert
void test_util_addr2line() {
  const char * file = __FILE__;
  const char * func = __func__;
  int    line;
  const int max_bt = 50;
  void *bt_addr[max_bt];  
  int size;
  char * func_name , * file_name;
  int line_nr;
  
  line = __LINE__ + 2;
  size = backtrace(bt_addr , max_bt);    
  test_assert_int_equal( size , 4 );
  test_assert_true( util_addr2line_lookup( bt_addr[0] , &func_name , &file_name , &line_nr));
  test_assert_string_equal( func_name , func );
  test_assert_int_equal( line , line_nr );
  test_assert_string_equal( file_name , file );
}
示例#26
0
void test_column_equal() {
  matrix_type * m1 = matrix_alloc(5,5);
  matrix_type * m2 = matrix_alloc(5,5);
  matrix_type * m3 = matrix_alloc(6,5);
  rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); 

  matrix_random_init( m1 , rng );
  matrix_assign( m2 , m1 );

  test_assert_true( matrix_columns_equal( m1 , 2 , m2 , 2 ));
  test_assert_false( matrix_columns_equal( m1 , 2 , m2 , 3 ));
  test_assert_false( matrix_columns_equal( m1 , 2 , m3 , 3 ));
  
  rng_free( rng );
  matrix_free( m1 );
  matrix_free( m2 );
  matrix_free( m3 );
}
示例#27
0
/**
 * \internal
 * \brief Setup Function: ADC callback mode test.
 *
 * This function initializes the ADC result buffer and
 * registers & enables callback for the ADC buffer read.
 *
 * \param test Current test case.
 */
static void setup_adc_callback_mode_test(const struct test_case *test)
{
	interrupt_flag = false;

	/* Skip test if ADC initialization failed */
	test_assert_true(test, adc_init_success,
			"Skipping test due to failed initialization");

	/* Initialize ADC buffer */
	for (uint8_t i = 0; i < ADC_SAMPLES; i++) {
		adc_buf[i] = 0;
	}

	/* Register and enable buffer read callback */
	adc_register_callback(&adc_inst, adc_user_callback,
			ADC_CALLBACK_READ_BUFFER);
	adc_enable_callback(&adc_inst, ADC_CALLBACK_READ_BUFFER);
}
示例#28
0
/**
 * \brief Test 32KHz oscillator
 *
 * This test enables the 32KHz oscillator, and then
 * check if they can be used after startup time
 *
 * \param test Current test case.
 */
static void run_osc32_test(const struct test_case *test)
{
#ifdef BOARD_OSC32_HZ
    uint32_t osc32_startup_timeout;
    volatile uint32_t wait;
    bool status;

    osc_enable(OSC_ID_OSC32);
    osc32_startup_timeout = OSC_RCSYS_NOMINAL_HZ/4;
    // wait for 1s
    for (wait = 0; wait < osc32_startup_timeout; wait++) {
        //waiting the 32KHz oscillator ready
        __asm__("nop");
    };
    status = osc_is_ready(OSC_ID_OSC32);
    test_assert_true(test, status, "32KHz oscillator is not stable");
#endif
}
示例#29
0
int main(int argc , char ** argv) {
  const char * config_file = argv[1];
  config_parser_type * config = config_alloc();
  config_content_type * content;
  ensemble_config_type * ensemble = ensemble_config_alloc();

  enkf_config_node_add_GEN_PARAM_config_schema( config );

  content = config_parse( config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true );
  test_assert_true( config_content_is_valid( content ) );

  ensemble_config_init_GEN_PARAM( ensemble, content );

  config_content_free( content );
  config_free( config );
  ensemble_config_free( ensemble );
  exit(0);
}
示例#30
0
int main(int argc , char ** argv) {
  int lgr_nr = 77;
  nnc_info_type * nnc_info = nnc_info_alloc(lgr_nr);   

  test_assert_int_equal( 0 , nnc_info_get_total_size( nnc_info ));
  test_assert_int_equal( lgr_nr , nnc_info_get_lgr_nr(  nnc_info ));
  test_assert_true(nnc_info_is_instance(nnc_info));
  test_assert_not_NULL(nnc_info); 
  
  nnc_info_add_nnc(nnc_info, lgr_nr, 110 , 0);
  test_assert_int_equal( 1, nnc_info_get_total_size( nnc_info ));
  
  nnc_info_add_nnc(nnc_info, 1, 110 , 1);
  nnc_info_add_nnc(nnc_info, 1, 111 , 2);
  test_assert_int_equal( 3, nnc_info_get_total_size( nnc_info ));
  

  nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1);
  const int_vector_type * nnc_cells = nnc_info_get_grid_index_list(nnc_info, 1); 
  test_assert_int_equal(int_vector_size(nnc_cells), 2); 
  test_assert_ptr_equal( nnc_cells , nnc_vector_get_grid_index_list( nnc_vector ));


  nnc_vector_type * nnc_vector_null  = nnc_info_get_vector( nnc_info , 2);
  const int_vector_type * nnc_cells_null = nnc_info_get_grid_index_list(nnc_info, 2); 
  test_assert_NULL(nnc_cells_null); 
  test_assert_NULL(nnc_vector_null); 
  
  nnc_vector_type * nnc_vector_self  = nnc_info_get_self_vector( nnc_info );
  const nnc_vector_type * nnc_vector_77  = nnc_info_get_vector( nnc_info , lgr_nr );
  test_assert_ptr_equal( nnc_vector_77 , nnc_vector_self );

  const int_vector_type * nnc_cells_77 = nnc_info_get_grid_index_list(nnc_info, lgr_nr); 
  const int_vector_type * nnc_cells_self = nnc_info_get_self_grid_index_list(nnc_info); 
  test_assert_ptr_equal( nnc_cells_77 , nnc_cells_self );


  test_assert_int_equal( 2 , nnc_info_get_size( nnc_info ));
  test_assert_ptr_equal( nnc_info_get_vector( nnc_info , 1 ) , nnc_info_iget_vector( nnc_info , 1 ));
  nnc_info_free(nnc_info);
  

  exit(0);
}