1*84e872a0SLloyd Pique#!/bin/sh 2*84e872a0SLloyd Pique 3*84e872a0SLloyd Piqueecho "srcdir: $srcdir" 4*84e872a0SLloyd Piqueecho "scanner: $WAYLAND_SCANNER" 5*84e872a0SLloyd Piqueecho "test_data_dir: $TEST_DATA_DIR" 6*84e872a0SLloyd Piqueecho "test_output_dir: $TEST_OUTPUT_DIR" 7*84e872a0SLloyd Piqueecho "pwd: $PWD" 8*84e872a0SLloyd Piqueecho "sed: $SED" 9*84e872a0SLloyd Pique 10*84e872a0SLloyd PiqueRETCODE=0 11*84e872a0SLloyd Pique 12*84e872a0SLloyd Piquehard_fail() { 13*84e872a0SLloyd Pique echo "$@" "ERROR" 14*84e872a0SLloyd Pique exit 99 15*84e872a0SLloyd Pique} 16*84e872a0SLloyd Pique 17*84e872a0SLloyd Piquefail() { 18*84e872a0SLloyd Pique echo "$@" "FAIL" 19*84e872a0SLloyd Pique RETCODE=1 20*84e872a0SLloyd Pique} 21*84e872a0SLloyd Pique 22*84e872a0SLloyd Piquemkdir -p "$TEST_OUTPUT_DIR" || hard_fail "setup" 23*84e872a0SLloyd Pique 24*84e872a0SLloyd Piquegenerate_and_compare() { 25*84e872a0SLloyd Pique echo 26*84e872a0SLloyd Pique echo "Testing $1 generation: $2 -> $3" 27*84e872a0SLloyd Pique 28*84e872a0SLloyd Pique "$WAYLAND_SCANNER" $1 < "$TEST_DATA_DIR/$2" > "$TEST_OUTPUT_DIR/$3" || \ 29*84e872a0SLloyd Pique hard_fail "$2 -> $3" 30*84e872a0SLloyd Pique 31*84e872a0SLloyd Pique "$SED" -i -e 's/Generated by wayland-scanner [0-9.]*/SCANNER TEST/' \ 32*84e872a0SLloyd Pique "$TEST_OUTPUT_DIR/$3" || hard_fail "$2 -> $3" 33*84e872a0SLloyd Pique 34*84e872a0SLloyd Pique diff -q "$TEST_DATA_DIR/$3" "$TEST_OUTPUT_DIR/$3" && \ 35*84e872a0SLloyd Pique echo "$2 -> $3 PASS" || \ 36*84e872a0SLloyd Pique fail "$2 -> $3" 37*84e872a0SLloyd Pique} 38*84e872a0SLloyd Pique 39*84e872a0SLloyd Piqueverify_error() { 40*84e872a0SLloyd Pique echo 41*84e872a0SLloyd Pique echo "Checking that reading $1 gives an error on line $3" 42*84e872a0SLloyd Pique 43*84e872a0SLloyd Pique [ -f "$TEST_DATA_DIR/$1" ] || hard_fail "$1 not present" 44*84e872a0SLloyd Pique 45*84e872a0SLloyd Pique # Confirm failure error code 46*84e872a0SLloyd Pique "$WAYLAND_SCANNER" server-header < "$TEST_DATA_DIR/$1" >/dev/null 2>"$TEST_OUTPUT_DIR/$2" && \ 47*84e872a0SLloyd Pique fail "$1 return code check" 48*84e872a0SLloyd Pique 49*84e872a0SLloyd Pique # Verify that an error is produced at the correct line 50*84e872a0SLloyd Pique grep -q "<stdin>:$3: error:" "$TEST_OUTPUT_DIR/$2" && echo "$1 PASS" || fail "$1 line number check" 51*84e872a0SLloyd Pique} 52*84e872a0SLloyd Pique 53*84e872a0SLloyd Piquegenerate_and_compare "code" "example.xml" "example-code.c" 54*84e872a0SLloyd Piquegenerate_and_compare "client-header" "example.xml" "example-client.h" 55*84e872a0SLloyd Piquegenerate_and_compare "server-header" "example.xml" "example-server.h" 56*84e872a0SLloyd Pique 57*84e872a0SLloyd Piquegenerate_and_compare "code" "small.xml" "small-code.c" 58*84e872a0SLloyd Piquegenerate_and_compare "client-header" "small.xml" "small-client.h" 59*84e872a0SLloyd Piquegenerate_and_compare "server-header" "small.xml" "small-server.h" 60*84e872a0SLloyd Pique 61*84e872a0SLloyd Piquegenerate_and_compare "-c code" "small.xml" "small-code-core.c" 62*84e872a0SLloyd Piquegenerate_and_compare "-c client-header" "small.xml" "small-client-core.h" 63*84e872a0SLloyd Piquegenerate_and_compare "-c server-header" "small.xml" "small-server-core.h" 64*84e872a0SLloyd Pique 65*84e872a0SLloyd Pique# The existing "code" must produce result identical to "public-code" 66*84e872a0SLloyd Piquegenerate_and_compare "code" "small.xml" "small-code.c" 67*84e872a0SLloyd Piquegenerate_and_compare "public-code" "small.xml" "small-code.c" 68*84e872a0SLloyd Piquegenerate_and_compare "private-code" "small.xml" "small-private-code.c" 69*84e872a0SLloyd Pique 70*84e872a0SLloyd Piqueverify_error "bad-identifier-arg.xml" "bad-identifier-arg.log" 7 71*84e872a0SLloyd Piqueverify_error "bad-identifier-entry.xml" "bad-identifier-entry.log" 8 72*84e872a0SLloyd Piqueverify_error "bad-identifier-enum.xml" "bad-identifier-enum.log" 6 73*84e872a0SLloyd Piqueverify_error "bad-identifier-event.xml" "bad-identifier-event.log" 6 74*84e872a0SLloyd Piqueverify_error "bad-identifier-interface.xml" "bad-identifier-interface.log" 3 75*84e872a0SLloyd Piqueverify_error "bad-identifier-protocol.xml" "bad-identifier-protocol.log" 2 76*84e872a0SLloyd Piqueverify_error "bad-identifier-request.xml" "bad-identifier-request.log" 6 77*84e872a0SLloyd Pique 78*84e872a0SLloyd Piqueexit $RETCODE 79