Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log on TCP/UDP UT failure and fix UDP UT #2705

Merged
merged 5 commits into from
Apr 29, 2024

Conversation

JohanBertrand
Copy link
Contributor

Related Issue(s)
Has Unit Tests (y/n)
Documentation Included (y/n)

Change Description

  • Add log on stdout when an error happens in the TCP and UDP UT.
  • Fix the following case, where the UDP UT would select twice the same port and fail binding later:
[ RUN      ] Nominal.BasicReceiveThread
Setup to send and receive udp to 127.0.0.1:60296
UDP socket open error: Address already in use
Port1: 60296
Port2: 60296
/home/fprime/Drv/Udp/test/ut/UdpTester.cpp:77: Failure
Expected equality of these values:
  status2
    Which is: -9
  Drv::SOCK_SUCCESS
    Which is: 0
[  FAILED  ] Nominal.BasicReceiveThread (10 ms)
[ RUN      ] Reconnect.MultiMessaging
Setup to send and receive udp to 127.0.0.1:6335
UDP socket open error: Address already in use
Port1: 6335
Port2: 6335
/home/fprime/Drv/Udp/test/ut/UdpTester.cpp:77: Failure
Expected equality of these values:
  status2
    Which is: -9
  Drv::SOCK_SUCCESS
    Which is: 0
[  FAILED  ] Reconnect.MultiMessaging (0 ms)

Rationale

TCP and UDP UT are often failing, and this will give more understanding of the reason of those failures.

Copy link
Collaborator

@LeStarch LeStarch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is cleaner to use the messaging built into GTest.

ASSERT...() << "Custom error message here"

As this allows GTest to colocate the error with the assertion failure.

Thoughts?

{
printf("TCP server startup error: %s\n", strerror(errno));
printf("Port: %u\n", port);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a note, this could be done with the following on line 44:

ASSERT_EQ(serverStat, SOCK_SUCCESS) <<  "TCP server startup error:" << strerror(errno) << " Port:" << port;

Copy link
Contributor Author

@JohanBertrand JohanBertrand Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I made the changes.

I can see that it is currently done both ways in the unit tests. I might try to make it uniform in the future.

@LeStarch LeStarch merged commit 0d4e909 into nasa:devel Apr 29, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants