#!/bin/sh

# Checking if the service does't refuse to start if binding fails for some addresses:ports.
# Expected logs:
# LOG6[ui]: Service [server] (FD=7) bound to 127.0.0.1:4433
# LOG5[ui]: Binding service [server] to 127.0.0.1:4433: Address already in use (98)

. $(dirname $0)/../test_library

start() {
  ../../src/stunnel -fd 0 <<EOT
  debug = debug
  syslog = no
  pid = ${result_path}/stunnel.pid
  output = ${result_path}/stunnel.log

  [client]
  client = yes
  accept = 127.0.0.1:${http1}
  connect = 127.0.0.1:${https1}

  [server]
  accept = 127.0.0.1:${https1}
  accept = 127.0.0.1:${https1}
  connect = 127.0.0.1:${http_nc}
  cert = ${script_path}/certs/server_cert.pem
EOT
}

test_log_for "022_bind" "success" "0" "$1" "$2" "$3" 2>> "stderr.log"
exit $?
