# Reproduce PR 50208, "iscsi-target prints scary messages"

from __future__ import print_function

from bracket import make_sh_test_op

def op():
    return make_sh_test_op('iscsi',
'''
set -ex
# The initiator doesn't work without a hostname
hostname test.gson.org
# Start target
iscsi-target
# Wait for target to start
sleep 5
# Start initiator per example in iscsictl(8)
modload iscsi
modstat iscsi
iscsid
iscsictl add_send_target -a localhost
iscsictl refresh_targets
iscsictl list_targets
iscsictl login -P 2
iscsictl list_sessions
# Wait for any new messages to appear in /var/log/messages
sleep 5
! grep 'iscsi.*ERROR' /var/log/messages
''')
