Skip to content

Removed EMAC get default instance from EMAC tests #6941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion TESTS/network/emac/emac_TestNetworkStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ nsapi_error_t EmacTestNetworkStack::add_ethernet_interface(EMAC &emac, bool defa

m_interface->m_emac = &emac;

EmacTestMemoryManager *memory_manager = &EmacTestMemoryManager::get_instance();
emac.set_memory_manager(*memory_manager);

*interface_out = m_interface;

return NSAPI_ERROR_OK;
Expand Down Expand Up @@ -158,7 +161,7 @@ char *EmacTestNetworkStack::Interface::get_gateway(char *buf, nsapi_size_t bufle

nsapi_error_t EmacTestNetworkStack::Interface::bringup(bool dhcp, const char *ip, const char *netmask, const char *gw, const nsapi_ip_stack_t stack, bool blocking)
{
if (!emac_if_init()) {
if (!emac_if_init(m_emac)) {
TEST_ASSERT_MESSAGE(0, "emac initialization failed!");
}

Expand Down
2 changes: 1 addition & 1 deletion TESTS/network/emac/emac_initialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define EMAC_INITIALIZE_H

unsigned char *emac_if_get_hw_addr(void);
bool emac_if_init(void);
bool emac_if_init(EMAC *emac);
EMAC *emac_if_get(void);
EmacTestMemoryManager *emac_m_mngr_get(void);

Expand Down
9 changes: 4 additions & 5 deletions TESTS/network/emac/emac_test_initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
using namespace utest::v1;

static unsigned char eth_mac_addr[ETH_MAC_ADDR_LEN];
EMAC *emac_handle = NULL;

void test_emac_initialize()
{
Expand Down Expand Up @@ -104,19 +105,17 @@ unsigned char *emac_if_get_hw_addr(void)

EMAC *emac_if_get(void)
{
return &EMAC::get_default_instance();
return emac_handle;
}

EmacTestMemoryManager *emac_m_mngr_get(void)
{
return &EmacTestMemoryManager::get_instance();
}

bool emac_if_init(void)
bool emac_if_init(EMAC *emac)
{
static EMAC *emac = &EMAC::get_default_instance();
static EmacTestMemoryManager *memory_manager = &EmacTestMemoryManager::get_instance();
emac->set_memory_manager(*memory_manager);
emac_handle = emac;

emac->set_link_input_cb(emac_if_link_input_cb);
emac->set_link_state_cb(emac_if_link_state_change_cb);
Expand Down
3 changes: 2 additions & 1 deletion features/netsocket/OnboardNetworkStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ class OnboardNetworkStack : public NetworkStack {
/** Register a network interface with the IP stack
*
* Connects EMAC layer with the IP stack and initializes all the required infrastructure.
* This function should be called only once for each available interface.
* This function should be called only once for each available interface. EMAC memory
* manager is available to EMAC after this function call.
*
* @param emac EMAC HAL implementation for this network interface
* @param default_if true if the interface should be treated as the default one
Expand Down