Lines Matching refs:test

3  * Sound core KUnit test
7 #include <kunit/test.h>
99 static void test_phys_format_size(struct kunit *test)
104 KUNIT_EXPECT_EQ(test, snd_pcm_format_physical_width(valid_fmt[i].format),
108 KUNIT_EXPECT_EQ(test, snd_pcm_format_physical_width(WRONG_FORMAT_1), -EINVAL);
109 KUNIT_EXPECT_EQ(test, snd_pcm_format_physical_width(WRONG_FORMAT_2), -EINVAL);
112 static void test_format_width(struct kunit *test)
117 KUNIT_EXPECT_EQ(test, snd_pcm_format_width(valid_fmt[i].format),
121 KUNIT_EXPECT_EQ(test, snd_pcm_format_width(WRONG_FORMAT_1), -EINVAL);
122 KUNIT_EXPECT_EQ(test, snd_pcm_format_width(WRONG_FORMAT_2), -EINVAL);
125 static void test_format_signed(struct kunit *test)
130 KUNIT_EXPECT_EQ(test, snd_pcm_format_signed(valid_fmt[i].format),
132 KUNIT_EXPECT_EQ(test, snd_pcm_format_unsigned(valid_fmt[i].format),
136 KUNIT_EXPECT_EQ(test, snd_pcm_format_width(WRONG_FORMAT_1), -EINVAL);
137 KUNIT_EXPECT_EQ(test, snd_pcm_format_width(WRONG_FORMAT_2), -EINVAL);
140 static void test_format_endianness(struct kunit *test)
145 KUNIT_EXPECT_EQ(test, snd_pcm_format_little_endian(valid_fmt[i].format),
147 KUNIT_EXPECT_EQ(test, snd_pcm_format_big_endian(valid_fmt[i].format),
151 KUNIT_EXPECT_EQ(test, snd_pcm_format_little_endian(WRONG_FORMAT_1), -EINVAL);
152 KUNIT_EXPECT_EQ(test, snd_pcm_format_little_endian(WRONG_FORMAT_2), -EINVAL);
153 KUNIT_EXPECT_EQ(test, snd_pcm_format_big_endian(WRONG_FORMAT_1), -EINVAL);
154 KUNIT_EXPECT_EQ(test, snd_pcm_format_big_endian(WRONG_FORMAT_2), -EINVAL);
157 static void _test_fill_silence(struct kunit *test, const struct snd_format_test_data *data,
163 KUNIT_ASSERT_EQ(test, snd_pcm_format_set_silence(data->format, buffer, samples_count), 0);
165 KUNIT_EXPECT_EQ(test, buffer[i], data->silence[i % sample_bytes]);
168 static void test_format_fill_silence(struct kunit *test)
174 buffer = kunit_kzalloc(test, SILENCE_BUFFER_SIZE, GFP_KERNEL);
178 _test_fill_silence(test, &valid_fmt[j], buffer, buf_samples[i]);
181 KUNIT_EXPECT_EQ(test, snd_pcm_format_set_silence(WRONG_FORMAT_1, buffer, 20), -EINVAL);
182 KUNIT_EXPECT_EQ(test, snd_pcm_format_set_silence(SNDRV_PCM_FORMAT_LAST, buffer, 0), 0);
206 static void test_playback_avail(struct kunit *test)
208 struct snd_pcm_runtime *r = kunit_kzalloc(test, sizeof(*r), GFP_KERNEL);
211 r->status = kunit_kzalloc(test, sizeof(*r->status), GFP_KERNEL);
212 r->control = kunit_kzalloc(test, sizeof(*r->control), GFP_KERNEL);
219 KUNIT_EXPECT_EQ(test, snd_pcm_playback_avail(r), p_avail_data[i].expected_avail);
230 static void test_capture_avail(struct kunit *test)
232 struct snd_pcm_runtime *r = kunit_kzalloc(test, sizeof(*r), GFP_KERNEL);
235 r->status = kunit_kzalloc(test, sizeof(*r->status), GFP_KERNEL);
236 r->control = kunit_kzalloc(test, sizeof(*r->control), GFP_KERNEL);
243 KUNIT_EXPECT_EQ(test, snd_pcm_capture_avail(r), c_avail_data[i].expected_avail);
247 static void test_card_set_id(struct kunit *test)
249 struct snd_card *card = kunit_kzalloc(test, sizeof(*card), GFP_KERNEL);
252 KUNIT_EXPECT_STREQ(test, card->id, VALID_NAME);
257 KUNIT_EXPECT_STRNEQ(test, card->id, NAME_W_SPEC_CHARS);
261 kunit_info(test, "%s", card->id);
262 KUNIT_EXPECT_STREQ(test, card->id, NAME_W_SPACE_REMOVED);
265 static void test_pcm_format_name(struct kunit *test)
272 KUNIT_ASSERT_NOT_NULL_MSG(test, name, "Don't have name for %s", valid_fmt[i].name);
273 KUNIT_EXPECT_STREQ(test, name, valid_fmt[i].name);
276 KUNIT_ASSERT_STREQ(test, snd_pcm_format_name(WRONG_FORMAT_1), "Unknown");
277 KUNIT_ASSERT_STREQ(test, snd_pcm_format_name(WRONG_FORMAT_2), "Unknown");
280 static void test_card_add_component(struct kunit *test)
282 struct snd_card *card = kunit_kzalloc(test, sizeof(*card), GFP_KERNEL);
285 KUNIT_ASSERT_STREQ(test, card->components, TEST_FIRST_COMPONENT);
288 KUNIT_ASSERT_STREQ(test, card->components, TEST_FIRST_COMPONENT " " TEST_SECOND_COMPONENT);
306 .name = "sound-core-test",
311 MODULE_DESCRIPTION("Sound core KUnit test");