Tests: Memory clean up in tests (#2645)

This patch normalizes what the tests do before exiting. After this
change each test should call final on the top module and explicitly
free the top module object before exiting.
This commit is contained in:
Tomasz Gorochowik 2020-11-17 12:37:55 +01:00 committed by GitHub
parent 1e7c61b23e
commit 5b3717b369
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 59 additions and 1 deletions

View File

@ -50,4 +50,7 @@ int main(int argc, char* argv[]) {
}
topp->check = 1;
clockit(0, 0);
topp->final();
VL_DO_DANGLING(delete topp, topp);
}

View File

@ -673,6 +673,7 @@ int main() {
// Tidy up
dut->final();
VL_DO_DANGLING(delete dut, dut);
cout << "*-* All Finished *-*" << endl;
}

View File

@ -27,6 +27,7 @@ int main(int argc, char* argv[]) {
Verilated::debug(0);
topp->eval();
VL_DO_DANGLING(delete topp, topp);
return 1;
}
int dpii_task() {

View File

@ -44,5 +44,8 @@ int main(int argc, char* argv[]) {
topp->eval();
dpix_task(); // Missing svSetScope
topp->final();
VL_DO_DANGLING(delete topp, topp);
return 1;
}

View File

@ -51,5 +51,8 @@ int main(int argc, char* argv[]) {
} else {
vl_fatal(__FILE__, __LINE__, "top", "Unexpected results\n");
}
topp->final();
VL_DO_DANGLING(delete topp, topp);
return 0;
}

View File

@ -24,4 +24,7 @@ int main(int argc, char* argv[]) {
for (int i = 0; i < 10; i++) { //
topp->eval();
}
topp->final();
VL_DO_DANGLING(delete topp, topp);
}

View File

@ -29,6 +29,7 @@ int main(int argc, char* argv[]) {
if (!gotit) { vl_fatal(__FILE__, __LINE__, "dut", "Never got call to myfunction"); }
topp->final();
VL_DO_DANGLING(delete topp, topp);
return 0;
}

View File

@ -24,5 +24,7 @@ int main(int argc, char* argv[]) {
if (topp->Rand != 0xfeed0fad) {
vl_fatal(__FILE__, __LINE__, "top", "Unexpected value for Rand output\n");
}
topp->final();
VL_DO_DANGLING(delete topp, topp);
printf("*-* All Finished *-*\n");
}

View File

@ -44,6 +44,9 @@ int main(int argc, char* argv[]) {
}
}
sim->final();
VL_DO_DANGLING(delete sim, sim);
if (errs) {
vl_stop(__FILE__, __LINE__, "TOP-cpp");
exit(10);

View File

@ -78,6 +78,9 @@ int main()
for (int j = 0; j < 5; j++) check("o345", READ(o345[i][j]), i * 8 + j);
}
tb->final();
VL_DO_DANGLING(delete tb, tb);
if (pass) {
VL_PRINTF("*-* All Finished *-*\n");
} else {

View File

@ -20,6 +20,9 @@ int main()
Verilated::debug(0);
tb = new VM_PREFIX("tb");
tb->final();
VL_DO_DANGLING(delete tb, tb);
// Just a constructor test
VL_PRINTF("*-* All Finished *-*\n");
return 0;

View File

@ -55,5 +55,8 @@ int main(int argc, char* argv[]) {
for (i = 0; i < 100; i++) //
StepSim(sim, random() % 3, random() % 2, random() % 2, random() % 3);
sim->final();
VL_DO_DANGLING(delete sim, sim);
printf("*-* All Finished *-*\n");
}

View File

@ -39,5 +39,9 @@ int main(int argc, char* argv[]) {
CHECK_RESULT(topp->b__02Eout, 1);
CHECK_RESULT(topp->uniq_out, 0);
}
topp->final();
VL_DO_DANGLING(delete topp, topp);
printf("*-* All Finished *-*\n");
}

View File

@ -56,5 +56,9 @@ int main() {
}
vcd->close();
vcore->final();
VL_DO_DANGLING(delete vcore, vcore);
printf("*-* All Finished *-*\n");
}

