1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2020 Petr Vorel <pvorel@suse.cz> 4# Copyright (c) Köry Maincent <kory.maincent@bootlin.com> 2020 5# Copyright (c) Manoj Iyer <manjo@mail.utexas.edu> 2003 6# Copyright (c) Robbie Williamson <robbiew@us.ibm.com> 2001 7# Copyright (c) International Business Machines Corp., 2000 8 9TST_TESTFUNC="do_test" 10TST_NEEDS_CMDS="awk grep host hostname tail" 11 12. tst_net.sh 13 14do_test() 15{ 16 local lhost="${HOSTNAME:-$(hostname)}" 17 local addr 18 19 tst_res TINFO "test basic functionality of the host command" 20 tst_res TINFO "lhost: $lhost" 21 22 if addr=$(host $lhost); then 23 addr=$(echo "$addr" | grep address | tail -1 | awk '{print $NF}') 24 if [ -z "$addr" ]; then 25 tst_brk TFAIL "empty address" 26 fi 27 EXPECT_PASS host $addr \>/dev/null 28 else 29 tst_brk TFAIL "host $lhost on local machine failed" 30 fi 31} 32 33tst_run 34