host01.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. #
  3. # Copyright (c) International Business Machines Corp., 2000
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13. # the GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. #
  19. #
  20. #
  21. # FILE : host
  22. #
  23. # PURPOSE: To test the basic functionality of the `host` command.
  24. #
  25. # SETUP: If "RHOST" is not exported, then the local hostname is used.
  26. #
  27. # HISTORY:
  28. # 06/06/03 Manoj Iyer manjo@mail.utexas.edu
  29. # - Modified to use LTP tests APIs
  30. # 03/01 Robbie Williamson (robbiew@us.ibm.com)
  31. # -Ported
  32. #
  33. #
  34. #-----------------------------------------------------------------------
  35. do_setup()
  36. {
  37. NUMLOOPS=${NUMLOOPS:-1}
  38. SLEEPTIME=${SLEEPTIME:-0}
  39. tst_setup
  40. exists awk host hostname
  41. RHOST=${RHOST:-`hostname`}
  42. }
  43. #-----------------------------------------------------------------------
  44. #
  45. # FUNCTION: do_test
  46. #
  47. #-----------------------------------------------------------------------
  48. do_test()
  49. {
  50. tst_resm TINFO "test basic functionality of the \`$TC' command."
  51. while [ $TST_COUNT -lt $NUMLOOPS ]; do
  52. if rhost_addr=$(host $RHOST); then
  53. rhost_addr=$(echo "$rhost_addr" | awk -F, '{print $NF}') >/dev/null 2>&1
  54. if ! host $rhost_addr >/dev/null 2>&1; then
  55. end_testcase "reverse lookup with host failed"
  56. fi
  57. else
  58. end_testcase "host $RHOST on local machine failed"
  59. fi
  60. incr_tst_count
  61. sleep $SLEEPTIME
  62. done
  63. }
  64. #-----------------------------------------------------------------------
  65. # FUNCTION: MAIN
  66. #-----------------------------------------------------------------------
  67. . net_cmdlib.sh
  68. read_opts $*
  69. do_setup
  70. do_test
  71. end_testcase