Lines Matching full:test

7 #include <kunit/test.h>
8 #include <kunit/test-bug.h>
25 static int relay_test_init(struct kunit *test) in relay_test_init() argument
35 test->priv = &fake; in relay_test_init()
36 xe_kunit_helper_xe_device_test_init(test); in relay_test_init()
38 xe = test->priv; in relay_test_init()
39 KUNIT_ASSERT_EQ(test, xe_sriov_init(xe), 0); in relay_test_init()
42 kunit_activate_static_stub(test, relay_get_totalvfs, in relay_test_init()
45 KUNIT_ASSERT_EQ(test, xe_guc_relay_init(relay), 0); in relay_test_init()
46 KUNIT_EXPECT_TRUE(test, relay_is_ready(relay)); in relay_test_init()
49 test->priv = relay; in relay_test_init()
65 struct kunit *test = kunit_get_current_test(); in replacement_xe_guc_ct_send_recv_always_fails() local
67 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ct); in replacement_xe_guc_ct_send_recv_always_fails()
68 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, msg); in replacement_xe_guc_ct_send_recv_always_fails()
69 KUNIT_ASSERT_GE(test, len, GUC_HXG_MSG_MIN_LEN); in replacement_xe_guc_ct_send_recv_always_fails()
78 struct kunit *test = kunit_get_current_test(); in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay() local
80 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ct); in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay()
81 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, msg); in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay()
82 KUNIT_ASSERT_GE(test, len, PF2GUC_RELAY_TO_VF_REQUEST_MSG_MIN_LEN); in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay()
83 KUNIT_ASSERT_EQ(test, len, PF2GUC_RELAY_TO_VF_REQUEST_MSG_MIN_LEN + TEST_LEN); in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay()
84 KUNIT_EXPECT_EQ(test, GUC_HXG_ORIGIN_HOST, FIELD_GET(GUC_HXG_MSG_0_ORIGIN, msg[0])); in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay()
85 KUNIT_EXPECT_EQ(test, GUC_HXG_TYPE_REQUEST, FIELD_GET(GUC_HXG_MSG_0_TYPE, msg[0])); in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay()
86 KUNIT_EXPECT_EQ(test, XE_GUC_ACTION_PF2GUC_RELAY_TO_VF, in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay()
88 KUNIT_EXPECT_EQ(test, TEST_VFID, in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay()
90 KUNIT_EXPECT_EQ(test, TEST_RID, in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay()
92 KUNIT_EXPECT_MEMEQ(test, TEST_MSG, msg + PF2GUC_RELAY_TO_VF_REQUEST_MSG_MIN_LEN, in replacement_xe_guc_ct_send_recv_expects_pf2guc_relay()
120 static void pf_rejects_guc2pf_too_short(struct kunit *test) in pf_rejects_guc2pf_too_short() argument
123 struct xe_guc_relay *relay = test->priv; in pf_rejects_guc2pf_too_short()
126 KUNIT_ASSERT_EQ(test, -EPROTO, xe_guc_relay_process_guc2pf(relay, msg, len)); in pf_rejects_guc2pf_too_short()
129 static void pf_rejects_guc2pf_too_long(struct kunit *test) in pf_rejects_guc2pf_too_long() argument
132 struct xe_guc_relay *relay = test->priv; in pf_rejects_guc2pf_too_long()
135 KUNIT_ASSERT_EQ(test, -EMSGSIZE, xe_guc_relay_process_guc2pf(relay, msg, len)); in pf_rejects_guc2pf_too_long()
138 static void pf_rejects_guc2pf_no_payload(struct kunit *test) in pf_rejects_guc2pf_no_payload() argument
141 struct xe_guc_relay *relay = test->priv; in pf_rejects_guc2pf_no_payload()
144 KUNIT_ASSERT_EQ(test, -EPROTO, xe_guc_relay_process_guc2pf(relay, msg, len)); in pf_rejects_guc2pf_no_payload()
147 static void pf_fails_no_payload(struct kunit *test) in pf_fails_no_payload() argument
149 struct xe_guc_relay *relay = test->priv; in pf_fails_no_payload()
152 KUNIT_ASSERT_EQ(test, -EPROTO, relay_process_msg(relay, TEST_VFID, TEST_RID, &msg, 0)); in pf_fails_no_payload()
155 static void pf_fails_bad_origin(struct kunit *test) in pf_fails_bad_origin() argument
157 struct xe_guc_relay *relay = test->priv; in pf_fails_bad_origin()
164 KUNIT_ASSERT_EQ(test, -EPROTO, relay_process_msg(relay, TEST_VFID, TEST_RID, msg, len)); in pf_fails_bad_origin()
167 static void pf_fails_bad_type(struct kunit *test) in pf_fails_bad_type() argument
169 struct xe_guc_relay *relay = test->priv; in pf_fails_bad_type()
176 KUNIT_ASSERT_EQ(test, -EBADRQC, relay_process_msg(relay, TEST_VFID, TEST_RID, msg, len)); in pf_fails_bad_type()
179 static void pf_txn_reports_error(struct kunit *test) in pf_txn_reports_error() argument
181 struct xe_guc_relay *relay = test->priv; in pf_txn_reports_error()
186 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, txn); in pf_txn_reports_error()
188 kunit_activate_static_stub(test, xe_guc_ct_send_recv, in pf_txn_reports_error()
190 KUNIT_EXPECT_EQ(test, -ECOMM, relay_send_transaction(relay, txn)); in pf_txn_reports_error()
195 static void pf_txn_sends_pf2guc(struct kunit *test) in pf_txn_sends_pf2guc() argument
197 struct xe_guc_relay *relay = test->priv; in pf_txn_sends_pf2guc()
202 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, txn); in pf_txn_sends_pf2guc()
204 kunit_activate_static_stub(test, xe_guc_ct_send_recv, in pf_txn_sends_pf2guc()
206 KUNIT_ASSERT_EQ(test, 0, relay_send_transaction(relay, txn)); in pf_txn_sends_pf2guc()
211 static void pf_sends_pf2guc(struct kunit *test) in pf_sends_pf2guc() argument
213 struct xe_guc_relay *relay = test->priv; in pf_sends_pf2guc()
215 kunit_activate_static_stub(test, xe_guc_ct_send_recv, in pf_sends_pf2guc()
217 KUNIT_ASSERT_EQ(test, 0, in pf_sends_pf2guc()
226 struct kunit *test = kunit_get_current_test(); in replacement_xe_guc_ct_send_recv_loopback_relay() local
227 struct xe_guc_relay *relay = test->priv; in replacement_xe_guc_ct_send_recv_loopback_relay()
228 u32 *reply = kunit_kzalloc(test, len * sizeof(u32), GFP_KERNEL); in replacement_xe_guc_ct_send_recv_loopback_relay()
233 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ct); in replacement_xe_guc_ct_send_recv_loopback_relay()
234 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, msg); in replacement_xe_guc_ct_send_recv_loopback_relay()
235 KUNIT_ASSERT_GE(test, len, GUC_HXG_MSG_MIN_LEN); in replacement_xe_guc_ct_send_recv_loopback_relay()
236 KUNIT_ASSERT_EQ(test, GUC_HXG_TYPE_REQUEST, in replacement_xe_guc_ct_send_recv_loopback_relay()
238 KUNIT_ASSERT_GE(test, len, GUC_HXG_REQUEST_MSG_MIN_LEN); in replacement_xe_guc_ct_send_recv_loopback_relay()
239 KUNIT_ASSERT_NOT_NULL(test, reply); in replacement_xe_guc_ct_send_recv_loopback_relay()
243 KUNIT_ASSERT_GE(test, len, PF2GUC_RELAY_TO_VF_REQUEST_MSG_MIN_LEN); in replacement_xe_guc_ct_send_recv_loopback_relay()
248 KUNIT_ASSERT_GE(test, len, VF2GUC_RELAY_TO_PF_REQUEST_MSG_MIN_LEN); in replacement_xe_guc_ct_send_recv_loopback_relay()
253 KUNIT_FAIL(test, "bad RELAY action %#x", msg[0]); in replacement_xe_guc_ct_send_recv_loopback_relay()
263 KUNIT_EXPECT_EQ(test, err, 0); in replacement_xe_guc_ct_send_recv_loopback_relay()
268 static void test_requires_relay_testloop(struct kunit *test) in test_requires_relay_testloop() argument
276 kunit_skip(test, "requires %s\n", __stringify(CONFIG_DRM_XE_DEBUG_SRIOV)); in test_requires_relay_testloop()
279 static void pf_loopback_nop(struct kunit *test) in pf_loopback_nop() argument
281 struct xe_guc_relay *relay = test->priv; in pf_loopback_nop()
291 test_requires_relay_testloop(test); in pf_loopback_nop()
293 kunit_activate_static_stub(test, relay_kick_worker, relay_process_incoming_action); in pf_loopback_nop()
294 kunit_activate_static_stub(test, xe_guc_ct_send_recv, in pf_loopback_nop()
299 KUNIT_ASSERT_EQ(test, ret, GUC_HXG_RESPONSE_MSG_MIN_LEN); in pf_loopback_nop()
300 KUNIT_EXPECT_EQ(test, FIELD_GET(GUC_HXG_MSG_0_ORIGIN, response[0]), in pf_loopback_nop()
302 KUNIT_EXPECT_EQ(test, FIELD_GET(GUC_HXG_MSG_0_TYPE, response[0]), in pf_loopback_nop()
304 KUNIT_EXPECT_EQ(test, FIELD_GET(GUC_HXG_RESPONSE_MSG_0_DATA0, response[0]), 0); in pf_loopback_nop()
307 static void pf_loopback_echo(struct kunit *test) in pf_loopback_echo() argument
309 struct xe_guc_relay *relay = test->priv; in pf_loopback_echo()
321 test_requires_relay_testloop(test); in pf_loopback_echo()
323 kunit_activate_static_stub(test, relay_kick_worker, relay_process_incoming_action); in pf_loopback_echo()
324 kunit_activate_static_stub(test, xe_guc_ct_send_recv, in pf_loopback_echo()
329 KUNIT_ASSERT_EQ(test, ret, ARRAY_SIZE(response)); in pf_loopback_echo()
330 KUNIT_EXPECT_EQ(test, FIELD_GET(GUC_HXG_MSG_0_ORIGIN, response[0]), in pf_loopback_echo()
332 KUNIT_EXPECT_EQ(test, FIELD_GET(GUC_HXG_MSG_0_TYPE, response[0]), in pf_loopback_echo()
334 KUNIT_EXPECT_EQ(test, FIELD_GET(GUC_HXG_RESPONSE_MSG_0_DATA0, response[0]), in pf_loopback_echo()
337 KUNIT_EXPECT_EQ(test, request[n], response[n]); in pf_loopback_echo()
340 static void pf_loopback_fail(struct kunit *test) in pf_loopback_fail() argument
342 struct xe_guc_relay *relay = test->priv; in pf_loopback_fail()
352 test_requires_relay_testloop(test); in pf_loopback_fail()
354 kunit_activate_static_stub(test, relay_kick_worker, relay_process_incoming_action); in pf_loopback_fail()
355 kunit_activate_static_stub(test, xe_guc_ct_send_recv, in pf_loopback_fail()
360 KUNIT_ASSERT_EQ(test, ret, -EREMOTEIO); in pf_loopback_fail()
363 static void pf_loopback_busy(struct kunit *test) in pf_loopback_busy() argument
365 struct xe_guc_relay *relay = test->priv; in pf_loopback_busy()
376 test_requires_relay_testloop(test); in pf_loopback_busy()
378 kunit_activate_static_stub(test, relay_testonly_nop, relay_process_incoming_action); in pf_loopback_busy()
379 kunit_activate_static_stub(test, relay_kick_worker, relay_process_incoming_action); in pf_loopback_busy()
380 kunit_activate_static_stub(test, xe_guc_ct_send_recv, in pf_loopback_busy()
385 KUNIT_ASSERT_EQ(test, ret, GUC_HXG_RESPONSE_MSG_MIN_LEN); in pf_loopback_busy()
388 static void pf_loopback_retry(struct kunit *test) in pf_loopback_retry() argument
390 struct xe_guc_relay *relay = test->priv; in pf_loopback_retry()
401 test_requires_relay_testloop(test); in pf_loopback_retry()
403 kunit_activate_static_stub(test, relay_kick_worker, relay_process_incoming_action); in pf_loopback_retry()
404 kunit_activate_static_stub(test, xe_guc_ct_send_recv, in pf_loopback_retry()
409 KUNIT_ASSERT_EQ(test, ret, GUC_HXG_RESPONSE_MSG_MIN_LEN); in pf_loopback_retry()
436 static void vf_rejects_guc2vf_too_short(struct kunit *test) in vf_rejects_guc2vf_too_short() argument
439 struct xe_guc_relay *relay = test->priv; in vf_rejects_guc2vf_too_short()
442 KUNIT_ASSERT_EQ(test, -EPROTO, xe_guc_relay_process_guc2vf(relay, msg, len)); in vf_rejects_guc2vf_too_short()
445 static void vf_rejects_guc2vf_too_long(struct kunit *test) in vf_rejects_guc2vf_too_long() argument
448 struct xe_guc_relay *relay = test->priv; in vf_rejects_guc2vf_too_long()
451 KUNIT_ASSERT_EQ(test, -EMSGSIZE, xe_guc_relay_process_guc2vf(relay, msg, len)); in vf_rejects_guc2vf_too_long()
454 static void vf_rejects_guc2vf_no_payload(struct kunit *test) in vf_rejects_guc2vf_no_payload() argument
457 struct xe_guc_relay *relay = test->priv; in vf_rejects_guc2vf_no_payload()
460 KUNIT_ASSERT_EQ(test, -EPROTO, xe_guc_relay_process_guc2vf(relay, msg, len)); in vf_rejects_guc2vf_no_payload()
476 static void xe_drops_guc2pf_if_not_ready(struct kunit *test) in xe_drops_guc2pf_if_not_ready() argument
478 struct xe_device *xe = test->priv; in xe_drops_guc2pf_if_not_ready()
483 KUNIT_ASSERT_EQ(test, -ENODEV, xe_guc_relay_process_guc2pf(relay, msg, len)); in xe_drops_guc2pf_if_not_ready()
486 static void xe_drops_guc2vf_if_not_ready(struct kunit *test) in xe_drops_guc2vf_if_not_ready() argument
488 struct xe_device *xe = test->priv; in xe_drops_guc2vf_if_not_ready()
493 KUNIT_ASSERT_EQ(test, -ENODEV, xe_guc_relay_process_guc2vf(relay, msg, len)); in xe_drops_guc2vf_if_not_ready()
496 static void xe_rejects_send_if_not_ready(struct kunit *test) in xe_rejects_send_if_not_ready() argument
498 struct xe_device *xe = test->priv; in xe_rejects_send_if_not_ready()
503 KUNIT_ASSERT_EQ(test, -ENODEV, xe_guc_relay_send_to_pf(relay, msg, len, NULL, 0)); in xe_rejects_send_if_not_ready()
504 KUNIT_ASSERT_EQ(test, -ENODEV, relay_send_to(relay, TEST_VFID, msg, len, NULL, 0)); in xe_rejects_send_if_not_ready()