2021-02-03 09:53:32 -05:00
#!/bin/bash
2021-07-09 10:34:35 -04:00
NO_FILES_WARNING = "Warning: No input files specified (try \`sv2v --help\`)"
2023-08-20 13:56:03 -04:00
INTERFACE_WARNING = "Warning: Source includes an interface but the output is empty because there are no modules without any interface ports. Please convert interfaces alongside the modules that instantiate them."
2023-04-21 08:29:27 -04:00
PORT_CONN_ATTR_WARNING = "attr.sv:6:11: Warning: Ignored port connection attributes (* foo *)(* bar *)."
2024-12-15 11:29:36 -05:00
DUPLICATE_MODULE_WARNING = "module_dupe_2.sv:2:5: Warning: Redefinition of \"top\". Previously defined at module_dupe_1.sv:2:5."
2021-02-03 09:53:32 -05:00
test_default() {
2023-08-20 13:56:03 -04:00
runAndCapture \
interface.sv module.sv \
package.sv class.sv \
localparam.sv task.sv function .sv
2021-02-03 09:53:32 -05:00
assertTrue "default conversion should succeed" $result
assertNotNull "stdout should not be empty" " $stdout "
assertNull "stderr should be empty" " $stderr "
}
2021-07-09 10:34:35 -04:00
test_no_files() {
runAndCapture
assertTrue "conversion should succeed" $result
assertNull "stdout should be empty" " $stdout "
assertEquals "stderr should should have warning" " $NO_FILES_WARNING " " $stderr "
}
2023-04-21 08:29:27 -04:00
test_port_conn_attr() {
runAndCapture attr.sv
assertTrue "conversion should succeed" $result
assertNotNull "stdout should not be empty" " $stdout "
assertEquals "stderr should should have warning" " $PORT_CONN_ATTR_WARNING " " $stderr "
}
2024-12-15 11:29:36 -05:00
test_duplicate_module() {
runAndCapture module_dupe_1.sv module_dupe_2.sv
assertTrue "conversion should succeed" $result
assertNotNull "stdout should not be empty" " $stdout "
assertEquals "stderr should should have warning" " $DUPLICATE_MODULE_WARNING " " $stderr "
}
2023-08-20 13:56:03 -04:00
no_modules_test() {
file = $1
warning = " $2 "
runAndCapture $file
2021-02-03 09:53:32 -05:00
assertTrue "conversion should succeed" $result
assertNull "stdout should be empty" " $stdout "
2023-08-20 13:56:03 -04:00
assertEquals "stderr should have warning" " $warning " " $stderr "
2021-02-03 09:53:32 -05:00
2023-08-20 13:56:03 -04:00
runAndCapture -v $file
2021-02-03 09:53:32 -05:00
assertTrue "conversion should succeed" $result
assertNotNull "stdout should not be empty" " $stdout "
2023-08-20 13:56:03 -04:00
assertEquals "stderr should have warning" " $warning " " $stderr "
2021-02-03 09:53:32 -05:00
}
test_only_interface() {
2023-08-20 13:56:03 -04:00
no_modules_test interface.sv " $INTERFACE_WARNING "
2021-02-03 09:53:32 -05:00
}
2023-08-20 13:56:03 -04:00
basic_no_modules_test() {
kind = $1
warning = "Warning: Source includes a $kind but no modules. Such elements are elaborated into the modules that use them. Please convert all sources in one invocation."
no_modules_test $kind .sv " $warning "
2021-02-03 09:53:32 -05:00
}
2023-08-20 13:56:03 -04:00
test_only_package() {
basic_no_modules_test package
2021-07-09 10:34:35 -04:00
}
2023-08-20 13:56:03 -04:00
test_only_class() {
basic_no_modules_test class
}
test_only_function() {
basic_no_modules_test function
}
test_only_task() {
basic_no_modules_test task
}
test_only_localparam() {
basic_no_modules_test localparam
2021-07-09 10:34:35 -04:00
}
2021-02-03 09:53:32 -05:00
source ../lib/functions.sh
. shunit2