Commit 6b1271de3723a7957c7cc6a7f36ea114f557e730
Committed by
Grant Likely
1 parent
15204ab1eb
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
of/unittest: Overlays with sub-devices tests
Introduce selftests for overlays using sub-devices present in children nodes. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Grant Likely <grant.likely@linaro.org>
Showing 2 changed files with 94 additions and 0 deletions Side-by-side Diff
drivers/of/unittest-data/tests-overlay.dtsi
... | ... | @@ -176,6 +176,61 @@ |
176 | 176 | }; |
177 | 177 | }; |
178 | 178 | |
179 | + overlay10 { | |
180 | + fragment@0 { | |
181 | + target-path = "/testcase-data/overlay-node/test-bus"; | |
182 | + __overlay__ { | |
183 | + | |
184 | + /* suppress DTC warning */ | |
185 | + #address-cells = <1>; | |
186 | + #size-cells = <0>; | |
187 | + | |
188 | + test-selftest10 { | |
189 | + compatible = "selftest"; | |
190 | + status = "okay"; | |
191 | + reg = <10>; | |
192 | + | |
193 | + #address-cells = <1>; | |
194 | + #size-cells = <0>; | |
195 | + | |
196 | + test-selftest101 { | |
197 | + compatible = "selftest"; | |
198 | + status = "okay"; | |
199 | + reg = <1>; | |
200 | + }; | |
201 | + | |
202 | + }; | |
203 | + }; | |
204 | + }; | |
205 | + }; | |
206 | + | |
207 | + overlay11 { | |
208 | + fragment@0 { | |
209 | + target-path = "/testcase-data/overlay-node/test-bus"; | |
210 | + __overlay__ { | |
211 | + | |
212 | + /* suppress DTC warning */ | |
213 | + #address-cells = <1>; | |
214 | + #size-cells = <0>; | |
215 | + | |
216 | + test-selftest11 { | |
217 | + compatible = "selftest"; | |
218 | + status = "okay"; | |
219 | + reg = <11>; | |
220 | + | |
221 | + #address-cells = <1>; | |
222 | + #size-cells = <0>; | |
223 | + | |
224 | + test-selftest111 { | |
225 | + compatible = "selftest"; | |
226 | + status = "okay"; | |
227 | + reg = <1>; | |
228 | + }; | |
229 | + | |
230 | + }; | |
231 | + }; | |
232 | + }; | |
233 | + }; | |
179 | 234 | }; |
180 | 235 | }; |
drivers/of/unittest.c
... | ... | @@ -978,6 +978,9 @@ |
978 | 978 | } |
979 | 979 | |
980 | 980 | dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); |
981 | + | |
982 | + of_platform_populate(np, NULL, NULL, &pdev->dev); | |
983 | + | |
981 | 984 | return 0; |
982 | 985 | } |
983 | 986 | |
... | ... | @@ -1385,6 +1388,39 @@ |
1385 | 1388 | selftest(1, "overlay test %d passed\n", 8); |
1386 | 1389 | } |
1387 | 1390 | |
1391 | +/* test insertion of a bus with parent devices */ | |
1392 | +static void of_selftest_overlay_10(void) | |
1393 | +{ | |
1394 | + int ret; | |
1395 | + char *child_path; | |
1396 | + | |
1397 | + /* device should disable */ | |
1398 | + ret = of_selftest_apply_overlay_check(10, 10, 0, 1); | |
1399 | + if (selftest(ret == 0, "overlay test %d failed; overlay application\n", 10)) | |
1400 | + return; | |
1401 | + | |
1402 | + child_path = kasprintf(GFP_KERNEL, "%s/test-selftest101", | |
1403 | + selftest_path(10)); | |
1404 | + if (selftest(child_path, "overlay test %d failed; kasprintf\n", 10)) | |
1405 | + return; | |
1406 | + | |
1407 | + ret = of_path_platform_device_exists(child_path); | |
1408 | + kfree(child_path); | |
1409 | + if (selftest(ret, "overlay test %d failed; no child device\n", 10)) | |
1410 | + return; | |
1411 | +} | |
1412 | + | |
1413 | +/* test insertion of a bus with parent devices (and revert) */ | |
1414 | +static void of_selftest_overlay_11(void) | |
1415 | +{ | |
1416 | + int ret; | |
1417 | + | |
1418 | + /* device should disable */ | |
1419 | + ret = of_selftest_apply_revert_overlay_check(11, 11, 0, 1); | |
1420 | + if (selftest(ret == 0, "overlay test %d failed; overlay application\n", 11)) | |
1421 | + return; | |
1422 | +} | |
1423 | + | |
1388 | 1424 | static void __init of_selftest_overlay(void) |
1389 | 1425 | { |
1390 | 1426 | struct device_node *bus_np = NULL; |
... | ... | @@ -1432,6 +1468,9 @@ |
1432 | 1468 | of_selftest_overlay_5(); |
1433 | 1469 | of_selftest_overlay_6(); |
1434 | 1470 | of_selftest_overlay_8(); |
1471 | + | |
1472 | + of_selftest_overlay_10(); | |
1473 | + of_selftest_overlay_11(); | |
1435 | 1474 | |
1436 | 1475 | out: |
1437 | 1476 | of_node_put(bus_np); |