Skip to content

feat(test): Enhance NVS test DEMO #2

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

Merged
merged 4 commits into from
Jun 19, 2025
Merged

feat(test): Enhance NVS test DEMO #2

merged 4 commits into from
Jun 19, 2025

Conversation

JakubAndrysek
Copy link
Owner

By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes

Checklist

  1. Please provide specific title of the PR describing the change, including the component name (eg. „Update of Documentation link on Readme.md“)
  2. Please provide related links (eg. Issue which will be closed by this Pull Request)
  3. Please update relevant Documentation if applicable
  4. Please check Contributing guide
  5. Please confirm option to "Allow edits and access to secrets by maintainers" when opening a Pull Request

This entire section above can be deleted if all items are checked.


Description of Change

Please describe your proposed Pull Request and it's impact.

Tests scenarios

Please describe on what Hardware and Software combinations you have tested this Pull Request and how.

(eg. I have tested my Pull Request on Arduino-esp32 core v2.0.2 with ESP32 and ESP32-S2 Board with this scenario)

Related links

Please provide links to related issue, PRs etc.

(eg. Closes #number of issue)

@JakubAndrysek JakubAndrysek requested a review from Copilot June 18, 2025 13:17
Copy link

github-actions bot commented Jun 18, 2025

Messages
📖 🎉 Good Job! All checks are passing!

👋 Hello JakubAndrysek, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against 834e85c

Copilot

This comment was marked as outdated.

@JakubAndrysek JakubAndrysek requested a review from Copilot June 18, 2025 13:28
Copilot

This comment was marked as outdated.

@JakubAndrysek JakubAndrysek requested a review from Copilot June 18, 2025 13:30
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces the simple counter demo with a full Preferences test covering all supported types, adds type validation, and updates the Python test to match the expanded output.

  • Expanded nvs.ino to read, validate, print, and update all Preferences data types (including structs, floats, doubles, and strings).
  • Added a validate_types() helper to assert that each key’s stored type matches the expected PT_* enum.
  • Updated test_nvs.py to check the new, verbose “Values from Preferences” output for default and successive runs.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/validation/nvs/test_nvs.py Updated expected serial output lines to match the new preferences demo output
tests/validation/nvs/nvs.ino Refactored the NVS demo to exercise get/put for all types, validate types, and print full state

Comment on lines +8 to +14
dut.expect_exact("Values from Preferences: char: A | uchar: 0 | short: 0 | ushort: 0 | int: 0 | uint: 0 | long: 0 | ulong: 0 | long64: 0 | ulong64: 0 | float: 0.00 | double: 0.00 | bool: false | str: str0 | strLen: strLen0 | struct: {id:1,val:100}")

LOGGER.info("Expecting counter value 1")
dut.expect_exact("Current counter value: 1")
LOGGER.info("Expecting updated preferences for the first time")
dut.expect_exact("Values from Preferences: char: B | uchar: 1 | short: 1 | ushort: 1 | int: 1 | uint: 1 | long: 1 | ulong: 1 | long64: 1 | ulong64: 1 | float: 1.10 | double: 1.10 | bool: true | str: str1 | strLen: strLen1 | struct: {id:2,val:110}")

LOGGER.info("Expecting counter value 2")
dut.expect_exact("Current counter value: 2")
LOGGER.info("Expecting updated preferences for the second time")
dut.expect_exact("Values from Preferences: char: C | uchar: 2 | short: 2 | ushort: 2 | int: 2 | uint: 2 | long: 2 | ulong: 2 | long64: 2 | ulong64: 2 | float: 2.20 | double: 2.20 | bool: false | str: str2 | strLen: strLen2 | struct: {id:3,val:120}")
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

[nitpick] This exact-match string is very long and makes the test fragile. Consider using a regex or splitting the check into multiple smaller expect calls so that a minor formatting change won’t break the entire test.

Copilot uses AI. Check for mistakes.

Serial.printf("Values from Preferences: ");
Serial.printf("char: %c | uchar: %u | short: %d | ushort: %u | int: %ld | uint: %lu | ",
val_char, val_uchar, val_short, val_ushort, val_int, val_uint);
Serial.printf("long: %lld | ulong: %lu | long64: %lld | ulong64: %llu | ",
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

Using %lld for val_long (which comes from getLong, typically a 32-bit value) can lead to mismatched output. Either switch to %ld for 32-bit long values or consistently use 64-bit APIs/types (e.g., getLong64) if you intend 64-bit storage.

Suggested change
Serial.printf("long: %lld | ulong: %lu | long64: %lld | ulong64: %llu | ",
Serial.printf("long: %ld | ulong: %lu | long64: %lld | ulong64: %llu | ",

Copilot uses AI. Check for mistakes.

// Print the counter to Serial Monitor
Serial.printf("Current counter value: %u\n", counter);
// Strings
String val_string = preferences.getString("str", "str0");
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

[nitpick] Using the Arduino String class on constrained devices can fragment heap memory over time. For a stability-focused demo, consider using a fixed-size char buffer and preferences.getString(key, buf, bufSize) instead.

Suggested change
String val_string = preferences.getString("str", "str0");
char val_string[20] = "str0"; // Fixed-size buffer for stability
preferences.getString("str", val_string, sizeof(val_string));

Copilot uses AI. Check for mistakes.

Copy link

Test Results

 76 files   76 suites   20m 30s ⏱️
 38 tests  37 ✅ 0 💤  1 ❌
241 runs  220 ✅ 0 💤 21 ❌

For more details on these failures, see this check.

Results for commit 834e85c.

@JakubAndrysek JakubAndrysek merged commit 3b64575 into master Jun 19, 2025
14 of 24 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.

1 participant