run.sh 2.24 KB
Newer Older
1 2
#!/bin/bash

3
NO_FILES_WARNING="Warning: No input files specified (try \`sv2v --help\`)"
4
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."
5
PORT_CONN_ATTR_WARNING="attr.sv:6:11: Warning: Ignored port connection attributes (* foo *)(* bar *)."
6 7

test_default() {
8 9 10 11
    runAndCapture \
        interface.sv module.sv \
        package.sv class.sv \
        localparam.sv task.sv function.sv
12 13 14 15 16
    assertTrue "default conversion should succeed" $result
    assertNotNull "stdout should not be empty" "$stdout"
    assertNull "stderr should be empty" "$stderr"
}

17 18 19 20 21 22 23
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"
}

24 25 26 27 28 29 30
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"
}

31 32 33 34 35
no_modules_test() {
    file=$1
    warning="$2"

    runAndCapture $file
36 37
    assertTrue "conversion should succeed" $result
    assertNull "stdout should be empty" "$stdout"
38
    assertEquals "stderr should have warning" "$warning" "$stderr"
39

40
    runAndCapture -v $file
41 42
    assertTrue "conversion should succeed" $result
    assertNotNull "stdout should not be empty" "$stdout"
43
    assertEquals "stderr should have warning" "$warning" "$stderr"
44 45 46
}

test_only_interface() {
47
    no_modules_test interface.sv "$INTERFACE_WARNING"
48 49
}

50 51 52 53
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"
54 55
}

56 57
test_only_package() {
    basic_no_modules_test package
58 59
}

60 61 62 63 64 65 66 67 68 69 70 71 72 73
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
74 75
}

76 77 78
source ../lib/functions.sh

. shunit2