UDPSocket_2.test 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. %description:
  2. Tests UDPSocket::bind() can not be called more than once on a socket.
  3. %#--------------------------------------------------------------------------------------------------------------
  4. %file: TestApp.cc
  5. #include "inet/transportlayer/contract/udp/UDPSocket.h"
  6. #include "inet/transportlayer/contract/udp/UDPControlInfo_m.h"
  7. using namespace inet;
  8. namespace UDPSocket_2 {
  9. class TestApp : public cSimpleModule
  10. {
  11. public:
  12. TestApp() : cSimpleModule(65536) {}
  13. protected:
  14. virtual void activity();
  15. };
  16. Define_Module(TestApp);
  17. void TestApp::activity()
  18. {
  19. UDPSocket s;
  20. s.setOutputGate(gate("udpOut"));
  21. s.bind(100);
  22. s.bind(200); // will fail
  23. }
  24. }
  25. %#--------------------------------------------------------------------------------------------------------------
  26. %file: TestApp.ned
  27. import inet.applications.contract.IUDPApp;
  28. simple TestApp like IUDPApp
  29. {
  30. gates:
  31. input udpIn;
  32. output udpOut;
  33. }
  34. %#--------------------------------------------------------------------------------------------------------------
  35. %inifile: omnetpp.ini
  36. [General]
  37. ned-path = .;../../../../src;../../lib
  38. network = SimpleTestNetwork
  39. cmdenv-express-mode = false
  40. cmdenv-event-banner-details = true
  41. #omnetpp 5.0 - 5.1 compatibility:
  42. eventlog-file = "${resultdir}/${configname}-${runnumber}.elog"
  43. output-scalar-file = "${resultdir}/${configname}-${runnumber}.sca"
  44. output-vector-file = "${resultdir}/${configname}-${runnumber}.vec"
  45. snapshot-file = "${resultdir}/${configname}-${runnumber}.sna"
  46. **.client.numUdpApps = 1
  47. **.client.udpApp[0].typename = "TestApp"
  48. %exitcode: 1
  49. %#--------------------------------------------------------------------------------------------------------------
  50. %postrun-command: grep "<!>" test.* > test_err.out || true
  51. %#--------------------------------------------------------------------------------------------------------------
  52. %contains-regex: test_err.out
  53. (<!> Error in module \(inet::UDP\) SimpleTestNetwork\.client\.udp \(id=\d+\) at event \#\d+, t=0: bind: socket is already bound \(sockId=\d+\).)|(<!> Error: bind: socket is already bound \(sockId=\d+\) -- in module \(inet::UDP\) SimpleTestNetwork\.client\.udp \(id=\d+\), at t=0s, event \#\d+)
  54. %#--------------------------------------------------------------------------------------------------------------
  55. %# %not-contains: stdout
  56. %# undisposed object:
  57. %# %not-contains: stdout
  58. %# -- check module destructor
  59. %#--------------------------------------------------------------------------------------------------------------