View File

@ -38,12 +38,13 @@ int main(int argc, char* argv[]) {
topp->eval();
check(topp->y, 0x3c00000000ULL);
topp->final();
if (!fail) {
VL_PRINTF("*-* All Finished *-*\n");
topp->final();
} else {
vl_fatal(__FILE__, __LINE__, "top", "Unexpected results\n");
}
VL_DO_DANGLING(delete topp, topp);
return 0;
}

View File

@ -26,4 +26,7 @@ int main(int argc, char* argv[]) {
for (int i = 0; i < 10; i++) { //
topp->eval();
}
topp->final();
VL_DO_DANGLING(delete topp, topp);
}

View File

@ -24,5 +24,6 @@ int sc_main(int argc, char* argv[]) {
} else {
vl_fatal(__FILE__, __LINE__, "tb", "Unexpected results\n");
}
VL_DO_DANGLING(delete tb, tb);
return 0;
}

View File

@ -161,6 +161,8 @@ int main(int argc, char** argv, char** env) {
tfp->close();
top->final();
VL_DO_DANGLING(delete top, top);
VL_PRINTF("*-* All Finished *-*\n");
return 0;

View File

@ -50,6 +50,7 @@ int main(int argc, char** argv, char** env) {
CHECK_RESULT(VL_TIME_STR_CONVERT(0), 0);
top->final();
VL_DO_DANGLING(delete top, top);
printf("*-* All Finished *-*\n");
return 0;
}

View File

@ -19,4 +19,5 @@ int main() {
tb->eval();
tb->final();
VL_DO_DANGLING(delete tb, tb);
}

View File

@ -58,6 +58,7 @@ int main(int argc, char** argv, char** env) {
}
tfp->close();
top->final();
VL_DO_DANGLING(delete top, top);
printf("*-* All Finished *-*\n");
return 0;
}

View File

@ -46,6 +46,7 @@ int main(int argc, char** argv, char** env) {
}
tfp->close();
top->final();
VL_DO_DANGLING(delete top, top);
printf("*-* All Finished *-*\n");
return 0;
}

View File

@ -46,6 +46,7 @@ int main(int argc, char** argv, char** env) {
}
tfp->close();
top->final();
VL_DO_DANGLING(delete top, top);
printf("*-* All Finished *-*\n");
return 0;
}

View File

@ -54,5 +54,6 @@ int main() {
} else {
vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from tristate test\n");
}
VL_DO_DANGLING(delete tb, tb);
return 0;
}

View File

@ -54,5 +54,6 @@ int main() {
} else {
vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from inout test\n");
}
VL_DO_DANGLING(delete tb, tb);
return 0;
}

View File

@ -44,5 +44,6 @@ int main() {
} else {
vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from t_tri_inz\n");
}
VL_DO_DANGLING(delete tb, tb);
return 0;
}

View File

@ -63,5 +63,6 @@ int main() {
} else {
vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from pullup test\n");
}
VL_DO_DANGLING(delete tb, tb);
return 0;
}

View File

@ -66,5 +66,6 @@ int main() {
} else {
vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from t_tri_select\n");
}
VL_DO_DANGLING(delete tb, tb);
return 0;
}

View File

@ -15,6 +15,7 @@ int main() {
VL_PRINTF("*-* All Finished *-*\n");
tb->final();
VL_DO_DANGLING(delete tb, tb);
return 0;
}
@ -23,5 +24,6 @@ int sc_main(int argc, char* argv[]) {
VL_PRINTF("*-* All Finished *-*\n");
tb->final();
VL_DO_DANGLING(delete tb, tb);
return 0;
}

View File

@ -12,5 +12,6 @@ int sc_main(int argc, char* argv[]) {
VL_PRINTF("*-* All Finished *-*\n");
tb->final();
VL_DO_DANGLING(delete tb, tb);
return 0;
}

View File

@ -48,6 +48,7 @@ int main(int argc, const char** argv) {
exit(1);
}
VL_DO_DANGLING(delete top, top);
std::cout << "*-* All Finished *-*" << std::endl;
return 0;
}