fix: harden CLI and GPS handling
This commit is contained in:
1 parent
5a26d4ddd1
commit
a0165cb38b
9 files changed
+192
-94
No files matched your search
@@ -45,6 +45,7 @@ does not reflect the GoogleTest count -- run the built binary directly
|
||||
| `test_flood_filter_policy` | `src/helpers/FloodFilterPolicy.h` | unordered blacklist matching; ordered 1/2/3-byte pbyte rule prefixes; original incoming scope classes and canonical region-name identity; channel-authentication cache key comparison; priority ordering and terminal stop masks; bridge-bucket and regionless channel-target selector encoding; `require=region` and per-channel scope-gate truth tables; fast/slow timing; adding, replacing, and preserving packet scope |
|
||||
| `test_logical_message_cache` | `src/helpers/LogicalMessageCache.h` | bounded logical-message mapping; stable retry timestamps; exact older retries after newer messages; stale and same-timestamp mismatch rejection |
|
||||
| `test_cli_command_utils` | `src/helpers/CLICommandUtils.h`, `src/helpers/ContactListOrder.h`, `src/helpers/TerminalCommandTracker.h`, `src/helpers/TerminalDisplayFilter.h` | terminal verb/argument/path parsing; routed receive labels; quiet display defaults and independent emergency filtering; favorite-first contact ordering; single-command reply matching, round-trip timing, and rollover-safe expiration |
|
||||
| `test_gps_time_validation` | `src/helpers/sensors/GpsTimeValidation.h` | complete NMEA UTC validation; leap years and calendar bounds; rejection of receiver-default and signed-32-bit-out-of-range dates |
|
||||
| `test_identity_generation` | `src/helpers/IdentityGeneration.h` | reserved-prefix rejection; bounded retries; final provisioned attempt; fail-closed exhaustion |
|
||||
| `test_remote_cli_reply_cache` | `src/helpers/RemoteCliReplyCache.h`, `src/helpers/RemoteCliRequest.h`, `src/helpers/RemoteCliTimeout.h` | authenticated logical-request matching; bounded recent-reply history; backward-compatible retry identity; 300% response timeout; empty-response completion; on-air truncation and clearing |
|
||||
| `test_companion_frame_queue` | `src/helpers/CompanionFrameQueue.h` | response/required/best-effort classification; reserved capacity; stable priority; safe eviction; message-waiting coalescing |
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <helpers/sensors/GpsTimeValidation.h>
|
||||
|
||||
TEST(GpsTimeValidation, AcceptsCompleteUtcDatesInSignedTimestampRange) {
|
||||
EXPECT_TRUE(mesh::gps::isValidNmeaDateTime(2020, 1, 1, 0, 0, 0));
|
||||
EXPECT_TRUE(mesh::gps::isValidNmeaDateTime(2024, 2, 29, 23, 59, 59));
|
||||
EXPECT_TRUE(mesh::gps::isValidNmeaDateTime(2038, 1, 19, 3, 14, 7));
|
||||
}
|
||||
|
||||
TEST(GpsTimeValidation, RejectsZeroPartialAndOutOfRangeDates) {
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(0, 0, 0, 0, 0, 0));
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(2019, 12, 31, 23, 59, 59));
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(2038, 1, 19, 3, 14, 8));
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(2038, 1, 20, 0, 0, 0));
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(2039, 1, 1, 0, 0, 0));
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(2026, 13, 1, 0, 0, 0));
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(2026, 1, 1, 24, 0, 0));
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(2026, 1, 1, 0, 60, 0));
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(2026, 1, 1, 0, 0, 60));
|
||||
}
|
||||
|
||||
TEST(GpsTimeValidation, EnforcesCalendarDayBounds) {
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(2023, 2, 29, 12, 0, 0));
|
||||
EXPECT_TRUE(mesh::gps::isValidNmeaDateTime(2024, 2, 29, 12, 0, 0));
|
||||
EXPECT_FALSE(mesh::gps::isValidNmeaDateTime(2026, 4, 31, 12, 0, 0));
|
||||
EXPECT_TRUE(mesh::gps::isValidNmeaDateTime(2026, 4, 30, 12, 0, 0));
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in new issue
Block a user