Refactored testing, Deprecated OF dependency in EmotiBit packet#28
Refactored testing, Deprecated OF dependency in EmotiBit packet#28Joseph-Jacobson merged 11 commits intomasterfrom
Conversation
added OF tag, cleaned up bash script
There was a problem hiding this comment.
Pull Request Overview
This PR removes openFrameworks dependencies, refactors packet creation for deterministic testing, and adds tooling to build and compare test data outputs.
- Refactor
EmotiBitPacketto remove OF-specific code and introduceappendTestDataMessage,createTestSawtoothData, andtestHeaderToStringmethods - Add
EmotiBitDataTesterexecutable with CMake support to generate a CSV of test packets - Provide a Bash script to locate and compare SD card output against the generated test CSV
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/EmotiBitPacket.h | Declared maxTestLength and new test data methods |
| src/EmotiBitPacket.cpp | Defined maxTestLength, refactored headerToString/createPacket, and implemented test data functions |
| src/EmotiBitDataTester.cpp | New CLI tool to call appendTestDataMessage and write test.csv |
| src/ArduinoString.h | Introduced a minimal EmotiBit::String wrapper around std::string |
| bashScripts/compare_test.sh | Script to find the most recent SD card CSV and diff against test.csv |
| CMakeLists.txt | Build configuration for EmotiBitDataTester |
nitin710
left a comment
There was a problem hiding this comment.
Review-01 by Nitin
I like that you took the time to populate the PR description. It reads well, but there are some issues that I have highlighted below.
General comments on the PR description
- "Moved testing logic for appendTestData to EmotiBitPacket". Maybe having a link to where it was moved from can add context to the PR.
- "Included CMake for running main testing file and associated data testing file". I am not sure it is clear enough to add value to the description. It either needs to in reviewer notes under a section "usage" or better explained if a part of the description.
- I think the list under "requirements" better lives under Testing > Requirements.
- This section was intended more for "you need this in your stack to be able to compile/run the new features". For us, that would be FW/SW version x.y.z. We can discuss more on this.
- Myabe adding a block diagram that explains the testing process helps in understanding the testing flow.
- We should discuss branch naming, XPlat was at version 1.6.1. So i think the feature is built on top of that version. I believe, currently it is using the FW version as base.
File/folder structure
- Generally, whenever we are adding new files/folders, there is always a question of naming conventions and location of the new files
- I am not sure
bashScriptsis the correct name or the correct location.- Are we using camel case as a convention? Why not
bash-scriptsorbash_scripts? - It would also be nice to add the reasoning for the name. for example, could we should call it
scripts, or maybehelper-scripts? - regarding structure, could we have the following? (see the next bullet point for an alternate organization)
- Are we using camel case as a convention? Why not
scripts
├── script1_name
│ ├── script1.sh
│ └── README.md
└── script2_name
├── script2.sh
└── README.md
CMakeListsis another file i dont think belongs in root.- I think it should live in a different folder. Maybe
apps? - There should be a correlation between this CMakeListt and the bashScript
- Maybe something like this is what we need?
- I think it should live in a different folder. Maybe
apps (probably some other appropriate name?)
├── DataTester
│ ├── README.md
│ ├── CMakeLists.txt
│ ├── src
│ │ └── EmotiBitDataTester.cpp
│ ├── scripts
│ │ ├── README.md
│ │ └── script1.sh
| └── build
ToDo
- Bump the version in the library.properties files in root. Follow semantic versioning for the version bump
Reviewer notes
- successfully compiled on PIO. Failed on Arduino, but i suspect it's a personal arduino setup issue.
- Did not run the CMake or bash. If we move the files, the sript and possible CMake file will change. So, I plan to test it then,
1. bumped library 2. code refactor 3. file restructure for testing 4. added ArduinoString.h tests
produceconsumerobot
left a comment
There was a problem hiding this comment.
Overall there are a number of good things in the code changes, but there are a handful of places where the rationale for the choices weren't immediately clear to me. The biggest omission from the PR itself is that you should include your complete results that fully demonstrates your code tested working. I shouldn't have to run your code to be sure that it works. Similar to presentation of scientific results in a journal article, I should be able to read your thorough description of your methods and your results and have everything I need to assess whether your conclusions are supported by your methods and results.
| #else | ||
| string EmotiBitPacket::headerToString(const Header &header) | ||
| { | ||
| //Refactored to use to_string instead of ofToString |
There was a problem hiding this comment.
Did you confirm that to_string performs the same as ofToString for all pertinent data types?
I'm not sure if I'm tracking where that's been tested explicitly.
There was a problem hiding this comment.
createTestHeader is used to test this refactor. We know to_string works the same as ofToString with the exceptions being it doesn't allow for string to string, which is why I omitted any conversion for the type tag. The other difference is to_string has more robust error handling.
|
|
||
| add_executable(ArduinoStringTest | ||
| src/main.cpp | ||
| ../../src/ArduinoString.h |
There was a problem hiding this comment.
maybe use target_include_directories function? I thnk add_executable should take cpp files by standard.
There was a problem hiding this comment.
Is this meant to replace add_executable?
There was a problem hiding this comment.
No, I *think*, add_executable is used to link src files to an executable.
_target_include_directories is used for specifying header files for the specified source files.
There was a problem hiding this comment.
Gotcha, target_include_directories specifies the directory so I will be specifying src so we can access arduino string
tests/MockDataTest/src/main.cpp
Outdated
| uint16_t packetNumber = 0; | ||
|
|
||
| // Define the type tags for the test data, can be used to expand the test data in the future | ||
| const char* typeTags[] = { |
There was a problem hiding this comment.
Im not sure I understand why we are defining this here. Can you add your explanation on this comment thread?
There was a problem hiding this comment.
I was defining it there as a method to access the type tags in a previous version, this was left in however can be easily removed.
Updated readmes, doxygen comments, and tests based on comments Cleaned up code Added new createPacket and deprecated old createPackets
nitin710
left a comment
There was a problem hiding this comment.
Left some minor feedback, but I think it looks good!
Did not run any tests.
I think, lets change the ArduinoStringTest script per my notes, and then we can merge it.
|
|
||
| add_executable(ArduinoStringTest | ||
| src/main.cpp | ||
| ../../src/ArduinoString.h |
There was a problem hiding this comment.
No, I *think*, add_executable is used to link src files to an executable.
_target_include_directories is used for specifying header files for the specified source files.
produceconsumerobot
left a comment
There was a problem hiding this comment.
Looks good. 2 small comments.
src/EmotiBitPacket.h
Outdated
| //! @param data Template parameter T for the data to include in the packet | ||
| //! @return String representation of the packet | ||
| template <typename T> | ||
| static String createPacket(const Header& header, const T& data) |
There was a problem hiding this comment.
I think output of Type T from createPacket() would make the function more versatile
There was a problem hiding this comment.
Agreed, I had to add another conversion to ArduinoString.h to convert a String to std::string for c++ to work with this template T. Messy internally but now we don't need to expect String as the return type. Will need to test this function as well.
nitin710
left a comment
There was a problem hiding this comment.
Let's merge it!
After you merge to master, you can go ahead and make a release using the guidelines here: https://github.com/EmotiBit/.github/blob/master/Docs/FirmwareDependencyRelease.md
| fi | ||
|
|
||
| "$EXECUTABLE" | ||
| RESULT=$? |
There was a problem hiding this comment.
I hope you also tested that "a fail" is registered as a fail by this script.
Trying to tweak the test to intentionally fail temporarily is a good way to make sure your "fail catch" is working!
There was a problem hiding this comment.
I confirmed fails get caught by the script as well!
Description
The purpose of this PR is to deprecate OF dependencies in EmotiBit Packet, and refactor appendTestData so it will have expected results that can be compared from the EmotiBit and an external source. Below is a more detailed list of the additions.
Requirements
To you run this branch you would need a minimum of:
Issues Referenced
Issue #29
Documentation update
None
Notes for Reviewer
Requirements for review
Additional Review Information
New testing structure
OF deprecation
Testing
Please follow "Mock Data Testing" and "Arduino String Testing" in the "EmotiBit Feature Test Protocols" document
To run this test you will need to pull both this, and 1.12.1 AppendTestData from the featherwing branch, and ofX. This process was built using Platform.io and the EmotiBit Oscilloscope. I also ran the follow tests on an Arduino build, and the oscilliscope with the new xPlat.
Results
Note: for CI both tests return 0/1 for pass/fail. The terminal prints is to communicate more information if needed.
For MockDataTest: the BASH script will show the results between the new MockDataTest and the EmotiBit's sd card result. The file path to the sd card will need to be specified.
For ArduinoStringTest: the BASH script will show the result of the pass/fails.
Feature Tests
none
Shared files
None
None
Checklist to allow merge
masterofxEmotiBitVersion.hDIGITAL_WRITE_DEBUG= false (if set true while testing)Screenshots: