Skip to content

Commit 7feda70

Browse files
fixed out of range NoCRouterId bug in link removal test
1 parent f715a53 commit 7feda70

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

vpr/test/test_noc_storage.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ TEST_CASE("test_remove_link", "[vpr_noc]") {
279279
std::mt19937 rand_num_gen(device());
280280

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

285285
// create the NoC
@@ -349,9 +349,9 @@ TEST_CASE("test_remove_link", "[vpr_noc]") {
349349

350350
auto& outgoing_links = test_noc.get_noc_router_connections(link_to_remove_src_router);
351351
// 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.
352-
for (auto outgoing_link_id = outgoing_links.begin(); outgoing_link_id != outgoing_links.end(); outgoing_link_id++) {
352+
for (auto outgoing_link : outgoing_links) {
353353
// get the current outgoing link
354-
const NocLink& curr_outgoing_link = test_noc.get_single_noc_link(*outgoing_link_id);
354+
const NocLink& curr_outgoing_link = test_noc.get_single_noc_link(outgoing_link);
355355

356356
if ((curr_outgoing_link.get_source_router() == link_to_remove_src_router) && (curr_outgoing_link.get_sink_router() == link_to_remove_sink_router)) {
357357
link_removed_from_outgoing_vector = false;
@@ -363,9 +363,9 @@ TEST_CASE("test_remove_link", "[vpr_noc]") {
363363
const auto& links_in_noc = test_noc.get_noc_links();
364364
// go through the links and make sure that none of them have the source and sink router of the link
365365
// that we removed. THe removed link should have the source and sink routers set to invalid values.
366-
for (auto single_link = links_in_noc.begin(); single_link != links_in_noc.end(); single_link++) {
366+
for (auto single_link : links_in_noc) {
367367
// check whether the source and sink router of the current link matches the routers in the link to remove
368-
if ((single_link->get_source_router() == link_to_remove_src_router) && (single_link->get_sink_router() == link_to_remove_sink_router)) {
368+
if ((single_link.get_source_router() == link_to_remove_src_router) && (single_link.get_sink_router() == link_to_remove_sink_router)) {
369369
// this indicates that the link was not set to an invalid state and not removed properly
370370
link_removed_from_outgoing_vector = false;
371371
break;

0 commit comments

Comments
 (0)