Add regression test for vpi_control() return value (issue #1208).

This commit is contained in:
Martin Whitaker 2025-07-08 21:52:13 +01:00
parent 7161dc0ab1
commit a883f2afe6
4 changed files with 64 additions and 0 deletions

49
ivtest/vpi/vpi_control.c Normal file
View File

@ -0,0 +1,49 @@
#include <vpi_user.h>
static PLI_INT32 test_control(PLI_BYTE8 *xx)
{
int ret_val;
int failed = 0;
(void)xx; /* Parameter is not used. */
ret_val = vpi_control(9999);
//vpi_printf("vpi_control(9999) returned %i\n", ret_val);
if (ret_val != 0) failed = 1;
ret_val = vpi_sim_control(9999);
//vpi_printf("vpi_sim_control(9999) returned %i\n", ret_val);
if (ret_val != 0) failed = 1;
ret_val = vpi_control(vpiFinish, 0);
//vpi_printf("vpi_control(vpiFinish, 1) returned %i\n", ret_val);
if (ret_val != 1) failed = 1;
ret_val = vpi_sim_control(vpiFinish, 0);
//vpi_printf("vpi_sim_control(vpiFinish, 1) returned %i\n", ret_val);
if (ret_val != 1) failed = 1;
if (failed) {
vpi_printf("FAILED\n");
} else {
vpi_printf("PASSED\n");
}
return 0;
}
static void register_test_control(void)
{
s_vpi_systf_data tf_data;
tf_data.type = vpiSysTask;
tf_data.tfname = "$test_control";
tf_data.calltf = test_control;
tf_data.compiletf = 0;
tf_data.sizetf = 0;
vpi_register_systf(&tf_data);
}
void (*vlog_startup_routines[])(void) = {
register_test_control,
0
};

9
ivtest/vpi/vpi_control.v Normal file
View File

@ -0,0 +1,9 @@
module main();
initial begin
$test_control;
$display("Error: simulation should have finished");
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,5 @@
Compiling vpi/vpi_control.c...
Making vpi_control.vpi from vpi_control.o...
Unsupported VPI control operation 9999.
Unsupported VPI control operation 9999.
PASSED

View File

@ -141,6 +141,7 @@ value_change_cb1 normal,-g2009 value_change_cb1.c value_change_cb1.gold
value_change_cb2 normal,-g2009 value_change_cb2.c value_change_cb2.gold
value_change_cb3 normal,-g2009 value_change_cb3.c value_change_cb3.gold
value_change_cb4 normal,-g2009 value_change_cb4.c value_change_cb4.gold
vpi_control normal vpi_control.c vpi_control.log
# Add new tests in alphabetic/numeric order. If the test needs
# a compile option or a different log file to run with an older