tree:
https://github.com/plbossart/sound test/topology-ktest
head: 435db31343ff7801bdf6d7da608c85d8f53353d3
commit: 2e3a9e7d28656d8eeabda33de7b2349f013ac9a1 [5/7] ASoC: topology: KUnit: Add KUnit
tests passing various arguments to snd_soc_tplg_component_load
config: nios2-allyesconfig (attached as .config)
compiler: nios2-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
#
https://github.com/plbossart/sound/commit/2e3a9e7d28656d8eeabda33de7b2349...
git remote add plbossart-sound
https://github.com/plbossart/sound
git fetch --no-tags plbossart-sound test/topology-ktest
git checkout 2e3a9e7d28656d8eeabda33de7b2349f013ac9a1
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nios2
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
> sound/soc/soc-topology-test.c:60:5: warning: no previous
prototype for 'd_probe' [-Wmissing-prototypes]
60 | int d_probe(struct
snd_soc_component *component)
| ^~~~~~~
> sound/soc/soc-topology-test.c:73:6: warning: no previous
prototype for 'd_remove' [-Wmissing-prototypes]
73 | void
d_remove(struct snd_soc_component *component)
| ^~~~~~~~
> sound/soc/soc-topology-test.c:121:5: warning: no previous
prototype for 'd_probe_null_comp' [-Wmissing-prototypes]
121 | int
d_probe_null_comp(struct snd_soc_component *component)
| ^~~~~~~~~~~~~~~~~
> sound/soc/soc-topology-test.c:229:5: warning: no previous
prototype for 'd_probe_null_fw' [-Wmissing-prototypes]
229 | int
d_probe_null_fw(struct snd_soc_component *component)
| ^~~~~~~~~~~~~~~
vim +/d_probe +60 sound/soc/soc-topology-test.c
59
60 int d_probe(struct snd_soc_component *component)
61 {
62 struct kunit_soc_component *kunit_comp =
63 container_of(component, struct kunit_soc_component, comp);
64 int ret;
65
66 ret = snd_soc_tplg_component_load(component, NULL, &kunit_comp->fw);
67 KUNIT_EXPECT_EQ_MSG(kunit_comp->kunit, kunit_comp->expect, ret,
68 "Failed topology load");
69
70 return 0;
71 }
72
73 void d_remove(struct snd_soc_component *component)
74 {
75 struct kunit_soc_component *kunit_comp =
76 container_of(component, struct kunit_soc_component, comp);
77 int ret;
78
79 ret = snd_soc_tplg_component_remove(component);
80 KUNIT_EXPECT_EQ(kunit_comp->kunit, 0, ret);
81 }
82
83 /*
84 * ASoC minimal boiler plate
85 */
86 SND_SOC_DAILINK_DEF(dummy, DAILINK_COMP_ARRAY(COMP_DUMMY()));
87
88 SND_SOC_DAILINK_DEF(platform,
DAILINK_COMP_ARRAY(COMP_PLATFORM("sound-soc-topology-test")));
89
90 static struct snd_soc_dai_link kunit_dai_links[] = {
91 {
92 .name = "KUNIT Audio Port",
93 .id = 0,
94 .stream_name = "Audio Playback/Capture",
95 .nonatomic = 1,
96 .dynamic = 1,
97 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
98 .dpcm_playback = 1,
99 .dpcm_capture = 1,
100 SND_SOC_DAILINK_REG(dummy, dummy, platform),
101 },
102 };
103
104 static const struct snd_soc_component_driver test_component = {
105 .name = "sound-soc-topology-test",
106 .probe = d_probe,
107 .remove = d_remove,
108 .non_legacy_dai_naming = 1,
109 };
110
111 /* ===== TEST CASES ========================================================= */
112
113 // TEST CASE
114 // Test passing NULL component as parameter to snd_soc_tplg_component_load
115
116 /*
117 * need to override generic probe function with one using NULL when calling
118 * topology load during component initialization, we don't need .remove
119 * handler as load should fail
120 */
121 int d_probe_null_comp(struct snd_soc_component *component)
122 {
123 struct kunit_soc_component *kunit_comp =
124 container_of(component, struct kunit_soc_component, comp);
125 int ret;
126
127 /* instead of passing component pointer as first argument, pass NULL here */
128 ret = snd_soc_tplg_component_load(NULL, NULL, &kunit_comp->fw);
129 KUNIT_EXPECT_EQ_MSG(kunit_comp->kunit, kunit_comp->expect, ret,
130 "Failed topology load");
131
132 return 0;
133 }
134
135 static const struct snd_soc_component_driver test_component_null_comp = {
136 .name = "sound-soc-topology-test",
137 .probe = d_probe_null_comp,
138 .non_legacy_dai_naming = 1,
139 };
140
141 static void snd_soc_tplg_test_load_with_null_comp(struct kunit *test)
142 {
143 struct kunit_soc_component *kunit_comp;
144 int ret;
145
146 /* prepare */
147 kunit_comp = kunit_kzalloc(test, sizeof(*kunit_comp), GFP_KERNEL);
148 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, kunit_comp);
149 kunit_comp->kunit = test;
150 kunit_comp->expect = -EINVAL; /* expect failure */
151
152 kunit_comp->card.dev = test_dev,
153 kunit_comp->card.name = "kunit-card",
154 kunit_comp->card.owner = THIS_MODULE,
155 kunit_comp->card.dai_link = kunit_dai_links,
156 kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links),
157 kunit_comp->card.fully_routed = true,
158
159 /* run test */
160 ret = snd_soc_register_card(&kunit_comp->card);
161 if (ret != 0 && ret != -EPROBE_DEFER)
162 KUNIT_FAIL(test, "Failed to register card");
163
164 ret = snd_soc_component_initialize(&kunit_comp->comp,
&test_component_null_comp, test_dev);
165 KUNIT_EXPECT_EQ(test, 0, ret);
166
167 ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
168 KUNIT_EXPECT_EQ(test, 0, ret);
169
170 /* cleanup */
171 ret = snd_soc_unregister_card(&kunit_comp->card);
172 KUNIT_EXPECT_EQ(test, 0, ret);
173
174 snd_soc_unregister_component(test_dev);
175 }
176
177 // TEST CASE
178 // Test passing NULL ops as parameter to snd_soc_tplg_component_load
179
180 /*
181 * NULL ops is default case, we pass empty topology (fw), so we don't have
182 * anything to parse and just do nothing, which results in return 0; from
183 * calling soc_tplg_dapm_complete in soc_tplg_process_headers
184 */
185 static void snd_soc_tplg_test_load_with_null_ops(struct kunit *test)
186 {
187 struct kunit_soc_component *kunit_comp;
188 int ret;
189
190 /* prepare */
191 kunit_comp = kunit_kzalloc(test, sizeof(*kunit_comp), GFP_KERNEL);
192 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, kunit_comp);
193 kunit_comp->kunit = test;
194 kunit_comp->expect = 0; /* expect success */
195
196 kunit_comp->card.dev = test_dev,
197 kunit_comp->card.name = "kunit-card",
198 kunit_comp->card.owner = THIS_MODULE,
199 kunit_comp->card.dai_link = kunit_dai_links,
200 kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links),
201 kunit_comp->card.fully_routed = true,
202
203 /* run test */
204 ret = snd_soc_register_card(&kunit_comp->card);
205 if (ret != 0 && ret != -EPROBE_DEFER)
206 KUNIT_FAIL(test, "Failed to register card");
207
208 ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component,
test_dev);
209 KUNIT_EXPECT_EQ(test, 0, ret);
210
211 ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
212 KUNIT_EXPECT_EQ(test, 0, ret);
213
214 /* cleanup */
215 ret = snd_soc_unregister_card(&kunit_comp->card);
216 KUNIT_EXPECT_EQ(test, 0, ret);
217
218 snd_soc_unregister_component(test_dev);
219 }
220
221 // TEST CASE
222 // Test passing NULL fw as parameter to snd_soc_tplg_component_load
223
224 /*
225 * need to override generic probe function with one using NULL pointer to fw
226 * when calling topology load during component initialization, we don't need
227 * .remove handler as load should fail
228 */
229 int d_probe_null_fw(struct snd_soc_component *component)
230 {
231 struct kunit_soc_component *kunit_comp =
232 container_of(component, struct kunit_soc_component, comp);
233 int ret;
234
235 /* instead of passing fw pointer as third argument, pass NULL here */
236 ret = snd_soc_tplg_component_load(component, NULL, NULL);
237 KUNIT_EXPECT_EQ_MSG(kunit_comp->kunit, kunit_comp->expect, ret,
238 "Failed topology load");
239
240 return 0;
241 }
242
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org