diff --git a/UNITTESTS/features/cellular/framework/AT/at_cellulardevice/at_cellulardevicetest.cpp b/UNITTESTS/features/cellular/framework/AT/at_cellulardevice/at_cellulardevicetest.cpp index 7ab8f742f3..0722fc501f 100644 --- a/UNITTESTS/features/cellular/framework/AT/at_cellulardevice/at_cellulardevicetest.cpp +++ b/UNITTESTS/features/cellular/framework/AT/at_cellulardevice/at_cellulardevicetest.cpp @@ -26,10 +26,12 @@ using namespace events; class TestAT_CellularDevice : public testing::Test { protected: - void SetUp() { + void SetUp() + { } - void TearDown() { + void TearDown() + { } }; diff --git a/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp b/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp index d555d55a18..5e5c4b7d1b 100644 --- a/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp +++ b/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp @@ -459,7 +459,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_registration_params) EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_registration_params(CellularNetwork::C_EREG, reg_params)); EXPECT_TRUE(reg_params._cell_id == 305463233); EXPECT_TRUE(reg_params._active_time == 240); - EXPECT_TRUE(reg_params._periodic_tau == 70 * 60 *60); + EXPECT_TRUE(reg_params._periodic_tau == 70 * 60 * 60); ATHandler_stub::read_string_index = kRead_string_table_size; ATHandler_stub::read_string_value = NULL; ATHandler_stub::ssize_value = 0; @@ -469,7 +469,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_registration_params) EXPECT_TRUE(reg_params_check._act == CellularNetwork::RAT_EGPRS); EXPECT_TRUE(reg_params_check._cell_id == 305463233); EXPECT_TRUE(reg_params_check._active_time == 240); - EXPECT_TRUE(reg_params_check._periodic_tau == 70 * 60 *60); + EXPECT_TRUE(reg_params_check._periodic_tau == 70 * 60 * 60); reg_params._status = CellularNetwork::NotRegistered; reg_params._act = CellularNetwork::RAT_GSM; diff --git a/UNITTESTS/features/cellular/framework/common/util/utiltest.cpp b/UNITTESTS/features/cellular/framework/common/util/utiltest.cpp index b4729d56bb..09f87c87e1 100644 --- a/UNITTESTS/features/cellular/framework/common/util/utiltest.cpp +++ b/UNITTESTS/features/cellular/framework/common/util/utiltest.cpp @@ -37,7 +37,7 @@ protected: TEST_F(Testutil, test_util_binary_str_to_uint) { - char binary_str[]="011001011101101000"; + char binary_str[] = "011001011101101000"; uint32_t value = binary_str_to_uint(binary_str, strlen(binary_str) + 1); EXPECT_TRUE(value == 104296); value = binary_str_to_uint(binary_str, strlen(binary_str)); @@ -210,7 +210,7 @@ TEST_F(Testutil, get_dynamic_ip_port) TEST_F(Testutil, int_to_hex_str) { char buf[2]; - int_to_hex_str(100, (char*)buf); + int_to_hex_str(100, (char *)buf); EXPECT_TRUE(buf[0] == '6'); EXPECT_TRUE(buf[1] == '4'); diff --git a/UNITTESTS/features/lorawan/loramac/Test_LoRaMac.cpp b/UNITTESTS/features/lorawan/loramac/Test_LoRaMac.cpp index 95512e2d05..ef4fa72f06 100644 --- a/UNITTESTS/features/lorawan/loramac/Test_LoRaMac.cpp +++ b/UNITTESTS/features/lorawan/loramac/Test_LoRaMac.cpp @@ -25,12 +25,11 @@ using namespace events; -class my_phy : public LoRaPHY -{ +class my_phy : public LoRaPHY { public: - my_phy(){}; + my_phy() {}; - virtual ~my_phy(){}; + virtual ~my_phy() {}; }; class Test_LoRaMac : public testing::Test { diff --git a/UNITTESTS/features/lorawan/loramacchannelplan/Test_LoRaMacChannelPlan.cpp b/UNITTESTS/features/lorawan/loramacchannelplan/Test_LoRaMacChannelPlan.cpp index 678fb868a4..9858c94792 100644 --- a/UNITTESTS/features/lorawan/loramacchannelplan/Test_LoRaMacChannelPlan.cpp +++ b/UNITTESTS/features/lorawan/loramacchannelplan/Test_LoRaMacChannelPlan.cpp @@ -20,12 +20,11 @@ #include "LoRaPHY_stub.h" #include "LoRaPHY.h" -class my_LoRaPHY : public LoRaPHY -{ +class my_LoRaPHY : public LoRaPHY { public: - my_LoRaPHY(){}; + my_LoRaPHY() {}; - virtual ~my_LoRaPHY(){}; + virtual ~my_LoRaPHY() {}; }; diff --git a/UNITTESTS/features/lorawan/loramaccommand/Test_LoRaMacCommand.cpp b/UNITTESTS/features/lorawan/loramaccommand/Test_LoRaMacCommand.cpp index 3417a5eba3..de0d39b54a 100644 --- a/UNITTESTS/features/lorawan/loramaccommand/Test_LoRaMacCommand.cpp +++ b/UNITTESTS/features/lorawan/loramaccommand/Test_LoRaMacCommand.cpp @@ -20,12 +20,11 @@ #include "LoRaPHY_stub.h" -class my_LoRaPHY : public LoRaPHY -{ +class my_LoRaPHY : public LoRaPHY { public: - my_LoRaPHY(){}; + my_LoRaPHY() {}; - virtual ~my_LoRaPHY(){}; + virtual ~my_LoRaPHY() {}; }; uint8_t my_cb() @@ -153,7 +152,7 @@ TEST_F(Test_LoRaMacCommand, copy_repeat_commands_to_buffer) TEST_F(Test_LoRaMacCommand, get_repeat_commands_length) { - EXPECT_TRUE(object->get_repeat_commands_length() == 0 ); + EXPECT_TRUE(object->get_repeat_commands_length() == 0); } TEST_F(Test_LoRaMacCommand, clear_sticky_mac_cmd) @@ -222,7 +221,7 @@ TEST_F(Test_LoRaMacCommand, process_mac_commands) //Overflow add_link_adr_ans function here object->clear_command_buffer(); buf[0] = 3; - for (int i=0; i < 64; i++) { + for (int i = 0; i < 64; i++) { EXPECT_TRUE(object->process_mac_commands(buf, 0, 5, 0, mlme, params, phy) == LORAWAN_STATUS_OK); } EXPECT_TRUE(object->process_mac_commands(buf, 0, 5, 0, mlme, params, phy) == LORAWAN_STATUS_LENGTH_ERROR); @@ -234,7 +233,7 @@ TEST_F(Test_LoRaMacCommand, process_mac_commands) //Overflow add_duty_cycle_ans() object->clear_command_buffer(); - for (int i=0; i < 128; i++) { + for (int i = 0; i < 128; i++) { EXPECT_TRUE(object->process_mac_commands(buf, 0, 1, 0, mlme, params, phy) == LORAWAN_STATUS_OK); } EXPECT_TRUE(object->process_mac_commands(buf, 0, 1, 0, mlme, params, phy) == LORAWAN_STATUS_LENGTH_ERROR); @@ -251,7 +250,7 @@ TEST_F(Test_LoRaMacCommand, process_mac_commands) //Overflow add_rx_param_setup_ans object->clear_command_buffer(); LoRaPHY_stub::uint8_value = 7; - for (int i=0; i < 64; i++) { + for (int i = 0; i < 64; i++) { EXPECT_TRUE(object->process_mac_commands(buf, 0, 5, 0, mlme, params, phy) == LORAWAN_STATUS_OK); } EXPECT_TRUE(object->process_mac_commands(buf, 0, 5, 0, mlme, params, phy) == LORAWAN_STATUS_LENGTH_ERROR); @@ -263,7 +262,7 @@ TEST_F(Test_LoRaMacCommand, process_mac_commands) //overflow add_dev_status_ans object->clear_command_buffer(); - for (int i=0; i < 42; i++) { + for (int i = 0; i < 42; i++) { EXPECT_TRUE(object->process_mac_commands(buf, 0, 1, 0, mlme, params, phy) == LORAWAN_STATUS_OK); } EXPECT_TRUE(object->process_mac_commands(buf, 0, 1, 0, mlme, params, phy) == LORAWAN_STATUS_LENGTH_ERROR); @@ -280,7 +279,7 @@ TEST_F(Test_LoRaMacCommand, process_mac_commands) //Overflow add_new_channel_ans object->clear_command_buffer(); LoRaPHY_stub::uint8_value = 7; - for (int i=0; i < 64; i++) { + for (int i = 0; i < 64; i++) { EXPECT_TRUE(object->process_mac_commands(buf, 0, 6, 0, mlme, params, phy) == LORAWAN_STATUS_OK); } EXPECT_TRUE(object->process_mac_commands(buf, 0, 6, 0, mlme, params, phy) == LORAWAN_STATUS_LENGTH_ERROR); @@ -293,7 +292,7 @@ TEST_F(Test_LoRaMacCommand, process_mac_commands) //Overflow add_rx_timing_setup_ans object->clear_command_buffer(); LoRaPHY_stub::uint8_value = 7; - for (int i=0; i < 128; i++) { + for (int i = 0; i < 128; i++) { EXPECT_TRUE(object->process_mac_commands(buf, 0, 2, 0, mlme, params, phy) == LORAWAN_STATUS_OK); } EXPECT_TRUE(object->process_mac_commands(buf, 0, 2, 0, mlme, params, phy) == LORAWAN_STATUS_LENGTH_ERROR); @@ -308,7 +307,7 @@ TEST_F(Test_LoRaMacCommand, process_mac_commands) LoRaPHY_stub::bool_table[0] = true; object->clear_command_buffer(); LoRaPHY_stub::uint8_value = 7; - for (int i=0; i < 128; i++) { + for (int i = 0; i < 128; i++) { EXPECT_TRUE(object->process_mac_commands(buf, 0, 2, 0, mlme, params, phy) == LORAWAN_STATUS_OK); LoRaPHY_stub::bool_counter = 0; } @@ -326,7 +325,7 @@ TEST_F(Test_LoRaMacCommand, process_mac_commands) LoRaPHY_stub::bool_table[0] = true; object->clear_command_buffer(); LoRaPHY_stub::uint8_value = 7; - for (int i=0; i < 64; i++) { + for (int i = 0; i < 64; i++) { EXPECT_TRUE(object->process_mac_commands(buf, 0, 4, 0, mlme, params, phy) == LORAWAN_STATUS_OK); LoRaPHY_stub::bool_counter = 0; } diff --git a/UNITTESTS/features/lorawan/loraphy/Test_LoRaPHY.cpp b/UNITTESTS/features/lorawan/loraphy/Test_LoRaPHY.cpp index 6ae74b1bb4..fac461fb2c 100644 --- a/UNITTESTS/features/lorawan/loraphy/Test_LoRaPHY.cpp +++ b/UNITTESTS/features/lorawan/loraphy/Test_LoRaPHY.cpp @@ -20,74 +20,85 @@ #include "LoRaWANTimer_stub.h" -class my_LoRaPHY : public LoRaPHY -{ +class my_LoRaPHY : public LoRaPHY { public: - my_LoRaPHY(){phy_params.adr_ack_delay = 1;} + my_LoRaPHY() + { + phy_params.adr_ack_delay = 1; + } - virtual ~my_LoRaPHY(){} + virtual ~my_LoRaPHY() {} - loraphy_params_t &get_phy_params() { + loraphy_params_t &get_phy_params() + { return phy_params; } }; -class my_radio : public LoRaRadio -{ +class my_radio : public LoRaRadio { public: - virtual void init_radio(radio_events_t *events){}; + virtual void init_radio(radio_events_t *events) {}; - virtual void radio_reset(){}; + virtual void radio_reset() {}; - virtual void sleep(void){}; + virtual void sleep(void) {}; - virtual void standby(void){}; + virtual void standby(void) {}; - virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, - uint32_t datarate, uint8_t coderate, - uint32_t bandwidth_afc, uint16_t preamble_len, - uint16_t symb_timeout, bool fix_len, - uint8_t payload_len, - bool crc_on, bool freq_hop_on, uint8_t hop_period, - bool iq_inverted, bool rx_continuous){}; + virtual void set_rx_config(radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous) {}; virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, - uint32_t bandwidth, uint32_t datarate, - uint8_t coderate, uint16_t preamble_len, - bool fix_len, bool crc_on, bool freq_hop_on, - uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout) {}; - virtual void send(uint8_t *buffer, uint8_t size){}; + virtual void send(uint8_t *buffer, uint8_t size) {}; - virtual void receive(void){}; + virtual void receive(void) {}; - virtual void set_channel(uint32_t freq){}; + virtual void set_channel(uint32_t freq) {}; - virtual uint32_t random(void){}; + virtual uint32_t random(void) {}; - virtual uint8_t get_status(void){return uint8_value;}; + virtual uint8_t get_status(void) + { + return uint8_value; + }; - virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {}; - virtual void set_public_network(bool enable){}; + virtual void set_public_network(bool enable) {}; - virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len) {}; virtual bool perform_carrier_sense(radio_modems_t modem, - uint32_t freq, - int16_t rssi_threshold, - uint32_t max_carrier_sense_time){ return bool_value;}; + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time) + { + return bool_value; + }; - virtual void start_cad(void){}; + virtual void start_cad(void) {}; - virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + virtual bool check_rf_frequency(uint32_t frequency) + { + return bool_value; + }; - virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {}; - virtual void lock(void){}; + virtual void lock(void) {}; - virtual void unlock(void){}; + virtual void unlock(void) {}; bool bool_value; uint8_t uint8_value; @@ -410,7 +421,7 @@ TEST_F(Test_LoRaPHY, tx_config) object->get_phy_params().bands.table = &b; channel_params_t pp; memset(&pp, 0, sizeof(channel_params_t)); - pp.band=0; + pp.band = 0; object->get_phy_params().channels.channel_list = &pp; uint32_t list[1]; list[0] = 125000; @@ -422,7 +433,7 @@ TEST_F(Test_LoRaPHY, tx_config) object->set_radio_instance(radio); tx_config_params_t p; memset(&p, 0, sizeof(tx_config_params_t)); - p.channel=0; + p.channel = 0; int8_t i = 20; lorawan_time_t t = 36; object->tx_config(&p, &i, &t); @@ -688,7 +699,7 @@ TEST_F(Test_LoRaPHY, add_channel) TEST_F(Test_LoRaPHY, remove_channel) { channel_params_t pp; - pp.band=0; + pp.band = 0; object->get_phy_params().channels.channel_list = &pp; uint16_t list[16]; list[0] = 1; @@ -710,7 +721,7 @@ TEST_F(Test_LoRaPHY, remove_channel) TEST_F(Test_LoRaPHY, set_tx_cont_mode) { channel_params_t pp; - pp.band=0; + pp.band = 0; object->get_phy_params().channels.channel_list = &pp; band_t b; b.max_tx_pwr = 10; @@ -791,7 +802,7 @@ TEST_F(Test_LoRaPHY, get_default_tx_power) TEST_F(Test_LoRaPHY, get_max_payload) { - uint8_t list=8; + uint8_t list = 8; object->get_phy_params().payloads.table = &list; object->get_phy_params().payloads_with_repeater.table = &list; EXPECT_TRUE(8 == object->get_max_payload(0)); diff --git a/UNITTESTS/features/lorawan/loraphyas923/Test_LoRaPHYAS923.cpp b/UNITTESTS/features/lorawan/loraphyas923/Test_LoRaPHYAS923.cpp index 98a361810d..912c35a12f 100644 --- a/UNITTESTS/features/lorawan/loraphyas923/Test_LoRaPHYAS923.cpp +++ b/UNITTESTS/features/lorawan/loraphyas923/Test_LoRaPHYAS923.cpp @@ -20,62 +20,70 @@ #include "LoRaPHY_stub.h" -class my_radio : public LoRaRadio -{ +class my_radio : public LoRaRadio { public: - virtual void init_radio(radio_events_t *events){}; + virtual void init_radio(radio_events_t *events) {}; - virtual void radio_reset(){}; + virtual void radio_reset() {}; - virtual void sleep(void){}; + virtual void sleep(void) {}; - virtual void standby(void){}; + virtual void standby(void) {}; - virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, - uint32_t datarate, uint8_t coderate, - uint32_t bandwidth_afc, uint16_t preamble_len, - uint16_t symb_timeout, bool fix_len, - uint8_t payload_len, - bool crc_on, bool freq_hop_on, uint8_t hop_period, - bool iq_inverted, bool rx_continuous){}; + virtual void set_rx_config(radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous) {}; virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, - uint32_t bandwidth, uint32_t datarate, - uint8_t coderate, uint16_t preamble_len, - bool fix_len, bool crc_on, bool freq_hop_on, - uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout) {}; - virtual void send(uint8_t *buffer, uint8_t size){}; + virtual void send(uint8_t *buffer, uint8_t size) {}; - virtual void receive(void){}; + virtual void receive(void) {}; - virtual void set_channel(uint32_t freq){}; + virtual void set_channel(uint32_t freq) {}; - virtual uint32_t random(void){}; + virtual uint32_t random(void) {}; - virtual uint8_t get_status(void){return uint8_value;}; + virtual uint8_t get_status(void) + { + return uint8_value; + }; - virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {}; - virtual void set_public_network(bool enable){}; + virtual void set_public_network(bool enable) {}; - virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len) {}; virtual bool perform_carrier_sense(radio_modems_t modem, - uint32_t freq, - int16_t rssi_threshold, - uint32_t max_carrier_sense_time){ return bool_value;}; + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time) + { + return bool_value; + }; - virtual void start_cad(void){}; + virtual void start_cad(void) {}; - virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + virtual bool check_rf_frequency(uint32_t frequency) + { + return bool_value; + }; - virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {}; - virtual void lock(void){}; + virtual void lock(void) {}; - virtual void unlock(void){}; + virtual void unlock(void) {}; bool bool_value; uint8_t uint8_value; @@ -135,8 +143,8 @@ TEST_F(Test_LoRaPHYAS923, set_next_channel) TEST_F(Test_LoRaPHYAS923, apply_DR_offset) { //0, 1, 2, 3, 4, 5, -1, -2 - for (int i=0; i < 8; i++) { - uint8_t val = i>5?5:2; + for (int i = 0; i < 8; i++) { + uint8_t val = i > 5 ? 5 : 2; EXPECT_TRUE(object->apply_DR_offset(0, i)); } } diff --git a/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp b/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp index b877f5077e..3b8eee4c14 100644 --- a/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp +++ b/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp @@ -20,62 +20,70 @@ #include "LoRaPHY_stub.h" -class my_radio : public LoRaRadio -{ +class my_radio : public LoRaRadio { public: - virtual void init_radio(radio_events_t *events){}; + virtual void init_radio(radio_events_t *events) {}; - virtual void radio_reset(){}; + virtual void radio_reset() {}; - virtual void sleep(void){}; + virtual void sleep(void) {}; - virtual void standby(void){}; + virtual void standby(void) {}; - virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, - uint32_t datarate, uint8_t coderate, - uint32_t bandwidth_afc, uint16_t preamble_len, - uint16_t symb_timeout, bool fix_len, - uint8_t payload_len, - bool crc_on, bool freq_hop_on, uint8_t hop_period, - bool iq_inverted, bool rx_continuous){}; + virtual void set_rx_config(radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous) {}; virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, - uint32_t bandwidth, uint32_t datarate, - uint8_t coderate, uint16_t preamble_len, - bool fix_len, bool crc_on, bool freq_hop_on, - uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout) {}; - virtual void send(uint8_t *buffer, uint8_t size){}; + virtual void send(uint8_t *buffer, uint8_t size) {}; - virtual void receive(void){}; + virtual void receive(void) {}; - virtual void set_channel(uint32_t freq){}; + virtual void set_channel(uint32_t freq) {}; - virtual uint32_t random(void){}; + virtual uint32_t random(void) {}; - virtual uint8_t get_status(void){return uint8_value;}; + virtual uint8_t get_status(void) + { + return uint8_value; + }; - virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {}; - virtual void set_public_network(bool enable){}; + virtual void set_public_network(bool enable) {}; - virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len) {}; virtual bool perform_carrier_sense(radio_modems_t modem, - uint32_t freq, - int16_t rssi_threshold, - uint32_t max_carrier_sense_time){ return bool_value;}; + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time) + { + return bool_value; + }; - virtual void start_cad(void){}; + virtual void start_cad(void) {}; - virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + virtual bool check_rf_frequency(uint32_t frequency) + { + return bool_value; + }; - virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {}; - virtual void lock(void){}; + virtual void lock(void) {}; - virtual void unlock(void){}; + virtual void unlock(void) {}; bool bool_value; uint8_t uint8_value; @@ -224,11 +232,15 @@ TEST_F(Test_LoRaPHYAU915, apply_DR_offset) // { DR_13, DR_13, DR_12, DR_11, DR_10, DR_9 }, // DR_6 for (int i = 0; i < 7; i++) { - for (int j=0; j < 6; j++ ) { + for (int j = 0; j < 6; j++) { uint8_t val = 8 + i; val -= j; - if (val > 13) val = 13; - if (val < 8) val = 8; + if (val > 13) { + val = 13; + } + if (val < 8) { + val = 8; + } EXPECT_TRUE(val == object->apply_DR_offset(i, j)); } } diff --git a/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp b/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp index 570a4b3eaa..d54b2645d6 100644 --- a/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp +++ b/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp @@ -20,62 +20,70 @@ #include "LoRaPHY_stub.h" -class my_radio : public LoRaRadio -{ +class my_radio : public LoRaRadio { public: - virtual void init_radio(radio_events_t *events){}; + virtual void init_radio(radio_events_t *events) {}; - virtual void radio_reset(){}; + virtual void radio_reset() {}; - virtual void sleep(void){}; + virtual void sleep(void) {}; - virtual void standby(void){}; + virtual void standby(void) {}; - virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, - uint32_t datarate, uint8_t coderate, - uint32_t bandwidth_afc, uint16_t preamble_len, - uint16_t symb_timeout, bool fix_len, - uint8_t payload_len, - bool crc_on, bool freq_hop_on, uint8_t hop_period, - bool iq_inverted, bool rx_continuous){}; + virtual void set_rx_config(radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous) {}; virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, - uint32_t bandwidth, uint32_t datarate, - uint8_t coderate, uint16_t preamble_len, - bool fix_len, bool crc_on, bool freq_hop_on, - uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout) {}; - virtual void send(uint8_t *buffer, uint8_t size){}; + virtual void send(uint8_t *buffer, uint8_t size) {}; - virtual void receive(void){}; + virtual void receive(void) {}; - virtual void set_channel(uint32_t freq){}; + virtual void set_channel(uint32_t freq) {}; - virtual uint32_t random(void){}; + virtual uint32_t random(void) {}; - virtual uint8_t get_status(void){return uint8_value;}; + virtual uint8_t get_status(void) + { + return uint8_value; + }; - virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {}; - virtual void set_public_network(bool enable){}; + virtual void set_public_network(bool enable) {}; - virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len) {}; virtual bool perform_carrier_sense(radio_modems_t modem, - uint32_t freq, - int16_t rssi_threshold, - uint32_t max_carrier_sense_time){ return bool_value;}; + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time) + { + return bool_value; + }; - virtual void start_cad(void){}; + virtual void start_cad(void) {}; - virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + virtual bool check_rf_frequency(uint32_t frequency) + { + return bool_value; + }; - virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {}; - virtual void lock(void){}; + virtual void lock(void) {}; - virtual void unlock(void){}; + virtual void unlock(void) {}; bool bool_value; uint8_t uint8_value; diff --git a/UNITTESTS/features/lorawan/loraphykr920/Test_LoRaPHYKR920.cpp b/UNITTESTS/features/lorawan/loraphykr920/Test_LoRaPHYKR920.cpp index 86561a8ad7..55c992d148 100644 --- a/UNITTESTS/features/lorawan/loraphykr920/Test_LoRaPHYKR920.cpp +++ b/UNITTESTS/features/lorawan/loraphykr920/Test_LoRaPHYKR920.cpp @@ -20,62 +20,67 @@ #include "LoRaPHY_stub.h" #include "LoRaRadio.h" -class my_radio : public LoRaRadio -{ +class my_radio : public LoRaRadio { public: - virtual void init_radio(radio_events_t *events){}; + virtual void init_radio(radio_events_t *events) {}; - virtual void radio_reset(){}; + virtual void radio_reset() {}; - virtual void sleep(void){}; + virtual void sleep(void) {}; - virtual void standby(void){}; + virtual void standby(void) {}; - virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, - uint32_t datarate, uint8_t coderate, - uint32_t bandwidth_afc, uint16_t preamble_len, - uint16_t symb_timeout, bool fix_len, - uint8_t payload_len, - bool crc_on, bool freq_hop_on, uint8_t hop_period, - bool iq_inverted, bool rx_continuous){}; + virtual void set_rx_config(radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous) {}; virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, - uint32_t bandwidth, uint32_t datarate, - uint8_t coderate, uint16_t preamble_len, - bool fix_len, bool crc_on, bool freq_hop_on, - uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout) {}; - virtual void send(uint8_t *buffer, uint8_t size){}; + virtual void send(uint8_t *buffer, uint8_t size) {}; - virtual void receive(void){}; + virtual void receive(void) {}; - virtual void set_channel(uint32_t freq){}; + virtual void set_channel(uint32_t freq) {}; - virtual uint32_t random(void){}; + virtual uint32_t random(void) {}; - virtual uint8_t get_status(void){}; + virtual uint8_t get_status(void) {}; - virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {}; - virtual void set_public_network(bool enable){}; + virtual void set_public_network(bool enable) {}; - virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len) {}; virtual bool perform_carrier_sense(radio_modems_t modem, - uint32_t freq, - int16_t rssi_threshold, - uint32_t max_carrier_sense_time){ return bool_value;}; + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time) + { + return bool_value; + }; - virtual void start_cad(void){}; + virtual void start_cad(void) {}; - virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + virtual bool check_rf_frequency(uint32_t frequency) + { + return bool_value; + }; - virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {}; - virtual void lock(void){}; + virtual void lock(void) {}; - virtual void unlock(void){}; + virtual void unlock(void) {}; bool bool_value; }; diff --git a/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp b/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp index 0e5e843281..94d6265259 100644 --- a/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp +++ b/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp @@ -19,62 +19,70 @@ #include "LoRaPHYUS915.h" #include "LoRaPHY_stub.h" -class my_radio : public LoRaRadio -{ +class my_radio : public LoRaRadio { public: - virtual void init_radio(radio_events_t *events){}; + virtual void init_radio(radio_events_t *events) {}; - virtual void radio_reset(){}; + virtual void radio_reset() {}; - virtual void sleep(void){}; + virtual void sleep(void) {}; - virtual void standby(void){}; + virtual void standby(void) {}; - virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, - uint32_t datarate, uint8_t coderate, - uint32_t bandwidth_afc, uint16_t preamble_len, - uint16_t symb_timeout, bool fix_len, - uint8_t payload_len, - bool crc_on, bool freq_hop_on, uint8_t hop_period, - bool iq_inverted, bool rx_continuous){}; + virtual void set_rx_config(radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous) {}; virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, - uint32_t bandwidth, uint32_t datarate, - uint8_t coderate, uint16_t preamble_len, - bool fix_len, bool crc_on, bool freq_hop_on, - uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout) {}; - virtual void send(uint8_t *buffer, uint8_t size){}; + virtual void send(uint8_t *buffer, uint8_t size) {}; - virtual void receive(void){}; + virtual void receive(void) {}; - virtual void set_channel(uint32_t freq){}; + virtual void set_channel(uint32_t freq) {}; - virtual uint32_t random(void){}; + virtual uint32_t random(void) {}; - virtual uint8_t get_status(void){return uint8_value;}; + virtual uint8_t get_status(void) + { + return uint8_value; + }; - virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {}; - virtual void set_public_network(bool enable){}; + virtual void set_public_network(bool enable) {}; - virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len) {}; virtual bool perform_carrier_sense(radio_modems_t modem, - uint32_t freq, - int16_t rssi_threshold, - uint32_t max_carrier_sense_time){ return bool_value;}; + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time) + { + return bool_value; + }; - virtual void start_cad(void){}; + virtual void start_cad(void) {}; - virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + virtual bool check_rf_frequency(uint32_t frequency) + { + return bool_value; + }; - virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {}; - virtual void lock(void){}; + virtual void lock(void) {}; - virtual void unlock(void){}; + virtual void unlock(void) {}; bool bool_value; uint8_t uint8_value; @@ -221,11 +229,15 @@ TEST_F(Test_LoRaPHYUS915, apply_DR_offset) //13, 13, 12, 11 for (int i = 0; i < 5; i++) { - for (int j=0; j < 4; j++ ) { + for (int j = 0; j < 4; j++) { uint8_t val = 10 + i; val -= j; - if (val > 13) val = 13; - if (val < 8) val = 8; + if (val > 13) { + val = 13; + } + if (val < 8) { + val = 8; + } EXPECT_TRUE(val == object->apply_DR_offset(i, j)); } } diff --git a/UNITTESTS/features/lorawan/lorawaninterface/Test_LoRaWANInterface.cpp b/UNITTESTS/features/lorawan/lorawaninterface/Test_LoRaWANInterface.cpp index 2a6e0525f5..d2182b482c 100644 --- a/UNITTESTS/features/lorawan/lorawaninterface/Test_LoRaWANInterface.cpp +++ b/UNITTESTS/features/lorawan/lorawaninterface/Test_LoRaWANInterface.cpp @@ -18,70 +18,68 @@ #include "gtest/gtest.h" #include "LoRaWANInterface.h" -class my_radio : public LoRaRadio -{ +class my_radio : public LoRaRadio { public: - virtual void init_radio(radio_events_t *events){}; + virtual void init_radio(radio_events_t *events) {}; - virtual void radio_reset(){}; + virtual void radio_reset() {}; - virtual void sleep(void){}; + virtual void sleep(void) {}; - virtual void standby(void){}; + virtual void standby(void) {}; - virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, - uint32_t datarate, uint8_t coderate, - uint32_t bandwidth_afc, uint16_t preamble_len, - uint16_t symb_timeout, bool fix_len, - uint8_t payload_len, - bool crc_on, bool freq_hop_on, uint8_t hop_period, - bool iq_inverted, bool rx_continuous){}; + virtual void set_rx_config(radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous) {}; virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, - uint32_t bandwidth, uint32_t datarate, - uint8_t coderate, uint16_t preamble_len, - bool fix_len, bool crc_on, bool freq_hop_on, - uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout) {}; - virtual void send(uint8_t *buffer, uint8_t size){}; + virtual void send(uint8_t *buffer, uint8_t size) {}; - virtual void receive(void){}; + virtual void receive(void) {}; - virtual void set_channel(uint32_t freq){}; + virtual void set_channel(uint32_t freq) {}; - virtual uint32_t random(void){}; + virtual uint32_t random(void) {}; - virtual uint8_t get_status(void){}; + virtual uint8_t get_status(void) {}; - virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {}; - virtual void set_public_network(bool enable){}; + virtual void set_public_network(bool enable) {}; - virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len) {}; virtual bool perform_carrier_sense(radio_modems_t modem, - uint32_t freq, - int16_t rssi_threshold, - uint32_t max_carrier_sense_time){}; + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time) {}; - virtual void start_cad(void){}; + virtual void start_cad(void) {}; - virtual bool check_rf_frequency(uint32_t frequency){}; + virtual bool check_rf_frequency(uint32_t frequency) {}; - virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {}; - virtual void lock(void){}; + virtual void lock(void) {}; - virtual void unlock(void){}; + virtual void unlock(void) {}; }; -class my_LoRaPHY : public LoRaPHY -{ +class my_LoRaPHY : public LoRaPHY { public: - my_LoRaPHY(){}; + my_LoRaPHY() {}; - virtual ~my_LoRaPHY(){}; + virtual ~my_LoRaPHY() {}; }; class Test_LoRaWANInterface : public testing::Test { diff --git a/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp b/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp index bed46b486e..58e11475bb 100644 --- a/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp +++ b/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp @@ -28,12 +28,11 @@ static uint8_t batt_level = 0; using namespace events; -class my_LoRaPHY : public LoRaPHY -{ +class my_LoRaPHY : public LoRaPHY { public: - my_LoRaPHY(){}; + my_LoRaPHY() {}; - virtual ~my_LoRaPHY(){}; + virtual ~my_LoRaPHY() {}; }; uint8_t my_cb() @@ -41,63 +40,74 @@ uint8_t my_cb() return 1; } -class my_radio : public LoRaRadio -{ +class my_radio : public LoRaRadio { public: radio_events_t *_ev; - virtual void init_radio(radio_events_t *events){_ev = events;}; + virtual void init_radio(radio_events_t *events) + { + _ev = events; + }; - virtual void radio_reset(){}; + virtual void radio_reset() {}; - virtual void sleep(void){}; + virtual void sleep(void) {}; - virtual void standby(void){}; + virtual void standby(void) {}; - virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, - uint32_t datarate, uint8_t coderate, - uint32_t bandwidth_afc, uint16_t preamble_len, - uint16_t symb_timeout, bool fix_len, - uint8_t payload_len, - bool crc_on, bool freq_hop_on, uint8_t hop_period, - bool iq_inverted, bool rx_continuous){}; + virtual void set_rx_config(radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous) {}; virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, - uint32_t bandwidth, uint32_t datarate, - uint8_t coderate, uint16_t preamble_len, - bool fix_len, bool crc_on, bool freq_hop_on, - uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout) {}; - virtual void send(uint8_t *buffer, uint8_t size){}; + virtual void send(uint8_t *buffer, uint8_t size) {}; - virtual void receive(void){}; + virtual void receive(void) {}; - virtual void set_channel(uint32_t freq){}; + virtual void set_channel(uint32_t freq) {}; - virtual uint32_t random(void){}; + virtual uint32_t random(void) {}; - virtual uint8_t get_status(void){return uint8_value;}; + virtual uint8_t get_status(void) + { + return uint8_value; + }; - virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {}; - virtual void set_public_network(bool enable){}; + virtual void set_public_network(bool enable) {}; - virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len) {}; virtual bool perform_carrier_sense(radio_modems_t modem, - uint32_t freq, - int16_t rssi_threshold, - uint32_t max_carrier_sense_time){ return bool_value;}; + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time) + { + return bool_value; + }; - virtual void start_cad(void){}; + virtual void start_cad(void) {}; - virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + virtual bool check_rf_frequency(uint32_t frequency) + { + return bool_value; + }; - virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {}; - virtual void lock(void){}; + virtual void lock(void) {}; - virtual void unlock(void){}; + virtual void unlock(void) {}; bool bool_value; uint8_t uint8_value; @@ -442,7 +452,7 @@ TEST_F(Test_LoRaWANStack, handle_rx) LoRaMac_stub::mlme_ind_ptr = &mlme_ind; uint8_t ind_buf[150]; - for (int i= 0; i < 110; i++) { + for (int i = 0; i < 110; i++) { ind_buf[i] = i; } ind.buffer = ind_buf; @@ -497,7 +507,7 @@ TEST_F(Test_LoRaWANStack, handle_rx) EXPECT_EQ(100, data[0]); //read can fit the buffer - for (int i= 0; i < 110; i++) { + for (int i = 0; i < 110; i++) { ind_buf[i] = i; } ind.buffer = ind_buf; @@ -847,7 +857,7 @@ TEST_F(Test_LoRaWANStack, process_reception) LoRaMac_stub::mlme_ind_ptr = &mlme_ind; uint8_t ind_buf[150]; - for (int i= 0; i < 110; i++) { + for (int i = 0; i < 110; i++) { ind_buf[i] = i; } ind.buffer = ind_buf; diff --git a/UNITTESTS/features/netsocket/NetworkStack/test_NetworkStack.cpp b/UNITTESTS/features/netsocket/NetworkStack/test_NetworkStack.cpp index 368618ea8f..236b0745dc 100644 --- a/UNITTESTS/features/netsocket/NetworkStack/test_NetworkStack.cpp +++ b/UNITTESTS/features/netsocket/NetworkStack/test_NetworkStack.cpp @@ -77,22 +77,22 @@ class NetworkStackChild : public NetworkStack { return NSAPI_ERROR_OK; } virtual nsapi_size_or_error_t socket_send(nsapi_socket_t handle, - const void *data, nsapi_size_t size) + const void *data, nsapi_size_t size) { return NSAPI_ERROR_OK; } virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle, - void *data, nsapi_size_t size) + void *data, nsapi_size_t size) { return NSAPI_ERROR_OK; } virtual nsapi_size_or_error_t socket_sendto(nsapi_socket_t handle, const SocketAddress &address, - const void *data, nsapi_size_t size) + const void *data, nsapi_size_t size) { return NSAPI_ERROR_OK; } virtual nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle, SocketAddress *address, - void *buffer, nsapi_size_t size) + void *buffer, nsapi_size_t size) { return NSAPI_ERROR_OK; } diff --git a/UNITTESTS/stubs/CellularDevice_stub.cpp b/UNITTESTS/stubs/CellularDevice_stub.cpp index aba5fc8f04..542d79e8fb 100644 --- a/UNITTESTS/stubs/CellularDevice_stub.cpp +++ b/UNITTESTS/stubs/CellularDevice_stub.cpp @@ -27,7 +27,7 @@ MBED_WEAK CellularDevice *CellularDevice::get_default_instance() } CellularDevice::CellularDevice() : _network_ref_count(0), _sms_ref_count(0), _power_ref_count(0), _sim_ref_count(0), - _info_ref_count(0) + _info_ref_count(0) { } diff --git a/UNITTESTS/stubs/EventFlags_stub.cpp b/UNITTESTS/stubs/EventFlags_stub.cpp index 82b1f48f62..39ded93482 100644 --- a/UNITTESTS/stubs/EventFlags_stub.cpp +++ b/UNITTESTS/stubs/EventFlags_stub.cpp @@ -42,8 +42,7 @@ uint32_t rtos::EventFlags::wait_all(uint32_t flags, uint32_t timeout, bool clear } uint32_t rtos::EventFlags::wait_any(uint32_t flags, uint32_t timeout, bool clear) { - if (!eventFlagsStubNextRetval.empty()) - { + if (!eventFlagsStubNextRetval.empty()) { uint32_t ret = eventFlagsStubNextRetval.front(); eventFlagsStubNextRetval.pop_front(); return ret; diff --git a/UNITTESTS/stubs/EventQueue_stub.h b/UNITTESTS/stubs/EventQueue_stub.h index 4dfb6ac567..12fb4d51a4 100644 --- a/UNITTESTS/stubs/EventQueue_stub.h +++ b/UNITTESTS/stubs/EventQueue_stub.h @@ -17,8 +17,7 @@ #include -namespace EventQueue_stub -{ +namespace EventQueue_stub { extern int int_value; extern unsigned unsigned_value; } diff --git a/UNITTESTS/stubs/FileHandle_stub.h b/UNITTESTS/stubs/FileHandle_stub.h index 41fb365ea6..69b6475294 100644 --- a/UNITTESTS/stubs/FileHandle_stub.h +++ b/UNITTESTS/stubs/FileHandle_stub.h @@ -20,27 +20,26 @@ #include "FileHandle.h" -namespace mbed -{ +namespace mbed { static uint8_t filehandle_stub_short_value_counter = 0; static char *filehandle_stub_table = NULL; static uint8_t filehandle_stub_table_pos = 0; -class FileHandle_stub : public FileHandle -{ - public: +class FileHandle_stub : public FileHandle { +public: ssize_t size_value; - FileHandle_stub() { size_value = 0; } + FileHandle_stub() + { + size_value = 0; + } virtual ssize_t read(void *buffer, size_t size) { - if (filehandle_stub_table) - { + if (filehandle_stub_table) { ssize_t ret = strlen(filehandle_stub_table) - filehandle_stub_table_pos; - if (size < ret) - { + if (size < ret) { ret = size; } memcpy(buffer, filehandle_stub_table, ret); @@ -52,33 +51,35 @@ class FileHandle_stub : public FileHandle virtual ssize_t write(const void *buffer, size_t size) { - if (size_value > 0) - { + if (size_value > 0) { size_value--; return size; - } - else if (size_value < 0) - { + } else if (size_value < 0) { return -1; } return 0; } - virtual off_t seek(off_t offset, int whence = SEEK_SET) { return 0; } + virtual off_t seek(off_t offset, int whence = SEEK_SET) + { + return 0; + } virtual int close() {} virtual short poll(short events) const { - if (filehandle_stub_short_value_counter) - { + if (filehandle_stub_short_value_counter) { filehandle_stub_short_value_counter--; return short_value; } return 0; } - virtual void sigio(Callback func) { func(); } + virtual void sigio(Callback func) + { + func(); + } short short_value; }; diff --git a/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp b/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp index e4ebeeb849..5d84f26359 100644 --- a/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp +++ b/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp @@ -29,13 +29,13 @@ void LoRaMacChannelPlan::activate_channelplan_subsystem(LoRaPHY *phy) { } -lorawan_status_t LoRaMacChannelPlan::set_plan(const lorawan_channelplan_t& plan) +lorawan_status_t LoRaMacChannelPlan::set_plan(const lorawan_channelplan_t &plan) { return LORAWAN_STATUS_OK; } -lorawan_status_t LoRaMacChannelPlan::get_plan(lorawan_channelplan_t& plan, - const channel_params_t* channel_list) +lorawan_status_t LoRaMacChannelPlan::get_plan(lorawan_channelplan_t &plan, + const channel_params_t *channel_list) { return LORAWAN_STATUS_OK; } diff --git a/UNITTESTS/stubs/LoRaMacCommand_stub.cpp b/UNITTESTS/stubs/LoRaMacCommand_stub.cpp index 4e67194d36..1bed37572e 100644 --- a/UNITTESTS/stubs/LoRaMacCommand_stub.cpp +++ b/UNITTESTS/stubs/LoRaMacCommand_stub.cpp @@ -72,7 +72,7 @@ bool LoRaMacCommand::has_sticky_mac_cmd() const lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, uint8_t mac_index, uint8_t commands_size, uint8_t snr, - loramac_mlme_confirm_t& mlme_conf, + loramac_mlme_confirm_t &mlme_conf, lora_mac_system_params_t &mac_sys_params, LoRaPHY &lora_phy) { diff --git a/UNITTESTS/stubs/LoRaMacCommand_stub.h b/UNITTESTS/stubs/LoRaMacCommand_stub.h index c7ce5f3716..2d1678ff7a 100644 --- a/UNITTESTS/stubs/LoRaMacCommand_stub.h +++ b/UNITTESTS/stubs/LoRaMacCommand_stub.h @@ -19,8 +19,7 @@ #include #include "lorawan_types.h" -namespace LoRaMacCommand_stub -{ +namespace LoRaMacCommand_stub { extern lorawan_status_t status_value; extern bool bool_value; extern uint8_t uint8_value; diff --git a/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp b/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp index b4b272d23c..669e44f64c 100644 --- a/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp +++ b/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp @@ -30,25 +30,25 @@ LoRaMacCrypto::LoRaMacCrypto() { } -int LoRaMacCrypto::compute_mic(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t, +int LoRaMacCrypto::compute_mic(const uint8_t *, uint16_t, const uint8_t *, uint32_t, uint32_t, uint8_t dir, uint32_t, uint32_t *) { return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++]; } -int LoRaMacCrypto::encrypt_payload(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t, - uint8_t , uint32_t , uint8_t *) +int LoRaMacCrypto::encrypt_payload(const uint8_t *, uint16_t, const uint8_t *, uint32_t, uint32_t, + uint8_t, uint32_t, uint8_t *) { return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++]; } -int LoRaMacCrypto::decrypt_payload(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t, - uint8_t , uint32_t , uint8_t *) +int LoRaMacCrypto::decrypt_payload(const uint8_t *, uint16_t, const uint8_t *, uint32_t, uint32_t, + uint8_t, uint32_t, uint8_t *) { return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++]; } -int LoRaMacCrypto::compute_join_frame_mic(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t *) +int LoRaMacCrypto::compute_join_frame_mic(const uint8_t *, uint16_t, const uint8_t *, uint32_t, uint32_t *) { return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++]; } @@ -59,7 +59,7 @@ int LoRaMacCrypto::decrypt_join_frame(const uint8_t *in, uint16_t size, const ui return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++]; } -int LoRaMacCrypto::compute_skeys_for_join_frame(const uint8_t *, uint32_t, const uint8_t *, uint16_t , +int LoRaMacCrypto::compute_skeys_for_join_frame(const uint8_t *, uint32_t, const uint8_t *, uint16_t, uint8_t *, uint8_t *) { return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++]; diff --git a/UNITTESTS/stubs/LoRaMacCrypto_stub.h b/UNITTESTS/stubs/LoRaMacCrypto_stub.h index 4a3a568efa..fb0f24eb1f 100644 --- a/UNITTESTS/stubs/LoRaMacCrypto_stub.h +++ b/UNITTESTS/stubs/LoRaMacCrypto_stub.h @@ -18,8 +18,7 @@ #include -namespace LoRaMacCrypto_stub -{ +namespace LoRaMacCrypto_stub { extern int int_table_idx_value; extern int int_table[20]; } diff --git a/UNITTESTS/stubs/LoRaMac_stub.h b/UNITTESTS/stubs/LoRaMac_stub.h index d98963b613..dedb261745 100644 --- a/UNITTESTS/stubs/LoRaMac_stub.h +++ b/UNITTESTS/stubs/LoRaMac_stub.h @@ -22,8 +22,7 @@ #include "lorawan_types.h" #include "lorawan_data_structures.h" -namespace LoRaMac_stub -{ +namespace LoRaMac_stub { extern bool bool_value; extern int bool_false_counter; extern int bool_true_counter; diff --git a/UNITTESTS/stubs/LoRaPHY_stub.h b/UNITTESTS/stubs/LoRaPHY_stub.h index 12a4e589bf..d3c8cffdd8 100644 --- a/UNITTESTS/stubs/LoRaPHY_stub.h +++ b/UNITTESTS/stubs/LoRaPHY_stub.h @@ -21,8 +21,7 @@ #include "lorawan_types.h" -namespace LoRaPHY_stub -{ +namespace LoRaPHY_stub { extern LoRaRadio *radio; extern uint8_t bool_counter; extern bool bool_table[20]; @@ -33,7 +32,7 @@ extern int int_value; extern double double_value; extern uint16_t uint16_value; extern lorawan_status_t lorawan_status_value; -extern channel_params_t* channel_params_ptr; +extern channel_params_t *channel_params_ptr; extern uint8_t linkAdrNbBytesParsed; extern uint8_t ch_mask_value; extern uint8_t adr_parse_count; diff --git a/UNITTESTS/stubs/LoRaWANTimer_stub.cpp b/UNITTESTS/stubs/LoRaWANTimer_stub.cpp index a66381c45f..4cbf21cdd8 100644 --- a/UNITTESTS/stubs/LoRaWANTimer_stub.cpp +++ b/UNITTESTS/stubs/LoRaWANTimer_stub.cpp @@ -36,7 +36,7 @@ void LoRaWANTimeHandler::activate_timer_subsystem(events::EventQueue *queue) { } -lorawan_time_t LoRaWANTimeHandler::get_current_time( void ) +lorawan_time_t LoRaWANTimeHandler::get_current_time(void) { return LoRaWANTimer_stub::time_value; } diff --git a/UNITTESTS/stubs/LoRaWANTimer_stub.h b/UNITTESTS/stubs/LoRaWANTimer_stub.h index 54a0f66633..0bc3db7396 100644 --- a/UNITTESTS/stubs/LoRaWANTimer_stub.h +++ b/UNITTESTS/stubs/LoRaWANTimer_stub.h @@ -17,8 +17,7 @@ #include "LoRaWANTimer.h" -namespace LoRaWANTimer_stub -{ +namespace LoRaWANTimer_stub { extern lorawan_time_t time_value; extern bool call_cb_immediately; } diff --git a/UNITTESTS/stubs/MBRBlockDevice_stub.cpp b/UNITTESTS/stubs/MBRBlockDevice_stub.cpp index 9759f749c9..449236be6e 100644 --- a/UNITTESTS/stubs/MBRBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/MBRBlockDevice_stub.cpp @@ -55,8 +55,8 @@ static void tochs(uint32_t lba, uint8_t chs[3]) // Partition after address are turned into absolute // addresses, assumes bd is initialized static int partition_absolute( - BlockDevice *bd, int part, uint8_t type, - bd_size_t offset, bd_size_t size) + BlockDevice *bd, int part, uint8_t type, + bd_size_t offset, bd_size_t size) { return 0; } @@ -67,7 +67,7 @@ int MBRBlockDevice::partition(BlockDevice *bd, int part, uint8_t type, bd_addr_t } int MBRBlockDevice::partition(BlockDevice *bd, int part, uint8_t type, - bd_addr_t start, bd_addr_t stop) + bd_addr_t start, bd_addr_t stop) { return 0; } diff --git a/UNITTESTS/stubs/NetworkStack_stub.h b/UNITTESTS/stubs/NetworkStack_stub.h index 3a8955a6e0..43eda21ee9 100644 --- a/UNITTESTS/stubs/NetworkStack_stub.h +++ b/UNITTESTS/stubs/NetworkStack_stub.h @@ -47,10 +47,9 @@ public: protected: virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto) { - if (return_value == NSAPI_ERROR_OK && return_values.front() == NSAPI_ERROR_OK) - { + if (return_value == NSAPI_ERROR_OK && return_values.front() == NSAPI_ERROR_OK) { // Make sure a non-NULL value is returned if error is not expected - *handle = reinterpret_cast(1234); + *handle = reinterpret_cast(1234); } return return_value; }; @@ -68,8 +67,7 @@ protected: }; virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address) { - if (!return_values.empty()) - { + if (!return_values.empty()) { nsapi_error_t ret = return_values.front(); return_values.pop_front(); return ret; @@ -84,8 +82,7 @@ protected: virtual nsapi_size_or_error_t socket_send(nsapi_socket_t handle, const void *data, nsapi_size_t size) { - if (!return_values.empty()) - { + if (!return_values.empty()) { nsapi_error_t ret = return_values.front(); return_values.pop_front(); return ret; @@ -95,8 +92,7 @@ protected: virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle, void *data, nsapi_size_t size) { - if (!return_values.empty()) - { + if (!return_values.empty()) { nsapi_error_t ret = return_values.front(); return_values.pop_front(); return ret; @@ -111,8 +107,7 @@ protected: virtual nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle, SocketAddress *address, void *buffer, nsapi_size_t size) { - if (!return_values.empty()) - { + if (!return_values.empty()) { nsapi_error_t ret = return_values.front(); return_values.pop_front(); return ret; diff --git a/UNITTESTS/stubs/aes_stub.c b/UNITTESTS/stubs/aes_stub.c index fad4b276f1..2aa4faeb29 100644 --- a/UNITTESTS/stubs/aes_stub.c +++ b/UNITTESTS/stubs/aes_stub.c @@ -30,27 +30,27 @@ aes_stub_def aes_stub; -void mbedtls_aes_init( mbedtls_aes_context *ctx ) +void mbedtls_aes_init(mbedtls_aes_context *ctx) { } -void mbedtls_aes_free( mbedtls_aes_context *ctx ) +void mbedtls_aes_free(mbedtls_aes_context *ctx) { } #if defined(MBEDTLS_CIPHER_MODE_XTS) -void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx ) +void mbedtls_aes_xts_init(mbedtls_aes_xts_context *ctx) { } -void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx ) +void mbedtls_aes_xts_free(mbedtls_aes_xts_context *ctx) { } #endif #if !defined(MBEDTLS_AES_SETKEY_ENC_ALT) -int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, - unsigned int keybits ) +int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, + unsigned int keybits) { if (aes_stub.int_zero_counter) { aes_stub.int_zero_counter--; @@ -61,8 +61,8 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, #endif #if !defined(MBEDTLS_AES_SETKEY_DEC_ALT) -int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, - unsigned int keybits ) +int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, + unsigned int keybits) { if (aes_stub.int_zero_counter) { aes_stub.int_zero_counter--; @@ -73,9 +73,9 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, #endif #if defined(MBEDTLS_CIPHER_MODE_XTS) -int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx, - const unsigned char *key, - unsigned int keybits) +int mbedtls_aes_xts_setkey_enc(mbedtls_aes_xts_context *ctx, + const unsigned char *key, + unsigned int keybits) { if (aes_stub.int_zero_counter) { aes_stub.int_zero_counter--; @@ -84,9 +84,9 @@ int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx, return aes_stub.int_value; } -int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, - const unsigned char *key, - unsigned int keybits) +int mbedtls_aes_xts_setkey_dec(mbedtls_aes_xts_context *ctx, + const unsigned char *key, + unsigned int keybits) { if (aes_stub.int_zero_counter) { aes_stub.int_zero_counter--; @@ -96,9 +96,9 @@ int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, } #endif -int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, - const unsigned char input[16], - unsigned char output[16] ) +int mbedtls_internal_aes_encrypt(mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16]) { if (aes_stub.int_zero_counter) { aes_stub.int_zero_counter--; @@ -107,15 +107,33 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, return aes_stub.int_value; } -void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, +void mbedtls_aes_encrypt(mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16]) +{ +} + +int mbedtls_internal_aes_decrypt(mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16]) +{ + if (aes_stub.int_zero_counter) { + aes_stub.int_zero_counter--; + return 0; + } + return aes_stub.int_value; +} + +void mbedtls_aes_decrypt(mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16]) +{ +} + +int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, + int mode, const unsigned char input[16], - unsigned char output[16] ) -{ -} - -int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, - const unsigned char input[16], - unsigned char output[16] ) + unsigned char output[16]) { if (aes_stub.int_zero_counter) { aes_stub.int_zero_counter--; @@ -124,30 +142,12 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, return aes_stub.int_value; } -void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, - const unsigned char input[16], - unsigned char output[16] ) -{ -} - -int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, - int mode, - const unsigned char input[16], - unsigned char output[16] ) -{ - if (aes_stub.int_zero_counter) { - aes_stub.int_zero_counter--; - return 0; - } - return aes_stub.int_value; -} - -int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, - int mode, - size_t length, - unsigned char iv[16], - const unsigned char *input, - unsigned char *output ) +int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx, + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output) { if (aes_stub.int_zero_counter) { aes_stub.int_zero_counter--; @@ -158,56 +158,42 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, #if defined(MBEDTLS_CIPHER_MODE_XTS) -int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx, +int mbedtls_aes_crypt_xts(mbedtls_aes_xts_context *ctx, + int mode, + size_t length, + const unsigned char data_unit[16], + const unsigned char *input, + unsigned char *output) +{ + if (aes_stub.int_zero_counter) { + aes_stub.int_zero_counter--; + return 0; + } + return aes_stub.int_value; +} +#endif + +int mbedtls_aes_crypt_cfb128(mbedtls_aes_context *ctx, + int mode, + size_t length, + size_t *iv_off, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output) +{ + if (aes_stub.int_zero_counter) { + aes_stub.int_zero_counter--; + return 0; + } + return aes_stub.int_value; +} + +int mbedtls_aes_crypt_cfb8(mbedtls_aes_context *ctx, int mode, size_t length, - const unsigned char data_unit[16], - const unsigned char *input, - unsigned char *output ) -{ - if (aes_stub.int_zero_counter) { - aes_stub.int_zero_counter--; - return 0; - } - return aes_stub.int_value; -} -#endif - -int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, - int mode, - size_t length, - size_t *iv_off, - unsigned char iv[16], - const unsigned char *input, - unsigned char *output ) -{ - if (aes_stub.int_zero_counter) { - aes_stub.int_zero_counter--; - return 0; - } - return aes_stub.int_value; -} - -int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, - int mode, - size_t length, - unsigned char iv[16], - const unsigned char *input, - unsigned char *output ) -{ - if (aes_stub.int_zero_counter) { - aes_stub.int_zero_counter--; - return 0; - } - return aes_stub.int_value; -} - -int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, - size_t length, - size_t *iv_off, unsigned char iv[16], const unsigned char *input, - unsigned char *output ) + unsigned char *output) { if (aes_stub.int_zero_counter) { aes_stub.int_zero_counter--; @@ -216,13 +202,27 @@ int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, return aes_stub.int_value; } -int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, - size_t length, - size_t *nc_off, - unsigned char nonce_counter[16], - unsigned char stream_block[16], - const unsigned char *input, - unsigned char *output ) +int mbedtls_aes_crypt_ofb(mbedtls_aes_context *ctx, + size_t length, + size_t *iv_off, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output) +{ + if (aes_stub.int_zero_counter) { + aes_stub.int_zero_counter--; + return 0; + } + return aes_stub.int_value; +} + +int mbedtls_aes_crypt_ctr(mbedtls_aes_context *ctx, + size_t length, + size_t *nc_off, + unsigned char nonce_counter[16], + unsigned char stream_block[16], + const unsigned char *input, + unsigned char *output) { if (aes_stub.int_zero_counter) { aes_stub.int_zero_counter--; diff --git a/UNITTESTS/stubs/cipher_stub.c b/UNITTESTS/stubs/cipher_stub.c index e55a685193..d6fc38ff9c 100644 --- a/UNITTESTS/stubs/cipher_stub.c +++ b/UNITTESTS/stubs/cipher_stub.c @@ -44,37 +44,37 @@ cipher_stub_def cipher_stub; -const int *mbedtls_cipher_list( void ) +const int *mbedtls_cipher_list(void) { return cipher_stub.int_ptr; } -const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher_type_t cipher_type ) +const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type(const mbedtls_cipher_type_t cipher_type) { return cipher_stub.info_value; } -const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher_name ) +const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string(const char *cipher_name) { return cipher_stub.info_value; } -const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_cipher_id_t cipher_id, - int key_bitlen, - const mbedtls_cipher_mode_t mode ) +const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values(const mbedtls_cipher_id_t cipher_id, + int key_bitlen, + const mbedtls_cipher_mode_t mode) { return cipher_stub.info_value; } -void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx ) +void mbedtls_cipher_init(mbedtls_cipher_context_t *ctx) { } -void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx ) +void mbedtls_cipher_free(mbedtls_cipher_context_t *ctx) { } -int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info ) +int mbedtls_cipher_setup(mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -83,8 +83,8 @@ int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_in return cipher_stub.int_value; } -int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key, - int key_bitlen, const mbedtls_operation_t operation ) +int mbedtls_cipher_setkey(mbedtls_cipher_context_t *ctx, const unsigned char *key, + int key_bitlen, const mbedtls_operation_t operation) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -93,8 +93,8 @@ int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *k return cipher_stub.int_value; } -int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, - const unsigned char *iv, size_t iv_len ) +int mbedtls_cipher_set_iv(mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -103,7 +103,7 @@ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, return cipher_stub.int_value; } -int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx ) +int mbedtls_cipher_reset(mbedtls_cipher_context_t *ctx) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -112,8 +112,8 @@ int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx ) return cipher_stub.int_value; } -int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx, - const unsigned char *ad, size_t ad_len ) +int mbedtls_cipher_update_ad(mbedtls_cipher_context_t *ctx, + const unsigned char *ad, size_t ad_len) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -122,8 +122,8 @@ int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx, return cipher_stub.int_value; } -int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input, - size_t ilen, unsigned char *output, size_t *olen ) +int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *input, + size_t ilen, unsigned char *output, size_t *olen) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -132,8 +132,8 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i return cipher_stub.int_value; } -int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, - unsigned char *output, size_t *olen ) +int mbedtls_cipher_finish(mbedtls_cipher_context_t *ctx, + unsigned char *output, size_t *olen) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -142,7 +142,7 @@ int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, return cipher_stub.int_value; } -int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode ) +int mbedtls_cipher_set_padding_mode(mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -151,8 +151,8 @@ int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_ciph return cipher_stub.int_value; } -int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx, - unsigned char *tag, size_t tag_len ) +int mbedtls_cipher_write_tag(mbedtls_cipher_context_t *ctx, + unsigned char *tag, size_t tag_len) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -161,8 +161,8 @@ int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx, return cipher_stub.int_value; } -int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx, - const unsigned char *tag, size_t tag_len ) +int mbedtls_cipher_check_tag(mbedtls_cipher_context_t *ctx, + const unsigned char *tag, size_t tag_len) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -171,24 +171,10 @@ int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx, return cipher_stub.int_value; } -int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx, - const unsigned char *iv, size_t iv_len, - const unsigned char *input, size_t ilen, - unsigned char *output, size_t *olen ) -{ - if (cipher_stub.int_zero_counter) { - cipher_stub.int_zero_counter--; - return 0; - } - return cipher_stub.int_value; -} - -int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx, +int mbedtls_cipher_crypt(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, - const unsigned char *ad, size_t ad_len, const unsigned char *input, size_t ilen, - unsigned char *output, size_t *olen, - unsigned char *tag, size_t tag_len ) + unsigned char *output, size_t *olen) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; @@ -197,12 +183,26 @@ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx, return cipher_stub.int_value; } -int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx, - const unsigned char *iv, size_t iv_len, - const unsigned char *ad, size_t ad_len, - const unsigned char *input, size_t ilen, - unsigned char *output, size_t *olen, - const unsigned char *tag, size_t tag_len ) +int mbedtls_cipher_auth_encrypt(mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len, + const unsigned char *ad, size_t ad_len, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, + unsigned char *tag, size_t tag_len) +{ + if (cipher_stub.int_zero_counter) { + cipher_stub.int_zero_counter--; + return 0; + } + return cipher_stub.int_value; +} + +int mbedtls_cipher_auth_decrypt(mbedtls_cipher_context_t *ctx, + const unsigned char *iv, size_t iv_len, + const unsigned char *ad, size_t ad_len, + const unsigned char *input, size_t ilen, + unsigned char *output, size_t *olen, + const unsigned char *tag, size_t tag_len) { if (cipher_stub.int_zero_counter) { cipher_stub.int_zero_counter--; diff --git a/UNITTESTS/stubs/cmac_stub.c b/UNITTESTS/stubs/cmac_stub.c index 382579fe1a..8ecd5709cd 100644 --- a/UNITTESTS/stubs/cmac_stub.c +++ b/UNITTESTS/stubs/cmac_stub.c @@ -30,8 +30,8 @@ cmac_stub_def cmac_stub; -int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx, - const unsigned char *key, size_t keybits ) +int mbedtls_cipher_cmac_starts(mbedtls_cipher_context_t *ctx, + const unsigned char *key, size_t keybits) { if (cmac_stub.int_zero_counter) { cmac_stub.int_zero_counter--; @@ -40,8 +40,8 @@ int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx, return cmac_stub.int_value; } -int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx, - const unsigned char *input, size_t ilen ) +int mbedtls_cipher_cmac_update(mbedtls_cipher_context_t *ctx, + const unsigned char *input, size_t ilen) { if (cmac_stub.int_zero_counter) { cmac_stub.int_zero_counter--; @@ -50,8 +50,8 @@ int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx, return cmac_stub.int_value; } -int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx, - unsigned char *output ) +int mbedtls_cipher_cmac_finish(mbedtls_cipher_context_t *ctx, + unsigned char *output) { if (cmac_stub.int_zero_counter) { cmac_stub.int_zero_counter--; @@ -60,7 +60,7 @@ int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx, return cmac_stub.int_value; } -int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx ) +int mbedtls_cipher_cmac_reset(mbedtls_cipher_context_t *ctx) { if (cmac_stub.int_zero_counter) { cmac_stub.int_zero_counter--; @@ -69,10 +69,10 @@ int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx ) return cmac_stub.int_value; } -int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info, - const unsigned char *key, size_t keylen, - const unsigned char *input, size_t ilen, - unsigned char *output ) +int mbedtls_cipher_cmac(const mbedtls_cipher_info_t *cipher_info, + const unsigned char *key, size_t keylen, + const unsigned char *input, size_t ilen, + unsigned char *output) { if (cmac_stub.int_zero_counter) { cmac_stub.int_zero_counter--; @@ -81,9 +81,9 @@ int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info, return cmac_stub.int_value; } -int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_length, - const unsigned char *input, size_t in_len, - unsigned char *output ) +int mbedtls_aes_cmac_prf_128(const unsigned char *key, size_t key_length, + const unsigned char *input, size_t in_len, + unsigned char *output) { if (cmac_stub.int_zero_counter) { cmac_stub.int_zero_counter--; diff --git a/UNITTESTS/stubs/equeue_stub.c b/UNITTESTS/stubs/equeue_stub.c index 4fea449ab1..40cdcd65b0 100644 --- a/UNITTESTS/stubs/equeue_stub.c +++ b/UNITTESTS/stubs/equeue_stub.c @@ -84,7 +84,7 @@ void equeue_event_dtor(void *event, void (*dtor)(void *)) int equeue_post(equeue_t *queue, void (*cb)(void *), void *event) { - struct equeue_event *e = (struct equeue_event*)event - 1; + struct equeue_event *e = (struct equeue_event *)event - 1; if (cb && equeue_stub.call_cb_immediately) { cb(e + 1); return 1; @@ -108,7 +108,8 @@ void equeue_chain(equeue_t *queue, equeue_t *target) } -int equeue_call_in(equeue_t *q, int ms, void (*cb)(void*), void *data) { +int equeue_call_in(equeue_t *q, int ms, void (*cb)(void *), void *data) +{ // The stub does not implement the delay mechanism. return equeue_post(q, cb, data); } diff --git a/UNITTESTS/target_h/cmsis_os2.h b/UNITTESTS/target_h/cmsis_os2.h index c2a601fb16..c45760f27b 100644 --- a/UNITTESTS/target_h/cmsis_os2.h +++ b/UNITTESTS/target_h/cmsis_os2.h @@ -51,12 +51,12 @@ typedef struct { } osThreadAttr_t; #define osWaitForever 0xFFFFFFFFU ///< Wait forever timeout value. - + // Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait). #define osFlagsWaitAny 0x00000000U ///< Wait for any flag (default). #define osFlagsWaitAll 0x00000001U ///< Wait for all flags. #define osFlagsNoClear 0x00000002U ///< Do not clear flags which have been specified to wait for. - + // Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx). #define osFlagsError 0x80000000U ///< Error indicator. #define osFlagsErrorUnknown 0xFFFFFFFFU ///< osError (-1). @@ -64,11 +64,11 @@ typedef struct { #define osFlagsErrorResource 0xFFFFFFFDU ///< osErrorResource (-3). #define osFlagsErrorParameter 0xFFFFFFFCU ///< osErrorParameter (-4). #define osFlagsErrorISR 0xFFFFFFFAU ///< osErrorISR (-6). - + // Thread attributes (attr_bits in \ref osThreadAttr_t). #define osThreadDetached 0x00000000U ///< Thread created in detached mode (default) #define osThreadJoinable 0x00000001U ///< Thread created in joinable mode - + // Mutex attributes (attr_bits in \ref osMutexAttr_t). #define osMutexRecursive 0x00000001U ///< Recursive mutex. #define osMutexPrioInherit 0x00000002U ///< Priority inherit protocol. diff --git a/UNITTESTS/target_h/rtos.h b/UNITTESTS/target_h/rtos.h index f369fe62eb..b6246789a6 100644 --- a/UNITTESTS/target_h/rtos.h +++ b/UNITTESTS/target_h/rtos.h @@ -19,8 +19,8 @@ #define RTOS_H typedef enum { - osTimerOnce = 0, ///< One-shot timer. - osTimerPeriodic = 1 ///< Repeating timer. + osTimerOnce = 0, ///< One-shot timer. + osTimerPeriodic = 1 ///< Repeating timer. } os_timer_type; #endif /* RTOS_H */ diff --git a/UNITTESTS/target_h/rtos/Mutex.h b/UNITTESTS/target_h/rtos/Mutex.h index a804e17212..4f38c37fe0 100644 --- a/UNITTESTS/target_h/rtos/Mutex.h +++ b/UNITTESTS/target_h/rtos/Mutex.h @@ -28,7 +28,7 @@ public: Mutex(const char *name); - osStatus lock(uint32_t millisec=osWaitForever); + osStatus lock(uint32_t millisec = osWaitForever); bool trylock(); diff --git a/UNITTESTS/target_h/rtx_os.h b/UNITTESTS/target_h/rtx_os.h index dfa7082fa1..f280c6733f 100644 --- a/UNITTESTS/target_h/rtx_os.h +++ b/UNITTESTS/target_h/rtx_os.h @@ -58,13 +58,13 @@ typedef struct osRtxThread_s { } osRtxThread_t; typedef struct { - uint8_t id; ///< Object Identifier - uint8_t state; ///< Object State - uint8_t flags; ///< Object Flags - uint8_t reserved; - const char *name; ///< Object Name - osRtxThread_t *thread_list; ///< Waiting Threads List - uint32_t event_flags; ///< Event Flags + uint8_t id; ///< Object Identifier + uint8_t state; ///< Object State + uint8_t flags; ///< Object Flags + uint8_t reserved; + const char *name; ///< Object Name + osRtxThread_t *thread_list; ///< Waiting Threads List + uint32_t event_flags; ///< Event Flags } osRtxEventFlags_t; #endif