diff --git a/test_regress/t/TestVpi.h b/test_regress/t/TestVpi.h index 555e97a18..d4fc51d4c 100644 --- a/test_regress/t/TestVpi.h +++ b/test_regress/t/TestVpi.h @@ -39,8 +39,9 @@ public: m_handle = h; return *this; } - TestVpiHandle& nofree() { + // Freed by another action e.g. vpi_scan; so empty and don't free again + void freed() { + m_handle = NULL; m_free = false; - return *this; } }; diff --git a/test_regress/t/t_vpi_get.cpp b/test_regress/t/t_vpi_get.cpp index c813f8673..f570190be 100644 --- a/test_regress/t/t_vpi_get.cpp +++ b/test_regress/t/t_vpi_get.cpp @@ -180,7 +180,8 @@ int mon_check_props() { if (value->children.size) { int size = 0; TestVpiHandle iter_h = vpi_iterate(vpiMemoryWord, h); - while (TestVpiHandle word_h = vpi_scan(iter_h.nofree())) { + TestVpiHandle word_h; + while (word_h = vpi_scan(iter_h)) { // check size and range if (int status = _mon_check_props(word_h, value->children.size, value->children.direction, @@ -188,6 +189,7 @@ int mon_check_props() { return status; size++; } + word_h.freed(); // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle CHECK_RESULT(size, value->attributes.size); } value++; diff --git a/test_regress/t/t_vpi_module.cpp b/test_regress/t/t_vpi_module.cpp index feb429d47..13ba9eeef 100644 --- a/test_regress/t/t_vpi_module.cpp +++ b/test_regress/t/t_vpi_module.cpp @@ -74,10 +74,6 @@ void modDump(const TestVpiHandle& it, int n) { extern "C" { int mon_check() { TestVpiHandle it = vpi_iterate(vpiModule, NULL); -#ifdef IS_ICARUS - // Icarus segfaults when some VPI handles are freed - it.nofree(); -#endif CHECK_RESULT_NZ(it); // Uncomment to see what other simulators return // modDump(it, 0); @@ -98,8 +94,9 @@ int mon_check() { CHECK_RESULT_NZ(t_name); } CHECK_RESULT_CSTR(t_name, "t"); - TestVpiHandle topmod_done = (vpi_scan(it)); - CHECK_RESULT_Z(topmod_done); + TestVpiHandle topmod_done_should_be_0 = (vpi_scan(it)); + it.freed(); // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle + CHECK_RESULT_Z(topmod_done_should_be_0); TestVpiHandle it2 = vpi_iterate(vpiModule, topmod); CHECK_RESULT_NZ(it2); diff --git a/test_regress/t/t_vpi_var.cpp b/test_regress/t/t_vpi_var.cpp index e74ca8619..a048ad11a 100644 --- a/test_regress/t/t_vpi_var.cpp +++ b/test_regress/t/t_vpi_var.cpp @@ -321,21 +321,25 @@ int _mon_check_varlist() { CHECK_RESULT_NZ(vh2); TestVpiHandle vh10 = vpi_iterate(vpiReg, vh2); - CHECK_RESULT_NZ(vh10.nofree()); - - TestVpiHandle vh11 = vpi_scan(vh10); - CHECK_RESULT_NZ(vh11); - p = vpi_get_str(vpiFullName, vh11); - CHECK_RESULT_CSTR(p, TestSimulator::rooted("sub.subsig1")); - - TestVpiHandle vh12 = vpi_scan(vh10); - CHECK_RESULT_NZ(vh12); - p = vpi_get_str(vpiFullName, vh12); - CHECK_RESULT_CSTR(p, TestSimulator::rooted("sub.subsig2")); - - TestVpiHandle vh13 = vpi_scan(vh10); - CHECK_RESULT(vh13, 0); + CHECK_RESULT_NZ(vh10); + { + TestVpiHandle vh11 = vpi_scan(vh10); + CHECK_RESULT_NZ(vh11); + p = vpi_get_str(vpiFullName, vh11); + CHECK_RESULT_CSTR(p, TestSimulator::rooted("sub.subsig1")); + } + { + TestVpiHandle vh12 = vpi_scan(vh10); + CHECK_RESULT_NZ(vh12); + p = vpi_get_str(vpiFullName, vh12); + CHECK_RESULT_CSTR(p, TestSimulator::rooted("sub.subsig2")); + } + { + TestVpiHandle vh13 = vpi_scan(vh10); + vh10.freed(); // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle + CHECK_RESULT(vh13, 0); + } return 0; }