Commit cabb7d5b7896a4d307ea6ad6d3bd045810544151
1 parent
f7f951c298
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
of/selftest: Use selftest() macro throughout
Some of the selftests are open-coded. Others use the selftest() macro defined in drivers/of/selftest.c. The macro makes for cleaner selftest code, so refactor the of_parse_phandle_with_args() tests to use it. Cc: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Showing 1 changed file with 14 additions and 23 deletions Side-by-side Diff
drivers/of/selftest.c
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | * Self tests for device tree subsystem |
3 | 3 | */ |
4 | 4 | |
5 | -#define pr_fmt(fmt) "### %s(): " fmt, __func__ | |
5 | +#define pr_fmt(fmt) "### dt-test ### " fmt | |
6 | 6 | |
7 | 7 | #include <linux/clk.h> |
8 | 8 | #include <linux/err.h> |
9 | 9 | |
10 | 10 | |
11 | 11 | |
... | ... | @@ -16,19 +16,20 @@ |
16 | 16 | |
17 | 17 | static bool selftest_passed = true; |
18 | 18 | #define selftest(result, fmt, ...) { \ |
19 | - selftest_passed &= (result); \ | |
20 | - if (!(result)) \ | |
19 | + if (!(result)) { \ | |
21 | 20 | pr_err("FAIL %s:%i " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \ |
21 | + selftest_passed = false; \ | |
22 | + } else { \ | |
23 | + pr_info("pass %s:%i\n", __FILE__, __LINE__); \ | |
24 | + } \ | |
22 | 25 | } |
23 | 26 | |
24 | 27 | static void __init of_selftest_parse_phandle_with_args(void) |
25 | 28 | { |
26 | 29 | struct device_node *np; |
27 | 30 | struct of_phandle_args args; |
28 | - int rc, i; | |
29 | - bool passed_all = true; | |
31 | + int i, rc; | |
30 | 32 | |
31 | - pr_info("start\n"); | |
32 | 33 | np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); |
33 | 34 | if (!np) { |
34 | 35 | pr_err("missing testcase data\n"); |
35 | 36 | |
36 | 37 | |
37 | 38 | |
38 | 39 | |
39 | 40 | |
... | ... | @@ -79,45 +80,35 @@ |
79 | 80 | passed &= (args.args[0] == (i + 1)); |
80 | 81 | break; |
81 | 82 | case 7: |
82 | - passed &= (rc == -EINVAL); | |
83 | + passed &= (rc == -ENOENT); | |
83 | 84 | break; |
84 | 85 | default: |
85 | 86 | passed = false; |
86 | 87 | } |
87 | 88 | |
88 | - if (!passed) { | |
89 | - int j; | |
90 | - pr_err("index %i - data error on node %s rc=%i regs=[", | |
91 | - i, args.np->full_name, rc); | |
92 | - for (j = 0; j < args.args_count; j++) | |
93 | - printk(" %i", args.args[j]); | |
94 | - printk(" ]\n"); | |
95 | - | |
96 | - passed_all = false; | |
97 | - } | |
89 | + selftest(passed, "index %i - data error on node %s rc=%i\n", | |
90 | + i, args.np->full_name, rc); | |
98 | 91 | } |
99 | 92 | |
100 | 93 | /* Check for missing list property */ |
101 | 94 | rc = of_parse_phandle_with_args(np, "phandle-list-missing", |
102 | 95 | "#phandle-cells", 0, &args); |
103 | - passed_all &= (rc == -EINVAL); | |
96 | + selftest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); | |
104 | 97 | |
105 | 98 | /* Check for missing cells property */ |
106 | 99 | rc = of_parse_phandle_with_args(np, "phandle-list", |
107 | 100 | "#phandle-cells-missing", 0, &args); |
108 | - passed_all &= (rc == -EINVAL); | |
101 | + selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); | |
109 | 102 | |
110 | 103 | /* Check for bad phandle in list */ |
111 | 104 | rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle", |
112 | 105 | "#phandle-cells", 0, &args); |
113 | - passed_all &= (rc == -EINVAL); | |
106 | + selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); | |
114 | 107 | |
115 | 108 | /* Check for incorrectly formed argument list */ |
116 | 109 | rc = of_parse_phandle_with_args(np, "phandle-list-bad-args", |
117 | 110 | "#phandle-cells", 1, &args); |
118 | - passed_all &= (rc == -EINVAL); | |
119 | - | |
120 | - pr_info("end - %s\n", passed_all ? "PASS" : "FAIL"); | |
111 | + selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); | |
121 | 112 | } |
122 | 113 | |
123 | 114 | static void __init of_selftest_property_match_string(void) |