aboutsummaryrefslogtreecommitdiff
path: root/tests/common.sh
blob: 4469874a96f7fa5dab4b26375c054bcb2ab31768 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

function assemble() {
    # Note: macOS only for now, abstract this out later
    nasm -f macho64 -o output.o output.nasm
    ld -lSystem output.o
}

function assert_exit_status() {
    ./cupcc -c "$1"
    assemble

    set +e
    ./a.out
    res=$?
    if [ $res -ne $2 ]
    then
        echo ""
        echo "----------------------------------" 
        echo "Test failed: expected $2, got $res"
        echo "- Input was:"
        echo "     \`$1\`"
        exit 1
    fi
    set -e
    echo -n "."
}