1#!/bin/sh
2
3# travis-log-failure.sh
4#
5# Copyright The Mbed TLS Contributors
6# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7#
8# Purpose
9#
10# List the server and client logs on failed ssl-opt.sh and compat.sh tests.
11# This script is used to make the logs show up in the Travis test results.
12#
13# Some of the logs can be very long: this means usually a couple of megabytes
14# but it can be much more. For example, the client log of test 273 in ssl-opt.sh
15# is more than 630 Megabytes long.
16
17if [ -d include/mbedtls ]; then :; else
18    echo "$0: must be run from root" >&2
19    exit 1
20fi
21
22FILES="o-srv-*.log o-cli-*.log c-srv-*.log c-cli-*.log o-pxy-*.log"
23MAX_LOG_SIZE=1048576
24
25for PATTERN in $FILES; do
26    for LOG in $( ls tests/$PATTERN 2>/dev/null ); do
27        echo
28        echo "****** BEGIN file: $LOG ******"
29        echo
30        tail -c $MAX_LOG_SIZE $LOG
31        echo "****** END file: $LOG ******"
32        echo
33        rm $LOG
34    done
35done
36