PageRenderTime 29ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/usr/src/test/util-tests/tests/dladm/show-overlay-exit.ksh

https://github.com/illumos/illumos-gate
Korn Shell | 83 lines | 52 code | 16 blank | 15 comment | 7 complexity | 528f92ae9340a0f03a4333551a7dcc19 MD5 | raw file
  1. #!/bin/ksh
  2. #
  3. # This file and its contents are supplied under the terms of the
  4. # Common Development and Distribution License ("CDDL"), version 1.0.
  5. # You may only use this file in accordance with the terms of version
  6. # 1.0 of the CDDL.
  7. #
  8. # A full copy of the text of the CDDL should have accompanied this
  9. # source. A copy of the CDDL is also available via the Internet at
  10. # http://www.illumos.org/license/CDDL.
  11. #
  12. #
  13. # Copyright (c) 2017, Joyent, Inc.
  14. # Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
  15. #
  16. soe_arg0="$(basename $0)"
  17. soe_overlay="soe_overlay$$"
  18. soe_dummy_ip="169.254.0.0"
  19. soe_port="2000"
  20. soe_vnetid=20
  21. soe_encap="vxlan"
  22. soe_search="direct"
  23. soe_etherstub="soe_teststub$$"
  24. function fatal
  25. {
  26. typeset msg="$*"
  27. [[ -z "$msg" ]] && msg="failed"
  28. echo "TEST_FAIL: $vt_arg0: $msg" >&2
  29. dladm delete-overlay $soe_overlay
  30. dladm delete-etherstub $soe_etherstub
  31. exit 1
  32. }
  33. function setup
  34. {
  35. dladm create-overlay -t -v $soe_vnetid -e $soe_encap -s $soe_search \
  36. -p vxlan/listen_ip=$soe_dummy_ip -p direct/dest_ip=$soe_dummy_ip \
  37. -p direct/dest_port=$soe_port $soe_overlay || \
  38. fatal "failed to create overlay"
  39. dladm create-etherstub $soe_etherstub || \
  40. fatal "failed to create etherstub"
  41. }
  42. function cleanup
  43. {
  44. dladm delete-overlay $soe_overlay || \
  45. fatal "failed to remove overlay"
  46. dladm delete-etherstub $soe_etherstub || \
  47. fatal "failed to remove etherstub"
  48. }
  49. function runtest
  50. {
  51. dladm show-overlay $* > /dev/null 2>&1
  52. }
  53. function epass
  54. {
  55. runtest $* || fatal "show-overlay=$* failed, expected success\n"
  56. }
  57. function efail
  58. {
  59. runtest $* && fatal "show-overlay=$* succeeded, expected failure\n"
  60. }
  61. setup
  62. epass $soe_overlay
  63. efail $soe_etherstub
  64. efail $soe_etherstub $soe_overlay
  65. efail $soe_overlay $soe_etherstub
  66. cleanup
  67. print "TEST PASS: $soe_arg0"