Microchip® Advanced Software Framework

services/eeprom/emulator/main_array/unit_test/unit_test.c File Reference

SAM EEPROM Emulator Service Unit test.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <stdio_serial.h>
#include <string.h>
#include "conf_test.h"

Macros

#define TEST_BUFFER_OFFSET   123
 
#define TEST_BUFFER_SIZE   19
 
#define TEST_EEPROM_PAGE   1
 

Functions

static void cdc_uart_init (void)
 Initialize the USART for unit test. More...
 
int main (void)
 Run EEPROM emulator unit tests. More...
 
static void run_eeprom_buffer_read_write_test (const struct test_case *test)
 Test for EEPROM emulator buffer read/write function. More...
 
static void run_eeprom_init_test (const struct test_case *test)
 Test for EEPROM emulator initialization. More...
 
static void run_eeprom_page_read_write_test (const struct test_case *test)
 Test for EEPROM emulator page read/write function. More...
 
static void setup_eeprom_buffer_read_write_test (const struct test_case *test)
 Setup function for EEPROM emulator buffer read/write test. More...
 
static void setup_eeprom_page_read_write_test (const struct test_case *test)
 Setup function for EEPROM emulator page read/write test. More...
 

Variables

struct usart_module cdc_uart_module
 
struct eeprom_emulator_parameters ee_params
 
uint16_t i
 
volatile bool init_success
 
uint8_t test_buffer [TEST_BUFFER_SIZE]
 
uint8_t test_page [EEPROM_PAGE_SIZE]
 
uint8_t verify_buffer [TEST_BUFFER_SIZE]
 
uint8_t verify_page [EEPROM_PAGE_SIZE]
 

#define TEST_BUFFER_OFFSET   123
#define TEST_BUFFER_SIZE   19
#define TEST_EEPROM_PAGE   1

static void cdc_uart_init ( void  )
static
int main ( void  )

Run EEPROM emulator unit tests.

Initializes the system and serial output, then sets up the EEPROM emulator unit test suite and runs it.

References cdc_uart_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_eeprom_buffer_read_write_test(), run_eeprom_init_test(), run_eeprom_page_read_write_test(), setup_eeprom_buffer_read_write_test(), setup_eeprom_page_read_write_test(), system_init(), and test_suite_run().

static void run_eeprom_buffer_read_write_test ( const struct test_case test)
static

Test for EEPROM emulator buffer read/write function.

This test writes a buffer of data of a given length to a given offset. It then reads back the data from that offset and verifies.

Parameters
testCurrent test case.

References eeprom_emulator_commit_page_buffer(), eeprom_emulator_read_buffer(), eeprom_emulator_write_buffer(), i, init_success, status, STATUS_OK, test_assert_true, test_buffer, TEST_BUFFER_OFFSET, TEST_BUFFER_SIZE, and verify_buffer.

Referenced by main().

static void run_eeprom_init_test ( const struct test_case test)
static

Test for EEPROM emulator initialization.

This test initializes the EEPROM emulator. If no memory was set for EEPROM in the fuses then all test will be skipped. During initialization it will format the EEPROM memory if it was not done previously.

It also checks the get parameter functionality.

Parameters
testCurrent test case.

References ee_params, eeprom_emulator_erase_memory(), eeprom_emulator_get_parameters(), eeprom_emulator_init(), EEPROM_PAGE_SIZE, init_success, eeprom_emulator_parameters::page_size, status, STATUS_ERR_NO_MEMORY, STATUS_OK, and test_assert_true.

Referenced by main().

static void run_eeprom_page_read_write_test ( const struct test_case test)
static

Test for EEPROM emulator page read/write function.

This test writes a page of data to a given page number. It then reads back the page and verifies.

Parameters
testCurrent test case.

References eeprom_emulator_commit_page_buffer(), eeprom_emulator_read_page(), eeprom_emulator_write_page(), EEPROM_PAGE_SIZE, i, init_success, status, STATUS_OK, test_assert_true, TEST_EEPROM_PAGE, test_page, and verify_page.

Referenced by main().

static void setup_eeprom_buffer_read_write_test ( const struct test_case test)
static

Setup function for EEPROM emulator buffer read/write test.

This function initializes the test buffer and verify buffer with appropriate values.

Parameters
testCurrent test case.

References i, test_buffer, TEST_BUFFER_SIZE, and verify_buffer.

Referenced by main().

static void setup_eeprom_page_read_write_test ( const struct test_case test)
static

Setup function for EEPROM emulator page read/write test.

This function initializes the test_page and verify_page data arrays with appropriate values.

Parameters
testCurrent test case.

References EEPROM_PAGE_SIZE, i, test_page, and verify_page.

Referenced by main().

struct usart_module cdc_uart_module
struct eeprom_emulator_parameters ee_params

Referenced by run_eeprom_init_test().

uint16_t i

