Skip to content

Commit 7a323de

Browse files
committed
fix noc unit test
1 parent 86f6e47 commit 7a323de

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

vpr/test/test_noc_storage.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ TEST_CASE("test_router_link_list", "[vpr_noc]") {
205205
NocRouterId source;
206206
NocRouterId sink;
207207

208-
NocLinkId link_id;
209-
210208
// testing datastructure
211209
NocStorage test_noc;
212210

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

281279
// 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);
280+
std::uniform_int_distribution<std::mt19937::result_type> src_router(0, NUM_OF_ROUTERS - 1);
283281
std::uniform_int_distribution<std::mt19937::result_type> sink_router(1, NOC_CONNECTIVITY - 1);
284282

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

350348
auto& outgoing_links = test_noc.get_noc_router_connections(link_to_remove_src_router);
351349
// 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++) {
350+
for (auto outgoing_link : outgoing_links) {
353351
// get the current outgoing link
354-
const NocLink& curr_outgoing_link = test_noc.get_single_noc_link(*outgoing_link_id);
352+
const NocLink& curr_outgoing_link = test_noc.get_single_noc_link(outgoing_link);
355353

356354
if ((curr_outgoing_link.get_source_router() == link_to_remove_src_router) && (curr_outgoing_link.get_sink_router() == link_to_remove_sink_router)) {
357355
link_removed_from_outgoing_vector = false;
@@ -363,9 +361,9 @@ TEST_CASE("test_remove_link", "[vpr_noc]") {
363361
const auto& links_in_noc = test_noc.get_noc_links();
364362
// go through the links and make sure that none of them have the source and sink router of the link
365363
// 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++) {
364+
for (auto single_link : links_in_noc) {
367365
// 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)) {
366+
if ((single_link.get_source_router() == link_to_remove_src_router) && (single_link.get_sink_router() == link_to_remove_sink_router)) {
369367
// this indicates that the link was not set to an invalid state and not removed properly
370368
link_removed_from_outgoing_vector = false;
371369
break;
@@ -412,8 +410,6 @@ TEST_CASE("test_generate_router_key_from_grid_location", "[vpr_noc]") {
412410
// this will be set to the total number of routers (and should be set before adding routers)
413411
test_noc.set_device_grid_spec((int)NUM_OF_ROUTERS, 0);
414412

415-
NocRouterId converted_id;
416-
417413
// add all the routers to noc_storage and populate the golden router set
418414
for (int router_number = 0; router_number < NUM_OF_ROUTERS; router_number++) {
419415
// determine the current router parameters

0 commit comments

Comments
 (0)