1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*
* This file is part of the flashrom project.
*
* Copyright 2021 Google LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "lifecycle.h"
#if CONFIG_DUMMY == 1
void dummy_basic_lifecycle_test_success(void **state)
{
struct io_mock_fallback_open_state dummy_fallback_open_state = {
.noc = 0,
.paths = { NULL },
};
const struct io_mock dummy_io = {
.fallback_open_state = &dummy_fallback_open_state,
};
run_basic_lifecycle(state, &dummy_io, &programmer_dummy, "bus=parallel+lpc+fwh+spi+prog");
}
void dummy_probe_lifecycle_test_success(void **state)
{
struct io_mock_fallback_open_state dummy_fallback_open_state = {
.noc = 0,
.paths = { NULL },
};
const struct io_mock dummy_io = {
.fallback_open_state = &dummy_fallback_open_state,
};
run_probe_lifecycle(state, &dummy_io, &programmer_dummy, "bus=spi,emulate=W25Q128FV", "W25Q128.V");
}
void dummy_probe_variable_size_test_success(void **state)
{
struct io_mock_fallback_open_state dummy_fallback_open_state = {
.noc = 0,
.paths = { NULL },
};
const struct io_mock dummy_io = {
.fallback_open_state = &dummy_fallback_open_state,
};
run_probe_lifecycle(state, &dummy_io, &programmer_dummy, "size=8388608,emulate=VARIABLE_SIZE", "Opaque flash chip");
}
void dummy_init_fails_unhandled_param_test_success(void **state)
{
struct io_mock_fallback_open_state dummy_fallback_open_state = {
.noc = 0,
.paths = { NULL },
};
const struct io_mock dummy_io = {
.fallback_open_state = &dummy_fallback_open_state,
};
/*
* Programmer init should fail due to `dummy_init` failure caused by
* invalid value of `emulate` param. There is unhandled param left
* at the end of param string.
*/
run_init_error_path(state, &dummy_io, &programmer_dummy, "bus=spi,emulate=INVALID,unhandled=value", 1);
}
void dummy_init_success_invalid_param_test_success(void **state)
{
struct io_mock_fallback_open_state dummy_fallback_open_state = {
.noc = 0,
.paths = { NULL },
};
const struct io_mock dummy_io = {
.fallback_open_state = &dummy_fallback_open_state,
};
/*
* Programmer init should fail despite of the fact that `dummy_init`
* is successful, due to invalid param at the end of param string.
*/
run_init_error_path(state, &dummy_io, &programmer_dummy,
"bus=spi,emulate=W25Q128FV,invalid=value", ERROR_FATAL);
}
void dummy_init_success_unhandled_param_test_success(void **state)
{
struct io_mock_fallback_open_state dummy_fallback_open_state = {
.noc = 0,
.paths = { NULL },
};
const struct io_mock dummy_io = {
.fallback_open_state = &dummy_fallback_open_state,
};
/*
* Programmer init should fail despite of the fact that `dummy_init`
* is successful, due to unhandled param at the end of param string.
* Unhandled param `voltage` is not used for dummyflasher.
*/
run_init_error_path(state, &dummy_io, &programmer_dummy,
"bus=spi,emulate=W25Q128FV,voltage=3.5V", ERROR_FATAL);
}
#else
SKIP_TEST(dummy_basic_lifecycle_test_success)
SKIP_TEST(dummy_probe_lifecycle_test_success)
SKIP_TEST(dummy_probe_variable_size_test_success)
SKIP_TEST(dummy_init_fails_unhandled_param_test_success)
SKIP_TEST(dummy_init_success_invalid_param_test_success)
SKIP_TEST(dummy_init_success_unhandled_param_test_success)
#endif /* CONFIG_DUMMY */
|