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

UT coverage to 95%, code improve and minor fix #34

Merged
merged 3 commits into from
May 13, 2023

Conversation

jcaiMR
Copy link
Contributor

@jcaiMR jcaiMR commented Mar 17, 2023

Description:

  1. Add gtest/gmock based gmock-global, Improve UT coverage from 80% to 95%
  2. code cleanup, remove unused code
    a) remove unused functions handleSwssNotification(), stopSwssNotificationPoll()
    b) change file name to GUN style, keep same style with the other files
  3. code improvement based on the findings in UT
    a) DHCPv6Msg::MarshalBinary/RelayMsg::MarshalBinary add protection for super frame, case for new packet length > 65536
    b) loop_relay() event base creation failure will call exit(EXIT_FAILURE)
    c) shutdown() name changed to shutdown_relay() as name duplication with glibc library.
  4. change PR target from 60% to 90%
  5. Makefile changes due to git clone MIT license based library, gmock-global

How I test it

  1. make test
  2. load new image to DUT, run test_dhcpv6_relay

image

@jcaiMR jcaiMR changed the title global mock, ut coverage to 95%, code cleanup and refine Improve UT coverage to 95% Mar 17, 2023
@jcaiMR jcaiMR force-pushed the dev/dhcprelay_ut_improve_new branch from 3bd2891 to c98cdff Compare March 17, 2023 18:05
@jcaiMR jcaiMR marked this pull request as ready for review March 17, 2023 18:16
@jcaiMR jcaiMR requested review from kellyyeh and yxieca March 17, 2023 18:16
@yxieca
Copy link
Contributor

yxieca commented Mar 17, 2023

@jcaiMR

  • can you look into the build failures?
  • it appears that you added bug fixes (not just code cleanups). Can you update the PR title and comments accordingly?

@kellyyeh
Copy link
Collaborator

@jcaiMR Looks like build failed due to package dependency. Adding sudo apt-get update in .azure-pipelines/build.yml might fix it

@saiarcot895
Copy link
Collaborator

Build fix is in #35.

@jcaiMR jcaiMR changed the title Improve UT coverage to 95% Improve UT coverage to 95%, code improve Mar 18, 2023
@jcaiMR
Copy link
Contributor Author

jcaiMR commented Mar 18, 2023

@kellyyeh @saiarcot895 Thanks all for fix this. I guess it not due to my PR code change, I raised a master based pipeline it also failed at arm64 and armhf, which looks good several weeks ago. Is it due to something changed/updated in our build system ?

@jcaiMR jcaiMR changed the title Improve UT coverage to 95%, code improve UT coverage to 95%, code improve and minor fix Mar 18, 2023
@jcaiMR
Copy link
Contributor Author

jcaiMR commented Mar 18, 2023

@jcaiMR

  • can you look into the build failures?
  • it appears that you added bug fixes (not just code cleanups). Can you update the PR title and comments accordingly?

Got it, just updated title and details in description.

@saiarcot895
Copy link
Collaborator

@kellyyeh @saiarcot895 Thanks all for fix this. I guess it not due to my PR code change, I raised a master based pipeline it also failed at arm64 and armhf, which looks good several weeks ago. Is it due to something changed/updated in our build system ?

The failures were due to changes in the slave container builds that removed the apt package cache at the end of the build. This meant that any users of the slave image who wanted to install new packages would need to do an apt update first.

@jcaiMR
Copy link
Contributor Author

jcaiMR commented Mar 20, 2023

@kellyyeh @saiarcot895 Thanks all for fix this. I guess it not due to my PR code change, I raised a master based pipeline it also failed at arm64 and armhf, which looks good several weeks ago. Is it due to something changed/updated in our build system ?

The failures were due to changes in the slave container builds that removed the apt package cache at the end of the build. This meant that any users of the slave image who wanted to install new packages would need to do an apt update first.

Got it, thank you for the detailed explanation.

test/mock_relay.cpp Show resolved Hide resolved
EXPECT_TRUE(false);
}
// same name to override static global variable
uint8_t server_recv_buffer[BUFFER_SIZE] = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you can override a static global variable in another .cpp file. Are you sure this is working?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Saikrishna, you are right. It's some dummy code I tried in my testing, I will remove them for less confusion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remove this code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, my miss, will apply in latest diff.

Makefile Outdated Show resolved Hide resolved
@jcaiMR jcaiMR requested a review from saiarcot895 April 22, 2023 05:52
config.local_sock = -1;

std::unordered_map<std::string, struct relay_config> vlans;

uint8_t client_recv_buffer[] = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this variable used? It doesn't seem like it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It only used to get a valid dhcp client packet size. I leave it there for an example of good dhcp client packet, maybe it would help to understand the original function meaning in future. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed in latest diff.

* Update package cache, and bail on the first error

Signed-off-by: Saikrishna Arcot <[email protected]>

* Incorrectly added line continuation

Signed-off-by: Saikrishna Arcot <[email protected]>

---------

Signed-off-by: Saikrishna Arcot <[email protected]>
@jcaiMR jcaiMR force-pushed the dev/dhcprelay_ut_improve_new branch from 544f8b9 to 7ff9806 Compare May 7, 2023 14:55
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 7, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@jcaiMR jcaiMR force-pushed the dev/dhcprelay_ut_improve_new branch from 7ff9806 to dfb8e92 Compare May 7, 2023 15:03
@jcaiMR jcaiMR requested a review from saiarcot895 May 9, 2023 01:20
@jcaiMR jcaiMR merged commit 4b17265 into sonic-net:master May 13, 2023
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.

4 participants