ping.test 830 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh
  2. . ./testlib.sh
  3. # Skip this test if we aren't root
  4. test "`id -u`" = "0" || exit 77
  5. # Initialize two nodes
  6. $tinc $c1 <<EOF
  7. init foo
  8. set Mode switch
  9. set Interface ping.test
  10. set Port 32573
  11. set Address localhost
  12. EOF
  13. cat >$d1/tinc-up <<EOF
  14. #!/bin/sh
  15. ifconfig \$INTERFACE up
  16. EOF
  17. $tinc $c2 <<EOF
  18. init bar
  19. set Mode switch
  20. set DeviceType multicast
  21. set Device 233.252.0.1 32754
  22. add ConnectTo foo
  23. EOF
  24. # Exchange configuration files
  25. $tinc $c1 export | $tinc $c2 exchange | $tinc $c1 import
  26. # Ensure we have a working multicast route
  27. ip route replace 233.252.0.0/16 dev lo
  28. # Start pong program in background
  29. ./pong 233.252.0.1 32754 10.6.5.5 &
  30. pong=$!
  31. # Start tinc and try to ping
  32. $tinc $c1 start $r1
  33. $tinc $c2 start $r2
  34. sleep 1
  35. ping -r -I ping.test -c3 10.6.5.5
  36. # Clean up
  37. kill $pong
  38. $tinc $c2 stop
  39. $tinc $c1 stop