From 7a323debda989269a7379267f461c6d3f30175f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fahrican=20Ko=C5=9Far?= Date: Tue, 14 Nov 2023 14:01:23 -0500 Subject: [PATCH] fix noc unit test --- vpr/test/test_noc_storage.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/vpr/test/test_noc_storage.cpp b/vpr/test/test_noc_storage.cpp index a0a3e2ee54b..1cdc57550ad 100644 --- a/vpr/test/test_noc_storage.cpp +++ b/vpr/test/test_noc_storage.cpp @@ -205,8 +205,6 @@ TEST_CASE("test_router_link_list", "[vpr_noc]") { NocRouterId source; NocRouterId sink; - NocLinkId link_id; - // testing datastructure NocStorage test_noc; @@ -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 src_router(0, NUM_OF_ROUTERS); + std::uniform_int_distribution src_router(0, NUM_OF_ROUTERS - 1); std::uniform_int_distribution sink_router(1, NOC_CONNECTIVITY - 1); // create the NoC @@ -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; @@ -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; @@ -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