#!/bin/sh
#
# This file is part of libunwind.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

test_dir="$(dirname $0)"

: ${LIBUNWIND:=/usr/local/lib/libunwind.so}
: ${LIBUNWIND_GENERIC:=/usr/local/lib/libunwind-x86_64.so}

count=0
printf "TAP version 14\n"
for t in test-proc-info test-static-link  test-strerror Gtest-bt Ltest-bt  Gtest-init Ltest-init  Gtest-concurrent  Ltest-concurrent  Gtest-trace Ltest-trace  Ltest-mem-validate  test-async-sig  test-flush-cache  test-init-remote test-mem  test-reg-state  Ltest-varargs  Ltest-nomalloc  Ltest-nocalloc Lrs-race Ltest-init-local-signal Gtest-exc  Ltest-exc  Gtest-resume-sig  Ltest-resume-sig  Gtest-resume-sig-rt  Ltest-resume-sig-rt  test-ptrace test-setjmp      Gx64-test-dwarf-expressions  Lx64-test-dwarf-expressions  x64-unwind-badjmp-signal-frame   check-namespace.sh run-ptrace-mapper run-ptrace-misc     ; do
    "$test_dir/$t" >$t.out 2>$t.err
    status=$?
    if [ $status = 77 ]; then
        printf "%d ok - %s # SKIP\n" $count "$t"
    elif [ $status = 0 ]; then
        printf "%d ok - %s\n" $count "$t"
    elif (echo          Garm64-test-sve-signal  Larm64-test-sve-signal | grep -Fqw "$t"); then
        printf "%d not ok - %s # TODO\n" $count "$t"
    else
        printf "%d not ok - %s returned %d\n" $count "$t" $status
    fi
    count=$(expr $count + 1)
done
printf "1..%d\n" $count
