| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | /* | |||
| 2 | * @file test_flash.cpp | |||
| 3 | * | |||
| 4 | * @date: jul 15, 2025 | |||
| 5 | * @author FDSoftware | |||
| 6 | */ | |||
| 7 | ||||
| 8 | ||||
| 9 | #include "pch.h" | |||
| 10 | #include "storage.h" | |||
| 11 | #include "engine_test_helper.h" | |||
| 12 | ||||
| 13 | bool canFlashWhileRunning = true; | |||
| 14 | ||||
| 15 | 4 | bool mcuCanFlashWhileRunning() { return canFlashWhileRunning; } | ||
| 16 | ||||
| 17 | 4 | TEST(Storage, AllowWriteID) { | ||
| 18 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineTestHelper eth(engine_type_e::TEST_ENGINE); | |
| 19 |
1/1✓ Branch 1 taken 1 time.
|
1 | engine->rpmCalculator.setStopSpinning(); | |
| 20 | ||||
| 21 | // Settings record with MCU that can flash while running | |||
| 22 | 1 | engine->triggerCentral.directSelfStimulation = false; | ||
| 23 | // Mock that MCU can flash while running | |||
| 24 | 1 | canFlashWhileRunning = true; | ||
| 25 |
2/7✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(storageAllowWriteID(EFI_SETTINGS_RECORD_ID)); | |
| 26 | ||||
| 27 | // Settings record with MCU that cannot flash while running, | |||
| 28 | // but engine is in self-stimulation mode | |||
| 29 | 1 | canFlashWhileRunning = false; | ||
| 30 | 1 | engine->triggerCentral.directSelfStimulation = true; | ||
| 31 |
2/7✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(storageAllowWriteID(EFI_SETTINGS_RECORD_ID)); | |
| 32 | ||||
| 33 | // Settings record with MCU that cannot flash while running, | |||
| 34 | // engine not in self-stimulation but stopped | |||
| 35 | 1 | engine->triggerCentral.directSelfStimulation = false; | ||
| 36 |
1/1✓ Branch 1 taken 1 time.
|
1 | engine->rpmCalculator.setStopSpinning(); | |
| 37 |
2/7✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(storageAllowWriteID(EFI_SETTINGS_RECORD_ID)); | |
| 38 | ||||
| 39 | // Settings record with MCU that cannot flash while running, | |||
| 40 | // engine running (should not allow write) | |||
| 41 |
1/1✓ Branch 1 taken 1 time.
|
1 | engine->rpmCalculator.setRpmValue(1000); | |
| 42 |
2/7✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_FALSE(storageAllowWriteID(EFI_SETTINGS_RECORD_ID)); | |
| 43 | ||||
| 44 | // Non-settings record (should always allow write) | |||
| 45 |
2/7✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(storageAllowWriteID(EFI_LTFT_RECORD_ID)); | |
| 46 |
2/7✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_TRUE(storageAllowWriteID((StorageItemId)123)); // Some random ID | |
| 47 | 2 | } | ||
| 48 |