#!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (c) 2020 Petr Vorel # Copyright (c) Köry Maincent 2020 # Copyright (c) Manoj Iyer 2003 # Copyright (c) Robbie Williamson 2001 # Copyright (c) International Business Machines Corp., 2000 TST_TESTFUNC="do_test" TST_NEEDS_CMDS="awk grep host hostname tail" . tst_net.sh do_test() { local lhost="${HOSTNAME:-$(hostname)}" local addr tst_res TINFO "test basic functionality of the host command" tst_res TINFO "lhost: $lhost" if addr=$(host $lhost); then addr=$(echo "$addr" | grep address | tail -1 | awk '{print $NF}') if [ -z "$addr" ]; then tst_brk TFAIL "empty address" fi EXPECT_PASS host $addr \>/dev/null else tst_brk TFAIL "host $lhost on local machine failed" fi } tst_run