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

feat(ThirdParty): Unity unit test #1033

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

feat(ThirdParty): Unity unit test #1033

wants to merge 22 commits into from

Conversation

EricB-ADI
Copy link
Contributor

@EricB-ADI EricB-ADI commented Jun 3, 2024

Pull Request Template

Description

  • Included 3rd party lib unity for unit testing
  • Added unit test example

@EricB-ADI EricB-ADI added enhancement New feature, request, or updating to latest version help wanted Extra attention is needed WIP work in progress dependencies Pull requests that update a dependency file build system This issue or pull request is related to the MSDK build system labels Jun 3, 2024
@github-actions github-actions bot added MAX32655 Related to the MAX32655 (ME17) Workflow Related to Workflow development labels Jun 3, 2024
@EricB-ADI
Copy link
Contributor Author

EricB-ADI commented Jun 3, 2024

Hey @Jake-Carter , I want to integrate unity into our SDK so we can have, and offer a unit test framework. I have it working ok, but it would benefit a lot more if we can integrate it better into the build system. I updated the libs.mk to include the lib. You can run the tests on target, but it is definitely meant to be ran on the PC. Looking for some pointers or help trying to integrate this better.

@EricB-ADI
Copy link
Contributor Author

/clang-format-run

@Jake-Carter
Copy link
Contributor

Hey @Jake-Carter , I want to integrate unity into our SDK so we can have, and offer a unit test framework. I have it working ok, but it would benefit a lot more if we can integrate it better into the build system. I updated the libs.mk to include the lib. You can run the tests on target, but it is definitely meant to be ran on the PC. Looking for some pointers or help trying to integrate this better.

Sounds good, I'll take a look

@Jake-Carter
Copy link
Contributor

Copy link
Contributor

@Jake-Carter Jake-Carter left a comment

Choose a reason for hiding this comment

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

@EricB-ADI seems easy enough to integrate. Some comments/questions below. Looks like we may need to just assign some custom printing configuration macros to our printf/UART drivers

Examples/MAX32655/Unity_Test/main.c Outdated Show resolved Hide resolved
Examples/MAX32655/Unity_Test/main.c Outdated Show resolved Hide resolved
Examples/MAX32655/Unity_Test/project.mk Outdated Show resolved Hide resolved
Examples/MAX32655/Unity_Test/project.mk Outdated Show resolved Hide resolved
Examples/MAX32655/Unity_Test/test/test_runner.c Outdated Show resolved Hide resolved
Libraries/libs.mk Show resolved Hide resolved
Examples/MAX32655/Unity_Test/project.mk Outdated Show resolved Hide resolved
@EricB-ADI
Copy link
Contributor Author

Just realized it got added as a submodule and none of the folders are there. Yes I did make a unity.mk.

@EricB-ADI
Copy link
Contributor Author

This should make more sense now.

@EricB-ADI
Copy link
Contributor Author

/clang-format-run

@github-actions github-actions bot added MAX32520 Related to the MAX32520 (ES17) MAX32650 Related to the MAX32650 (ME10) MAX32660 Related to the MAX32660 (ME11) MAX32665 Related to the MAX32665 (ME14) MAX32670 Related to the MAX32670 (ME15) MAX32672 Related to the MAX32672 (ME21) labels Jun 10, 2024
@github-actions github-actions bot removed MAX32665 Related to the MAX32665 (ME14) MAX32670 Related to the MAX32670 (ME15) MAX32672 Related to the MAX32672 (ME21) MAX32675 Related to the MAX32675 (ME16) MAX32680 Related to the MAX32680 (ME20) MAX78000 Related to the MAX78000 (AI85) MAX78002 Related to the MAX78002 (AI87) MAX32662 Related to the MAX32662 (ME12) labels Jun 12, 2024
@EricB-ADI
Copy link
Contributor Author

@Jake-Carter Everything is working as expected. I reran MSDKGen to update all the makefiles.

@EricB-ADI can you revert it and just update a single project? My browser crashes now when I try to view the diff

done

@github-actions github-actions bot removed the Workflow Related to Workflow development label Jun 12, 2024
Copy link
Contributor

@sihyung-maxim sihyung-maxim left a comment

Choose a reason for hiding this comment

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

Did you test the example in Keil and IAR (judging by the example's project files)?

If not, I'd recommend deleting those files from the example because it's still TBD how we'll handle IAR and Keil with the SDK. I don't know if we'll continue using the old setup we used to have. Code delivery and setting up a system to sync the codebase for IAR/Keil with GitHub hasn't been officially decided yet (mainly due to a lack of resources).

Also, don't forget to update the boards' examples.txt with the new example.

Copy link
Contributor

Choose a reason for hiding this comment

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

Extra file?

@sihyung-maxim
Copy link
Contributor

Removed Unity from the linter.

@github-actions github-actions bot added the Workflow Related to Workflow development label Jul 2, 2024
@Jake-Carter
Copy link
Contributor

@EricB-ADI pushed my latest changes. Streamlined the integration with the host PC and added some documentation to the UG. Also slightly modified the example and options.

Of note are some updates to the unity config in 274b74f. I was seeing hard faults on the host micro from those setjmp calls on assertion failures so I disabled them.

Works well on my target micro and host machine. Have you already developed some way to check the return code of a micro's main function when it's under debug? This would be a useful addition to the documentation for developing automated hardware-in-the-loop testing with this framework.

@EricB-ADI
Copy link
Contributor Author

Thanks for

@EricB-ADI pushed my latest changes. Streamlined the integration with the host PC and added some documentation to the UG. Also slightly modified the example and options.

Of note are some updates to the unity config in 274b74f. I was seeing hard faults on the host micro from those setjmp calls on assertion failures so I disabled them.

Works well on my target micro and host machine. Have you already developed some way to check the return code of a micro's main function when it's under debug? This would be a useful addition to the documentation for developing automated hardware-in-the-loop testing with this framework.

I have not, but I suspect we can do it by checking the register after a return. I have some pyocd automation scripts so I may take a look at that to see what happens.

@Jake-Carter
Copy link
Contributor

Sounds good. I poked around r0-r3 a bit but didn't pick out a consistent pattern. I was hoping GDB would exit and pass through the return code but the micro just goes into .SPIN and GDB doesn't really support finish on the outermost frame.

Lmk if you find anything, otherwise I think we can add some documentation on parsing the serial output. OK and FAIL are consistent strings

@EricB-ADI
Copy link
Contributor Author

EricB-ADI commented Oct 7, 2024

It should be pretty easy to make an automation script with GDB to break at void UnityFail(...) If it doesn't break and we hit a while loop or spin then it passed. We also have a test now that looks for serial prints. So we could modify to make sure the tests are passing from the print outs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system This issue or pull request is related to the MSDK build system dependencies Pull requests that update a dependency file enhancement New feature, request, or updating to latest version help wanted Extra attention is needed MAX32690 Related to the MAX32690 (ME18) WIP work in progress Workflow Related to Workflow development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants