-
Notifications
You must be signed in to change notification settings - Fork 543
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
[aclorch] unittest by gtest #924
Conversation
Console output of Jenkins
|
@@ -0,0 +1,104 @@ | |||
#Language: Cpp | |||
AccessModifierOffset: -4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is nice, does it get applied in the build or test process? if not, how should we enable it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First need install clang-format. Before build process, apply clang-format to committed files (or all files) and save the result into a tmp
folder. Then compare committed files and files in tmp
folder. If all files are the same, means submitter do clang-format before send PR.
Current I do it locally to make sure every files have the same style, follow aclorch.cpp
nearly.
But it shall be another task if we want to enable it in build or test process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to add enforce the format check on the pr test. can you add clang-format in the sonic-slave-stretch, and add a small script to perform the check. Then, i can run it in the pr test.
thanks for adding the tests |
* Add macsec xpn support Signed-off-by: Ze Gan <ganze718@gmail.com> * Add unit test for loadMACsecAttrFromMACsecSC Signed-off-by: Ze Gan <ganze718@gmail.com> * Add SWSS_LOG_ENTER Signed-off-by: Ze Gan <ganze718@gmail.com> * Fix bug and refactor code Signed-off-by: Ubuntu <zegan@zegan-test-hk.0y0yh0pwahvetntlrcfftojvof.hx.internal.cloudapp.net> Co-authored-by: Ubuntu <zegan@zegan-test-hk.0y0yh0pwahvetntlrcfftojvof.hx.internal.cloudapp.net>
What I did
Add unit test for aclorch.
Why I did it
Do unit test in development phase. The developer can check each variable in each stack frame. And also do memory leakage detection or buffer overrun test. That is different than pytest, it is black box test. But, this is white box test.
How I verified it
The new committed testes are all passed.
Details if related
The unit test of aclorch have two scopes. One is cover the whole aclorch behaviors. Second is for internal component like AclTable or AclRule.
The first scope. Each test will call doTask() that simulate configDB was changed. All reaction by AclOrch, AclTable or AclReult will save into libvs via SAI. Then we can verify the results via SAI to make sure every operation is correct.
The second scope using spy function to redirect SAI function pointer to c++ std::function for accessing local variable of test instance. It can verify the result directly without any library.
Because many orch will connect Redis when it is created by constructor, so run the test will need to start Redis first. The later tests will not access Redis.
Signed-off-by: JunYing Yeh junying_yeh@edge-core.com