Skip to content

Commit

Permalink
fix noc unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
duck2 committed Nov 14, 2023
1 parent 86f6e47 commit 7a323de
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions vpr/test/test_noc_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ TEST_CASE("test_router_link_list", "[vpr_noc]") {
NocRouterId source;
NocRouterId sink;

NocLinkId link_id;

// testing datastructure
NocStorage test_noc;

Expand Down Expand Up @@ -279,7 +277,7 @@ TEST_CASE("test_remove_link", "[vpr_noc]") {
std::mt19937 rand_num_gen(device());

// random number generation to determine routers of the link to remove
std::uniform_int_distribution<std::mt19937::result_type> src_router(0, NUM_OF_ROUTERS);
std::uniform_int_distribution<std::mt19937::result_type> src_router(0, NUM_OF_ROUTERS - 1);
std::uniform_int_distribution<std::mt19937::result_type> sink_router(1, NOC_CONNECTIVITY - 1);

// create the NoC
Expand Down Expand Up @@ -349,9 +347,9 @@ TEST_CASE("test_remove_link", "[vpr_noc]") {

auto& outgoing_links = test_noc.get_noc_router_connections(link_to_remove_src_router);
// go through all the outgoing links of the source router in the link we removed and check that the link does not exist there as well.
for (auto outgoing_link_id = outgoing_links.begin(); outgoing_link_id != outgoing_links.end(); outgoing_link_id++) {
for (auto outgoing_link : outgoing_links) {
// get the current outgoing link
const NocLink& curr_outgoing_link = test_noc.get_single_noc_link(*outgoing_link_id);
const NocLink& curr_outgoing_link = test_noc.get_single_noc_link(outgoing_link);

if ((curr_outgoing_link.get_source_router() == link_to_remove_src_router) && (curr_outgoing_link.get_sink_router() == link_to_remove_sink_router)) {
link_removed_from_outgoing_vector = false;
Expand All @@ -363,9 +361,9 @@ TEST_CASE("test_remove_link", "[vpr_noc]") {
const auto& links_in_noc = test_noc.get_noc_links();
// go through the links and make sure that none of them have the source and sink router of the link
// that we removed. THe removed link should have the source and sink routers set to invalid values.
for (auto single_link = links_in_noc.begin(); single_link != links_in_noc.end(); single_link++) {
for (auto single_link : links_in_noc) {
// check whether the source and sink router of the current link matches the routers in the link to remove
if ((single_link->get_source_router() == link_to_remove_src_router) && (single_link->get_sink_router() == link_to_remove_sink_router)) {
if ((single_link.get_source_router() == link_to_remove_src_router) && (single_link.get_sink_router() == link_to_remove_sink_router)) {
// this indicates that the link was not set to an invalid state and not removed properly
link_removed_from_outgoing_vector = false;
break;
Expand Down Expand Up @@ -412,8 +410,6 @@ TEST_CASE("test_generate_router_key_from_grid_location", "[vpr_noc]") {
// this will be set to the total number of routers (and should be set before adding routers)
test_noc.set_device_grid_spec((int)NUM_OF_ROUTERS, 0);

NocRouterId converted_id;

// add all the routers to noc_storage and populate the golden router set
for (int router_number = 0; router_number < NUM_OF_ROUTERS; router_number++) {
// determine the current router parameters
Expand Down

0 comments on commit 7a323de

Please sign in to comment.