1#!/usr/bin/env bash
2# Copyright 2023 Nordic Semiconductor
3# SPDX-License-Identifier: Apache-2.0
4
5source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh
6
7# Note:
8# Tests must be added in pairs and in sequence.
9# First test pair: executes Receive Firmware procedure up to certain point using distributor and
10# target.
11# Second test pair: tests are executed with `recover` enabled. This means target will recover
12# settings from persistent storage, which will allow to verify if stored DFU server's phase and
13# image index were loaded correctly.
14# Test cases are designed to be run using single target. `dfu_cli_stop` test case in recovery part
15# plays dummy role, and is there to keep order of settings files being loaded.
16overlay=overlay_pst_conf
17RunTestFlash dfu_dist_recover_phase \
18  dfu_cli_stop -flash_erase dfu_target_dfu_stop -flash_erase \
19  -- -argstest recover=0 expected-phase=2
20
21overlay=overlay_pst_conf
22RunTestFlash dfu_dist_recover_phase \
23  dfu_cli_stop dfu_target_dfu_stop \
24  -- -argstest recover=1 expected-phase=3
25
26overlay=overlay_pst_conf
27RunTestFlash dfu_dist_recover_phase \
28  dfu_cli_stop dfu_target_dfu_stop \
29  -- -argstest recover=1 expected-phase=4
30
31overlay=overlay_pst_conf
32RunTestFlash dfu_dist_recover_phase \
33  dfu_cli_stop dfu_target_dfu_stop \
34  -- -argstest recover=1 expected-phase=6
35
36# Use phase `BT_MESH_DFU_PHASE_APPLY_SUCCESS` as marker to bring whole procedure to an end
37overlay=overlay_pst_conf
38RunTestFlash dfu_dist_recover_phase \
39  dfu_cli_stop -flash_rm dfu_target_dfu_stop -flash_rm \
40  -- -argstest recover=1 expected-phase=8
41
42# The same test but with PSA crypto
43overlay="overlay_pst_conf_overlay_psa_conf"
44RunTestFlash dfu_dist_recover_phase_psa \
45  dfu_cli_stop -flash_erase dfu_target_dfu_stop -flash_erase \
46  -- -argstest recover=0 expected-phase=2
47
48overlay="overlay_pst_conf_overlay_psa_conf"
49RunTestFlash dfu_dist_recover_phase_psa \
50  dfu_cli_stop dfu_target_dfu_stop \
51  -- -argstest recover=1 expected-phase=3
52
53overlay="overlay_pst_conf_overlay_psa_conf"
54RunTestFlash dfu_dist_recover_phase_psa \
55  dfu_cli_stop dfu_target_dfu_stop \
56  -- -argstest recover=1 expected-phase=4
57
58overlay="overlay_pst_conf_overlay_psa_conf"
59RunTestFlash dfu_dist_recover_phase_psa \
60  dfu_cli_stop dfu_target_dfu_stop \
61  -- -argstest recover=1 expected-phase=6
62
63# Use phase `BT_MESH_DFU_PHASE_APPLY_SUCCESS` as marker to bring whole procedure to an end
64overlay="overlay_pst_conf_overlay_psa_conf"
65RunTestFlash dfu_dist_recover_phase_psa \
66  dfu_cli_stop -flash_rm dfu_target_dfu_stop -flash_rm \
67  -- -argstest recover=1 expected-phase=8
68