Referenced by _eeprom_emulator_check_logical_page(), _extint_disable(), _extint_enable(), _http_client_request(), _http_client_send_wait(), _json_parse(), _rtc_calendar_set_config(), _rww_eeprom_emulator_check_logical_page(), _rww_eeprom_emulator_move_data_to_spare(), _rww_eeprom_emulator_page_checksum(), _sercom_get_sercom_inst_index(), _sercom_set_handler(), _system_extint_init(), _tcc_build_ctrla(), _tcc_build_drvctrl(), _tcc_build_faults(), _tcc_get_inst_index(), _tcc_interrupt_handler(), _usb_device_interrupt_handler(), about_co_routine(), about_task(), ac_disable_events(), ac_enable_events(), ac_get_config_defaults(), AckStatusCallback(), addr_context_lookup_by_number(), addr_context_lookup_by_prefix(), aes_ccm_decrypt(), aes_ccm_encrypt(), aes_ccm_verify(), allocate_pingconn(), APP_CommandsInit(), APP_CommandsPending(), APP_TaskHandler(), appCmdBuffer(), appCmdCheckPendingTable(), appDataInd(), appPrintEdValues(), appUartSendMessage(), arch_ioport_disable_port(), arch_ioport_enable_port(), arp_update(), assign_new_short_addr(), at24mac602_arch_read_eui64(), at24mac602_arch_read_serial128(), at30tse_eeprom_write(), at_ble_init(), at_ble_pair_key_reply(), at_ble_service_define(), autostart_exit(), autostart_start(), aws_iot_shadow_add_desired(), aws_iot_shadow_add_reported(), base64decode(), ble_pair_key_request_handler(), ble_pair_request_handler(), ble_scan_duplication_check(), ble_slave_security_handler(), ble_slave_security_request_handler(), bufchar(), cbcmac_append(), cbcmac_verify(), cgi_search(), check_usart_buffer(), cleanup_adc_callback_mode_test(), cleanup_buffer_polled_write_interrupt_read_test(), convert_phyTransmitPower_to_reg_value(), crc16_data(), crc7(), create_name(), ctr_mic(), ctr_next_ctr_block(), ctr_payload(), dac_chan_write_buffer_wait(), dac_init(), dao_input(), decode_board_info(), decodeLength(), decodePacket(), deliverMessage(), dio_input(), dir_next(), dir_remove(), disk_initialize(), disk_read(), disk_write(), edbg_eui_read_eui64(), encrypt_pldmic(), event_init(), eventhandler(), extint_disable_events(), extint_enable_events(), extint_is_syncing(), extractClientToken(), extractVersionNumber(), f_getfree(), fallback(), find_entry(), find_string_start(), findIndexOfSubscriptionList(), flash_write(), fwcache_register(), gapm_start_connection_cmd_handler(), gattc_read_cmd_handler_multible(), get_batmon_voltage(), get_dag(), get_fileinfo(), get_global_addr(), get_pingconn(), get_sensor_index(), get_token_value(), getNextFreeIndexOfAckWaitList(), getNextFreeIndexOfSubscriptionList(), gfx_mono_draw_char_hugemem(), gfx_mono_draw_char_progmem(), gfx_mono_generic_draw_line(), gfx_mono_generic_put_bitmap(), gfx_mono_spinctrl_spincollection_add_spinner(), gfx_mono_spinctrl_spincollection_process_key(), gfx_mono_spinctrl_spincollection_show(), handle_dao_timer(), handle_input_message(), HandleExpiredResponseCallbacks(), hid_keyboard_app_init(), hid_mouse_app_init(), hid_serv_init(), HMAC_Vector(), http_client_send_request(), http_client_socket_resolve_handler(), http_decodeUrl(), http_getPageName(), http_getValue(), http_searchContentType(), http_tokenizeGetRequest(), httpd_fs_count(), httpd_fs_init(), httpd_fs_open(), httpd_fs_strcmp(), httpd_sprint_ip6(), i2c_slave_read_packet_wait(), i2c_slave_write_packet_wait(), i2s_init(), i2s_serializer_read_buffer_wait(), i2s_serializer_write_buffer_wait(), ifft(), incrementSubscriptionCnt(), init_wifi_scan_service(), initDeltaTokens(), initializeRecords(), input(), input_pt(), io1_board_get_info(), iot_tls_read(), iot_tls_write(), ip64_arp_check_cache(), ip64_arp_create_ethhdr(), ip64_arp_init(), ip64_arp_timer(), ip64_conv(), ip64_init(), IperfSocketClose(), IperfStart(), IperfStop(), IperfUpdate(), is_broadcast_addr(), isJsonKeyMatchingAndUpdateValue(), iso7816_cold_reset(), iso7816_data_block_atr(), iso7816_decode_atr(), iso7816_warm_reset(), isSubscriptionPresent(), isSubStr(), jsmn_parse(), jsmn_parse_string(), KeyExpansion(), ledctrl_receiver(), m2m_memcmp(), mac_sequence_is_duplicate(), mac_sequence_register_seqno(), main(), main_co_routine(), main_count_states(), main_extra_string(), main_init_buffers(), main_reset_states(), main_task(), main_test_memory(), make_addresses(), memb_alloc(), memb_free(), memp_init(), menu_draw(), mmc_cmd8(), mqtt_event(), MQTTClient(), MQTTClientInit(), MQTTSerialize_GetSubscribePacketLength(), MQTTSerialize_GetUnsubscribePacketLength(), MQTTSerialize_suback(), MQTTSerialize_subscribe(), MQTTSerialize_subscribeLength(), MQTTSerialize_unsubscribe(), MQTTSerialize_unsubscribeLength(), MQTTSubscribe(), MQTTUnsubscribe(), nbr_table_allocate(), netstack_aes_decrypt(), netstack_aes_encrypt(), netstack_aes_verify(), nm_usart_protocol_handler(), nm_usart_send_regval(), nmi_inet_addr(), node_id_restore(), numtostring(), nvm_read_buffer(), nvm_update_buffer(), nvm_write_buffer(), NWK_Init(), NWK_LinearizeLqi(), nwkFrameAlloc(), nwkFrameInit(), nwkRxDuplicateRejectionTimerHandler(), nwkRxInit(), nwkRxRejectDuplicate(), packetbuf_attr_clear(), packetbuf_compact(), packetbuf_copyto(), packetbuf_copyto_hdr(), packetqueue_dequeue(), packetqueue_enqueue_packetbuf(), parse_command(), parse_headers(), parse_incoming_packet(), parse_subscribe_response(), parse_url(), pbuf_memcmp(), pbuf_memfind(), pds_nvm_write(), PHY_RandomReq(), PHY_SetIEEEAddr(), platform_create_hw_timer(), platform_interface_callback(), platform_send_sync(), PROCESS_THREAD(), procinit_init(), program_memory(), putPacket(), queuebuf_init(), read(), read_from_efuse(), remove_queued_packet(), rename_to_unique(), reset_i2c(), rf212_prepare(), rf233_init(), rf233_prepare(), rf_generate_random_seed(), rpl_find_of(), rpl_get_any_dag(), rpl_get_instance(), rpl_local_repair(), rtc_calendar_disable_events(), rtc_calendar_enable_events(), rtc_calendar_get_config_defaults(), rtc_calendar_swap_time_mode(), rtc_count_disable_events(), rtc_count_enable_events(), rtc_count_get_config_defaults(), run_adc_callback_mode_test(), run_adc_polled_mode_test(), run_buffer_polled_write_interrupt_read_test(), run_eeprom_buffer_read_write_test(), run_eeprom_page_read_write_test(), run_i2c_full_speed_test(), run_i2c_master_transfer_test(), run_i2s_callback_mode_test(), run_i2s_polled_mode_test(), run_nvm_read_and_write_test(), run_nvm_update_test(), run_transceive_buffer_test(), rw_test(), sam_ba_monitor_run(), sam_ba_putdata_term(), send_packet(), sensors_find(), serial_bridge_frame_get_nm_command(), serial_bridge_process_frame(), set_global_address(), set_link_addr(), setup_adc_callback_mode_test(), setup_board(), setup_eeprom_buffer_read_write_test(), setup_eeprom_page_read_write_test(), shadow_delta_callback(), show_extension_boards_information(), simple_rpl_global_address(), simple_rpl_init_dag_immediately(), sleepmgr_init(), slip_poll_handler(), slip_send(), slip_write(), slipdev_send(), spi_flash_erase(), spi_flash_pp(), spi_init(), spi_read_buffer_wait(), spi_transceive_buffer_wait(), spi_write_buffer_wait(), stb_ccm_secure(), system_pinmux_group_set_config(), tal_dump_registers(), tal_generate_rand_seed(), tal_init(), tal_pib_set(), tc_callback_to_change_duty_cycle(), tc_disable_events(), tc_enable_events(), tcc_callback_to_change_duty_cycle(), tcc_clear_status(), tcc_get_status(), tcc_init(), tcpip_uipcall(), test_suite_run(), tfa_continuous_tx_start(), tfa_get_batmon_voltage(), trans_service_init(), transmit_frame(), UartBytesReceived(), udc_req_std_dev_get_str_desc(), udi_hid_kbd_down(), udi_hid_kbd_up(), udi_msc_spc_inquiry(), uhc_connection_tree(), uhc_dev_get_string(), uhc_dev_reset(), uhc_enumeration_step14(), uhc_enumeration_step15(), uhc_enumeration_step18_lpm(), uhc_notify_sof(), uhi_cdc_free_device(), uhi_cdc_install(), uhi_vendor_install(), uip_arp_init(), uip_arp_out(), uip_arp_timer(), uip_arp_update(), uip_debug_ipaddr_print(), uip_debug_lladdr_print(), uip_neighbor_add(), uip_neighbor_init(), uip_neighbor_periodic(), uiplib_ip4addrconv(), usart_init(), usart_putdata(), usart_read_buffer_wait(), usart_write_buffer_wait(), usb_init(), usr_mcps_data_ind(), usr_range_test_beacon_rsp(), usr_range_test_beacon_tx(), usr_range_test_marker_ind(), wifiscan_scanlist_receive(), WINC1500_read(), WINC1500_write(), write_all_tal_pib_to_trx(), write_to_efuse(), and X509Cert_Dump().