1# Copyright (c) 2020 Intel Corporation
2# SPDX-License-Identifier: Apache-2.0
3
4if [ -z "$RUNNING_FROM_MAIN_SCRIPT" ]; then
5    echo "Do not run this script directly!"
6    echo "Run $ZEPHYR_BASE/scripts/net/run-sample-tests.sh instead."
7    exit 1
8fi
9
10# First the non-tls version
11start_configuration || return $?
12start_zephyr "$overlay" "-DCONFIG_NET_SAMPLE_SERVE_LARGE_FILE=y" || return $?
13start_docker "/usr/local/bin/http-get-file-test.sh 5" || return $?
14wait_docker
15docker_result=$?
16
17# curl timeout is return code 28. If we get that, zephyr will never
18# return so we can just kill it here
19if [ $docker_result -eq 28 ]; then
20	stop_zephyr
21	result=1
22else
23	sleep 1
24	wait_zephyr
25	result=$?
26fi
27
28stop_docker
29stop_zephyr
30
31if [ $result -ne 0 ] || [ $docker_result -ne 0 ]; then
32    return $result
33fi
34
35# Then the TLS version
36if [ -n "$zephyr_overlay" ]; then
37	overlay="${zephyr_overlay};overlay-tls.conf"
38else
39	overlay="-DOVERLAY_CONFIG=overlay-tls.conf"
40fi
41
42start_configuration || return $?
43start_zephyr "$overlay" "-DCONFIG_NET_SAMPLE_SERVE_LARGE_FILE=y" || return $?
44start_docker "/usr/local/bin/https-get-file-test.sh 5" || return $?
45wait_docker
46docker_result=$?
47
48# curl timeout is return code 28. If we get that, zephyr will never
49# return so we can just kill it here
50if [ $docker_result -eq 28 ]; then
51	stop_zephyr
52	result=1
53else
54	sleep 1
55	wait_zephyr
56	result=$?
57fi
58
59stop_docker
60stop_zephyr
61
62if [ $result -ne 0 ] || [ $docker_result -ne 0 ]; then
63    return $result
64fi
65