netstat01.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 `netstat` command.
  24. #
  25. # HISTORY:
  26. # 06/06/03 Manoj Iyer manjo@mail.utexas.edu
  27. # - Modified test to use LTP harness API
  28. # - Fixed bugs.
  29. # 03/01 Robbie Williamson (robbiew@us.ibm.com)
  30. # -Ported
  31. #
  32. #
  33. #-----------------------------------------------------------------------
  34. do_setup()
  35. {
  36. NUMLOOPS=${NUMLOOPS:-1}
  37. SLEEPTIME=${SLEEPTIME:-0}
  38. tst_setup
  39. exists netstat
  40. }
  41. #-------------------------------------------------------------------------
  42. # FUNCTION: do_test
  43. # PURPOSE:
  44. # To loop for LOOPCOUNT times
  45. # If MAXCOUNT is "-1" the "while"
  46. # loop will execute until terminated by "intr" signal.
  47. # INPUT: None.
  48. # OUTPUT: Informational messages are logged into the run log.
  49. #
  50. #-----------------------------------------------------------------------
  51. do_test() {
  52. while [ $TST_COUNT -le $NUMLOOPS ]; do
  53. for flag in "-s" "-rn" "-i" "-gn" "-apn"; do
  54. if ! netstat $flag 1>/dev/null 2>&1; then
  55. end_testcase "netstat $flag failed"
  56. fi
  57. done
  58. incr_tst_count
  59. sleep $SLEEPTIME
  60. done
  61. }
  62. #-----------------------------------------------------------------------
  63. #
  64. # FUNCTION: MAIN
  65. # PURPOSE: To invoke functions that perform the tasks as described in
  66. # the design in the prolog above.
  67. # INPUT: See SETUP in the prolog above.
  68. # OUTPUT: Logged run results written to testcase run log
  69. #
  70. #-----------------------------------------------------------------------
  71. . net_cmdlib.sh
  72. read_opts $*
  73. do_setup
  74. do_test
  75. end_testcase