Tests: Make explicit some IEEE-mandated freeing of VPI handles
This commit is contained in:
parent
a816c2b75e
commit
9bb353c577
|
|
@ -39,8 +39,9 @@ public:
|
||||||
m_handle = h;
|
m_handle = h;
|
||||||
return *this;
|
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;
|
m_free = false;
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,8 @@ int mon_check_props() {
|
||||||
if (value->children.size) {
|
if (value->children.size) {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
TestVpiHandle iter_h = vpi_iterate(vpiMemoryWord, h);
|
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
|
// check size and range
|
||||||
if (int status
|
if (int status
|
||||||
= _mon_check_props(word_h, value->children.size, value->children.direction,
|
= _mon_check_props(word_h, value->children.size, value->children.direction,
|
||||||
|
|
@ -188,6 +189,7 @@ int mon_check_props() {
|
||||||
return status;
|
return status;
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
|
word_h.freed(); // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle
|
||||||
CHECK_RESULT(size, value->attributes.size);
|
CHECK_RESULT(size, value->attributes.size);
|
||||||
}
|
}
|
||||||
value++;
|
value++;
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,6 @@ void modDump(const TestVpiHandle& it, int n) {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
int mon_check() {
|
int mon_check() {
|
||||||
TestVpiHandle it = vpi_iterate(vpiModule, NULL);
|
TestVpiHandle it = vpi_iterate(vpiModule, NULL);
|
||||||
#ifdef IS_ICARUS
|
|
||||||
// Icarus segfaults when some VPI handles are freed
|
|
||||||
it.nofree();
|
|
||||||
#endif
|
|
||||||
CHECK_RESULT_NZ(it);
|
CHECK_RESULT_NZ(it);
|
||||||
// Uncomment to see what other simulators return
|
// Uncomment to see what other simulators return
|
||||||
// modDump(it, 0);
|
// modDump(it, 0);
|
||||||
|
|
@ -98,8 +94,9 @@ int mon_check() {
|
||||||
CHECK_RESULT_NZ(t_name);
|
CHECK_RESULT_NZ(t_name);
|
||||||
}
|
}
|
||||||
CHECK_RESULT_CSTR(t_name, "t");
|
CHECK_RESULT_CSTR(t_name, "t");
|
||||||
TestVpiHandle topmod_done = (vpi_scan(it));
|
TestVpiHandle topmod_done_should_be_0 = (vpi_scan(it));
|
||||||
CHECK_RESULT_Z(topmod_done);
|
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);
|
TestVpiHandle it2 = vpi_iterate(vpiModule, topmod);
|
||||||
CHECK_RESULT_NZ(it2);
|
CHECK_RESULT_NZ(it2);
|
||||||
|
|
|
||||||
|
|
@ -321,21 +321,25 @@ int _mon_check_varlist() {
|
||||||
CHECK_RESULT_NZ(vh2);
|
CHECK_RESULT_NZ(vh2);
|
||||||
|
|
||||||
TestVpiHandle vh10 = vpi_iterate(vpiReg, vh2);
|
TestVpiHandle vh10 = vpi_iterate(vpiReg, vh2);
|
||||||
CHECK_RESULT_NZ(vh10.nofree());
|
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);
|
|
||||||
CHECK_RESULT(vh13, 0);
|
|
||||||
|
|
||||||
|
{
|
||||||
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue