Skip to content

Commit 1f09c92

Browse files
mbolivar-nordiccfriedt
authored andcommitted
Revert "tests: devicetree: test supported devices API"
This reverts commit 4c32e21 with some manual conflict resolution. It's not clear that the supported devices are being properly computed, so let's revert this for v2.7.0 until we've had more time to think it through. Signed-off-by: Martí Bolívar <[email protected]>
1 parent aa8c3fa commit 1f09c92

File tree

1 file changed

+16
-56
lines changed
  • tests/lib/devicetree/devices/src

1 file changed

+16
-56
lines changed

tests/lib/devicetree/devices/src/main.c

Lines changed: 16 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ static bool check_handle(device_handle_t hdl,
7474
return false;
7575
}
7676

77-
struct visitor_context {
77+
struct requires_context {
7878
uint8_t ndevs;
7979
const struct device *rdevs[2];
8080
};
8181

82-
static int device_visitor(const struct device *dev,
83-
void *context)
82+
static int requires_visitor(const struct device *dev,
83+
void *context)
8484
{
85-
struct visitor_context *ctx = context;
85+
struct requires_context *ctx = context;
8686
const struct device **rdp = ctx->rdevs;
8787

8888
while (rdp < (ctx->rdevs + ctx->ndevs)) {
@@ -102,22 +102,22 @@ static void test_requires(void)
102102
size_t nhdls = 0;
103103
const device_handle_t *hdls;
104104
const struct device *dev;
105-
struct visitor_context ctx = { 0 };
105+
struct requires_context ctx = { 0 };
106106

107107
/* TEST_GPIO: no req */
108108
dev = device_get_binding(DT_LABEL(TEST_GPIO));
109109
zassert_equal(dev, DEVICE_DT_GET(TEST_GPIO), NULL);
110110
hdls = device_required_handles_get(dev, &nhdls);
111111
zassert_equal(nhdls, 0, NULL);
112-
zassert_equal(0, device_required_foreach(dev, device_visitor, &ctx),
112+
zassert_equal(0, device_required_foreach(dev, requires_visitor, &ctx),
113113
NULL);
114114

115115
/* TEST_I2C: no req */
116116
dev = device_get_binding(DT_LABEL(TEST_I2C));
117117
zassert_equal(dev, DEVICE_DT_GET(TEST_I2C), NULL);
118118
hdls = device_required_handles_get(dev, &nhdls);
119119
zassert_equal(nhdls, 0, NULL);
120-
zassert_equal(0, device_required_foreach(dev, device_visitor, &ctx),
120+
zassert_equal(0, device_required_foreach(dev, requires_visitor, &ctx),
121121
NULL);
122122

123123
/* TEST_DEVA: TEST_I2C GPIO */
@@ -129,23 +129,23 @@ static void test_requires(void)
129129
zassert_true(check_handle(DEV_HDL(TEST_GPIO), hdls, nhdls), NULL);
130130

131131
/* Visit fails if not enough space */
132-
ctx = (struct visitor_context){
132+
ctx = (struct requires_context){
133133
.ndevs = 1,
134134
};
135-
zassert_equal(-ENOSPC, device_required_foreach(dev, device_visitor, &ctx),
135+
zassert_equal(-ENOSPC, device_required_foreach(dev, requires_visitor, &ctx),
136136
NULL);
137137

138138
/* Visit succeeds if enough space. */
139-
ctx = (struct visitor_context){
139+
ctx = (struct requires_context){
140140
.ndevs = 2,
141141
};
142-
zassert_equal(2, device_required_foreach(dev, device_visitor, &ctx),
142+
zassert_equal(2, device_required_foreach(dev, requires_visitor, &ctx),
143143
NULL);
144144
zassert_true((ctx.rdevs[0] == device_from_handle(DEV_HDL(TEST_I2C)))
145-
|| (ctx.rdevs[1] == device_from_handle(DEV_HDL(TEST_I2C))),
145+
|| (ctx.rdevs[1] == device_from_handle(DEV_HDL(TEST_I2C))),
146146
NULL);
147147
zassert_true((ctx.rdevs[0] == device_from_handle(DEV_HDL(TEST_GPIO)))
148-
|| (ctx.rdevs[1] == device_from_handle(DEV_HDL(TEST_GPIO))),
148+
|| (ctx.rdevs[1] == device_from_handle(DEV_HDL(TEST_GPIO))),
149149
NULL);
150150

151151
/* TEST_GPIOX: TEST_I2C */
@@ -154,10 +154,10 @@ static void test_requires(void)
154154
hdls = device_required_handles_get(dev, &nhdls);
155155
zassert_equal(nhdls, 1, NULL);
156156
zassert_true(check_handle(DEV_HDL(TEST_I2C), hdls, nhdls), NULL);
157-
ctx = (struct visitor_context){
157+
ctx = (struct requires_context){
158158
.ndevs = 3,
159159
};
160-
zassert_equal(1, device_required_foreach(dev, device_visitor, &ctx),
160+
zassert_equal(1, device_required_foreach(dev, requires_visitor, &ctx),
161161
NULL);
162162
zassert_true(ctx.rdevs[0] == device_from_handle(DEV_HDL(TEST_I2C)),
163163
NULL);
@@ -171,45 +171,6 @@ static void test_requires(void)
171171
zassert_true(check_handle(DEV_HDL(TEST_GPIOX), hdls, nhdls), NULL);
172172
}
173173

174-
static void test_supports(void)
175-
{
176-
size_t nhdls = 0;
177-
const device_handle_t *hdls;
178-
const struct device *dev;
179-
struct visitor_context ctx = { 0 };
180-
181-
/* TEST_DEVB: None */
182-
dev = DEVICE_DT_GET(TEST_DEVB);
183-
hdls = device_supported_handles_get(dev, &nhdls);
184-
zassert_equal(nhdls, 0, NULL);
185-
186-
/* TEST_GPIO: TEST_DEVA */
187-
dev = DEVICE_DT_GET(TEST_GPIO);
188-
hdls = device_supported_handles_get(dev, &nhdls);
189-
zassert_equal(nhdls, 1, NULL);
190-
zassert_true(check_handle(DEV_HDL(TEST_DEVA), hdls, nhdls), NULL);
191-
192-
/* Visit fails if not enough space */
193-
ctx = (struct visitor_context){
194-
.ndevs = 0,
195-
};
196-
zassert_equal(-ENOSPC, device_supported_foreach(dev, device_visitor, &ctx), NULL);
197-
198-
/* Visit succeeds if enough space. */
199-
ctx = (struct visitor_context){
200-
.ndevs = 1,
201-
};
202-
zassert_equal(1, device_supported_foreach(dev, device_visitor, &ctx), NULL);
203-
zassert_true(ctx.rdevs[0] == device_from_handle(DEV_HDL(TEST_DEVA)), NULL);
204-
205-
/* TEST_I2C: TEST_DEVA TEST_GPIOX TEST_DEVB */
206-
dev = DEVICE_DT_GET(TEST_I2C);
207-
hdls = device_supported_handles_get(dev, &nhdls);
208-
zassert_equal(nhdls, 3, NULL);
209-
zassert_true(check_handle(DEV_HDL(TEST_DEVA), hdls, nhdls), NULL);
210-
zassert_true(check_handle(DEV_HDL(TEST_GPIOX), hdls, nhdls), NULL);
211-
zassert_true(check_handle(DEV_HDL(TEST_DEVB), hdls, nhdls), NULL);
212-
}
213174

214175
void test_main(void)
215176
{
@@ -220,8 +181,7 @@ void test_main(void)
220181

221182
ztest_test_suite(devicetree_driver,
222183
ztest_unit_test(test_init_order),
223-
ztest_unit_test(test_requires),
224-
ztest_unit_test(test_supports)
184+
ztest_unit_test(test_requires)
225185
);
226186
ztest_run_test_suite(devicetree_driver);
227187
}

0 commit comments

Comments
 (0)