Lines Matching full:test
6 #include <kunit/test.h>
25 static void cros_ec_proto_test_prepare_tx_legacy_normal(struct kunit *test) in cros_ec_proto_test_prepare_tx_legacy_normal() argument
27 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_prepare_tx_legacy_normal()
44 KUNIT_EXPECT_EQ(test, ret, EC_MSG_TX_PROTO_BYTES + EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_proto_test_prepare_tx_legacy_normal()
45 KUNIT_EXPECT_EQ(test, ec_dev->dout[0], EC_CMD_VERSION0); in cros_ec_proto_test_prepare_tx_legacy_normal()
46 KUNIT_EXPECT_EQ(test, ec_dev->dout[1], EC_CMD_HELLO); in cros_ec_proto_test_prepare_tx_legacy_normal()
47 KUNIT_EXPECT_EQ(test, ec_dev->dout[2], EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_proto_test_prepare_tx_legacy_normal()
48 KUNIT_EXPECT_EQ(test, EC_MSG_TX_HEADER_BYTES, 3); in cros_ec_proto_test_prepare_tx_legacy_normal()
49 KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 0], 0xde); in cros_ec_proto_test_prepare_tx_legacy_normal()
50 KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 1], 0xad); in cros_ec_proto_test_prepare_tx_legacy_normal()
51 KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 2], 0xbe); in cros_ec_proto_test_prepare_tx_legacy_normal()
52 KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 3], 0xef); in cros_ec_proto_test_prepare_tx_legacy_normal()
54 KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + i], 0); in cros_ec_proto_test_prepare_tx_legacy_normal()
63 KUNIT_EXPECT_EQ(test, in cros_ec_proto_test_prepare_tx_legacy_normal()
68 static void cros_ec_proto_test_prepare_tx_legacy_bad_msg_outsize(struct kunit *test) in cros_ec_proto_test_prepare_tx_legacy_bad_msg_outsize() argument
70 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_prepare_tx_legacy_bad_msg_outsize()
80 KUNIT_EXPECT_EQ(test, ret, -EINVAL); in cros_ec_proto_test_prepare_tx_legacy_bad_msg_outsize()
83 static void cros_ec_proto_test_prepare_tx_normal(struct kunit *test) in cros_ec_proto_test_prepare_tx_normal() argument
85 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_prepare_tx_normal()
101 KUNIT_EXPECT_EQ(test, ret, sizeof(*request) + 0x88); in cros_ec_proto_test_prepare_tx_normal()
103 KUNIT_EXPECT_EQ(test, request->struct_version, EC_HOST_REQUEST_VERSION); in cros_ec_proto_test_prepare_tx_normal()
104 KUNIT_EXPECT_EQ(test, request->command, EC_CMD_HELLO); in cros_ec_proto_test_prepare_tx_normal()
105 KUNIT_EXPECT_EQ(test, request->command_version, 0); in cros_ec_proto_test_prepare_tx_normal()
106 KUNIT_EXPECT_EQ(test, request->data_len, 0x88); in cros_ec_proto_test_prepare_tx_normal()
107 KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 0], 0xde); in cros_ec_proto_test_prepare_tx_normal()
108 KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 1], 0xad); in cros_ec_proto_test_prepare_tx_normal()
109 KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 2], 0xbe); in cros_ec_proto_test_prepare_tx_normal()
110 KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 3], 0xef); in cros_ec_proto_test_prepare_tx_normal()
112 KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + i], 0); in cros_ec_proto_test_prepare_tx_normal()
121 KUNIT_EXPECT_EQ(test, request->checksum, (u8)-csum); in cros_ec_proto_test_prepare_tx_normal()
124 static void cros_ec_proto_test_prepare_tx_bad_msg_outsize(struct kunit *test) in cros_ec_proto_test_prepare_tx_bad_msg_outsize() argument
126 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_prepare_tx_bad_msg_outsize()
134 KUNIT_EXPECT_EQ(test, ret, -EINVAL); in cros_ec_proto_test_prepare_tx_bad_msg_outsize()
137 static void cros_ec_proto_test_check_result(struct kunit *test) in cros_ec_proto_test_check_result() argument
139 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_check_result()
169 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_check_result()
174 KUNIT_EXPECT_EQ(test, ret, -EAGAIN); in cros_ec_proto_test_check_result()
177 static void cros_ec_proto_test_query_all_pretest(struct kunit *test) in cros_ec_proto_test_query_all_pretest() argument
179 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_pretest()
192 static void cros_ec_proto_test_query_all_normal(struct kunit *test) in cros_ec_proto_test_query_all_normal() argument
194 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_normal()
203 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
204 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
216 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
217 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
227 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
228 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
238 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
239 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
249 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
250 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
256 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_normal()
258 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_normal()
263 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
265 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_normal()
266 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_normal()
267 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_normal()
269 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_normal()
271 KUNIT_EXPECT_EQ(test, ec_dev->max_request, 0xbe - sizeof(struct ec_host_request)); in cros_ec_proto_test_query_all_normal()
272 KUNIT_EXPECT_EQ(test, ec_dev->max_response, 0xef - sizeof(struct ec_host_response)); in cros_ec_proto_test_query_all_normal()
273 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, 3); in cros_ec_proto_test_query_all_normal()
274 KUNIT_EXPECT_EQ(test, ec_dev->din_size, 0xef + EC_MAX_RESPONSE_OVERHEAD); in cros_ec_proto_test_query_all_normal()
275 KUNIT_EXPECT_EQ(test, ec_dev->dout_size, 0xbe + EC_MAX_REQUEST_OVERHEAD); in cros_ec_proto_test_query_all_normal()
281 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
283 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_normal()
284 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_normal()
287 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_normal()
289 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_normal()
291 KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0xbf - sizeof(struct ec_host_request)); in cros_ec_proto_test_query_all_normal()
299 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
301 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_normal()
302 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_normal()
303 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_normal()
305 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
308 KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_query_all_normal()
310 KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 7); in cros_ec_proto_test_query_all_normal()
318 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
320 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_normal()
321 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_normal()
322 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_normal()
324 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
327 KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_HOST_SLEEP_EVENT); in cros_ec_proto_test_query_all_normal()
329 KUNIT_EXPECT_TRUE(test, ec_dev->host_sleep_v1); in cros_ec_proto_test_query_all_normal()
335 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
337 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_normal()
338 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HOST_EVENT_GET_WAKE_MASK); in cros_ec_proto_test_query_all_normal()
339 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_host_event_mask)); in cros_ec_proto_test_query_all_normal()
340 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_normal()
342 KUNIT_EXPECT_EQ(test, ec_dev->host_event_wake_mask, 0xbeef); in cros_ec_proto_test_query_all_normal()
346 static void cros_ec_proto_test_query_all_no_pd_return_error(struct kunit *test) in cros_ec_proto_test_query_all_no_pd_return_error() argument
348 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_pd_return_error()
360 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_pd_return_error()
361 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return_error()
374 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
375 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return_error()
378 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_pd_return_error()
380 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
385 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return_error()
387 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
388 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_pd_return_error()
389 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_pd_return_error()
391 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
397 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return_error()
399 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
400 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_pd_return_error()
403 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_pd_return_error()
405 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
407 KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
411 static void cros_ec_proto_test_query_all_no_pd_return0(struct kunit *test) in cros_ec_proto_test_query_all_no_pd_return0() argument
413 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_pd_return0()
425 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_pd_return0()
426 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return0()
439 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_no_pd_return0()
440 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return0()
443 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_pd_return0()
445 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_pd_return0()
450 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return0()
452 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_pd_return0()
453 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_pd_return0()
454 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_pd_return0()
456 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_pd_return0()
462 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return0()
464 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_pd_return0()
465 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_pd_return0()
468 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_pd_return0()
470 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_pd_return0()
472 KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0); in cros_ec_proto_test_query_all_no_pd_return0()
476 static void cros_ec_proto_test_query_all_legacy_normal_v3_return_error(struct kunit *test) in cros_ec_proto_test_query_all_legacy_normal_v3_return_error() argument
478 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
485 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
486 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
493 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
494 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
500 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
502 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
507 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
509 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
510 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
511 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
513 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
521 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
523 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
524 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
525 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
526 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
529 KUNIT_EXPECT_EQ(test, data->in_data, 0xa0b0c0d0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
531 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, 2); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
532 KUNIT_EXPECT_EQ(test, ec_dev->max_request, EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
533 KUNIT_EXPECT_EQ(test, ec_dev->max_response, EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
534 KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
535 KUNIT_EXPECT_PTR_EQ(test, ec_dev->pkt_xfer, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
536 KUNIT_EXPECT_EQ(test, ec_dev->din_size, EC_PROTO2_MSG_BYTES); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
537 KUNIT_EXPECT_EQ(test, ec_dev->dout_size, EC_PROTO2_MSG_BYTES); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
541 static void cros_ec_proto_test_query_all_legacy_normal_v3_return0(struct kunit *test) in cros_ec_proto_test_query_all_legacy_normal_v3_return0() argument
543 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
550 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
551 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
558 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
559 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
565 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
567 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
572 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
574 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
575 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
576 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
578 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
586 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
588 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
589 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
590 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
591 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
594 KUNIT_EXPECT_EQ(test, data->in_data, 0xa0b0c0d0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
596 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, 2); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
597 KUNIT_EXPECT_EQ(test, ec_dev->max_request, EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
598 KUNIT_EXPECT_EQ(test, ec_dev->max_response, EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
599 KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
600 KUNIT_EXPECT_PTR_EQ(test, ec_dev->pkt_xfer, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
601 KUNIT_EXPECT_EQ(test, ec_dev->din_size, EC_PROTO2_MSG_BYTES); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
602 KUNIT_EXPECT_EQ(test, ec_dev->dout_size, EC_PROTO2_MSG_BYTES); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
606 static void cros_ec_proto_test_query_all_legacy_xfer_error(struct kunit *test) in cros_ec_proto_test_query_all_legacy_xfer_error() argument
608 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_xfer_error()
615 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_xfer_error()
616 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_xfer_error()
621 mock = cros_kunit_ec_xfer_mock_addx(test, -EIO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_query_all_legacy_xfer_error()
622 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_xfer_error()
625 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_xfer_error()
627 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_query_all_legacy_xfer_error()
628 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN); in cros_ec_proto_test_query_all_legacy_xfer_error()
633 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_xfer_error()
635 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_xfer_error()
636 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_xfer_error()
637 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_xfer_error()
639 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_xfer_error()
645 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_xfer_error()
647 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_xfer_error()
648 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_xfer_error()
649 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_xfer_error()
650 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello)); in cros_ec_proto_test_query_all_legacy_xfer_error()
654 static void cros_ec_proto_test_query_all_legacy_return_error(struct kunit *test) in cros_ec_proto_test_query_all_legacy_return_error() argument
656 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_return_error()
663 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_return_error()
664 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return_error()
669 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_return_error()
670 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return_error()
673 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_return_error()
675 KUNIT_EXPECT_EQ(test, ret, -EOPNOTSUPP); in cros_ec_proto_test_query_all_legacy_return_error()
676 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN); in cros_ec_proto_test_query_all_legacy_return_error()
681 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return_error()
683 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_return_error()
684 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_return_error()
685 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_return_error()
687 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_return_error()
693 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return_error()
695 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_return_error()
696 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_return_error()
697 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_return_error()
698 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello)); in cros_ec_proto_test_query_all_legacy_return_error()
702 static void cros_ec_proto_test_query_all_legacy_data_error(struct kunit *test) in cros_ec_proto_test_query_all_legacy_data_error() argument
704 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_data_error()
711 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_data_error()
712 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_data_error()
719 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_legacy_data_error()
720 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_data_error()
726 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_data_error()
728 KUNIT_EXPECT_EQ(test, ret, -EBADMSG); in cros_ec_proto_test_query_all_legacy_data_error()
729 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN); in cros_ec_proto_test_query_all_legacy_data_error()
734 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_data_error()
736 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_data_error()
737 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_data_error()
738 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_data_error()
740 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_data_error()
746 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_data_error()
748 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_data_error()
749 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_data_error()
750 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_data_error()
751 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello)); in cros_ec_proto_test_query_all_legacy_data_error()
755 static void cros_ec_proto_test_query_all_legacy_return0(struct kunit *test) in cros_ec_proto_test_query_all_legacy_return0() argument
757 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_return0()
764 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_return0()
765 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return0()
770 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_legacy_return0()
771 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return0()
774 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_return0()
776 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_query_all_legacy_return0()
777 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN); in cros_ec_proto_test_query_all_legacy_return0()
782 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return0()
784 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_return0()
785 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_return0()
786 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_return0()
788 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_return0()
794 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return0()
796 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_return0()
797 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_return0()
798 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_return0()
799 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello)); in cros_ec_proto_test_query_all_legacy_return0()
803 static void cros_ec_proto_test_query_all_no_mkbp(struct kunit *test) in cros_ec_proto_test_query_all_no_mkbp() argument
805 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_mkbp()
817 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp()
818 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
831 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_no_mkbp()
832 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
839 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp()
840 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
846 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_mkbp()
848 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_mkbp()
853 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
855 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp()
856 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_mkbp()
857 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp()
859 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp()
865 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
867 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp()
868 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_mkbp()
871 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp()
873 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp()
881 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
883 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp()
884 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_mkbp()
885 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp()
887 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp()
890 KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_query_all_no_mkbp()
892 KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0); in cros_ec_proto_test_query_all_no_mkbp()
896 static void cros_ec_proto_test_query_all_no_mkbp_return_error(struct kunit *test) in cros_ec_proto_test_query_all_no_mkbp_return_error() argument
898 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_mkbp_return_error()
910 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp_return_error()
911 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
924 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
925 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
930 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
931 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
934 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_mkbp_return_error()
936 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
941 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
943 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
944 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_mkbp_return_error()
945 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return_error()
947 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
953 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
955 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
956 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_mkbp_return_error()
959 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return_error()
961 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
969 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
971 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
972 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_mkbp_return_error()
973 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return_error()
975 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp_return_error()
978 KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_query_all_no_mkbp_return_error()
980 KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
984 static void cros_ec_proto_test_query_all_no_mkbp_return0(struct kunit *test) in cros_ec_proto_test_query_all_no_mkbp_return0() argument
986 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_mkbp_return0()
998 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp_return0()
999 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1012 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1013 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1018 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1019 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1022 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_mkbp_return0()
1024 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1029 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1031 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1032 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_mkbp_return0()
1033 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return0()
1035 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1041 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1043 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1044 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_mkbp_return0()
1047 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return0()
1049 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1057 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1059 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1060 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_mkbp_return0()
1061 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return0()
1063 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp_return0()
1066 KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_query_all_no_mkbp_return0()
1068 KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1072 static void cros_ec_proto_test_query_all_no_host_sleep(struct kunit *test) in cros_ec_proto_test_query_all_no_host_sleep() argument
1074 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_host_sleep()
1086 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_host_sleep()
1087 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1100 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1101 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1106 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1107 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1114 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_host_sleep()
1115 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1121 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_host_sleep()
1123 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1128 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1130 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1131 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_host_sleep()
1132 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep()
1134 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1140 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1142 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1143 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_host_sleep()
1146 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep()
1148 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1154 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1156 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1157 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_host_sleep()
1158 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep()
1160 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); in cros_ec_proto_test_query_all_no_host_sleep()
1166 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1168 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1169 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_host_sleep()
1170 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep()
1172 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); in cros_ec_proto_test_query_all_no_host_sleep()
1174 KUNIT_EXPECT_FALSE(test, ec_dev->host_sleep_v1); in cros_ec_proto_test_query_all_no_host_sleep()
1178 static void cros_ec_proto_test_query_all_no_host_sleep_return0(struct kunit *test) in cros_ec_proto_test_query_all_no_host_sleep_return0() argument
1180 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_host_sleep_return0()
1192 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1193 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1206 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1207 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1214 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1215 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1224 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1225 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1228 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1230 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1235 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1237 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1238 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1239 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep_return0()
1241 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1247 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1249 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1250 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_host_sleep_return0()
1253 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep_return0()
1255 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1261 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1263 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1264 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1265 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep_return0()
1267 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1273 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1275 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1276 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1277 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep_return0()
1279 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1281 KUNIT_EXPECT_FALSE(test, ec_dev->host_sleep_v1); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1285 static void cros_ec_proto_test_query_all_default_wake_mask_return_error(struct kunit *test) in cros_ec_proto_test_query_all_default_wake_mask_return_error() argument
1287 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1299 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1300 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1313 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1314 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1319 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1320 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1325 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1326 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1331 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1332 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1335 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1337 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1342 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1344 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1345 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1346 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1348 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1354 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1356 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1357 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1360 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1362 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1368 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1370 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1371 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1372 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1374 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1380 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1382 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1383 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1384 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1386 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1394 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1396 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1397 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HOST_EVENT_GET_WAKE_MASK); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1398 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_host_event_mask)); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1399 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1402 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED), 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1403 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED), 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1404 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_LOW), 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1405 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_CRITICAL), 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1406 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY), 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1407 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU), 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1408 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_STATUS), 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1412 static void cros_ec_proto_test_query_all_default_wake_mask_return0(struct kunit *test) in cros_ec_proto_test_query_all_default_wake_mask_return0() argument
1414 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_default_wake_mask_return0()
1426 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1427 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1440 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1441 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1446 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1447 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1452 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1453 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1458 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1459 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1462 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1464 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1469 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1471 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1472 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1473 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return0()
1475 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1481 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1483 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1484 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_default_wake_mask_return0()
1487 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return0()
1489 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1495 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1497 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1498 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1499 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return0()
1501 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1507 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1509 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1510 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1511 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return0()
1513 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1521 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1523 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1524 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HOST_EVENT_GET_WAKE_MASK); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1525 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_host_event_mask)); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1526 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1529 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED), 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1530 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED), 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1531 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_LOW), 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1532 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_CRITICAL), 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1533 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY), 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1534 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU), 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1535 KUNIT_EXPECT_EQ(test, mask & EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_STATUS), 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1539 static void cros_ec_proto_test_cmd_xfer_normal(struct kunit *test) in cros_ec_proto_test_cmd_xfer_normal() argument
1541 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_normal()
1564 mock = cros_kunit_ec_xfer_mock_add(test, 4); in cros_ec_proto_test_cmd_xfer_normal()
1565 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_normal()
1575 KUNIT_EXPECT_EQ(test, ret, 4); in cros_ec_proto_test_cmd_xfer_normal()
1581 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_normal()
1583 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_cmd_xfer_normal()
1584 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_cmd_xfer_normal()
1585 KUNIT_EXPECT_EQ(test, mock->msg.insize, 4); in cros_ec_proto_test_cmd_xfer_normal()
1586 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 2); in cros_ec_proto_test_cmd_xfer_normal()
1589 KUNIT_EXPECT_EQ(test, data[0], 0x55); in cros_ec_proto_test_cmd_xfer_normal()
1590 KUNIT_EXPECT_EQ(test, data[1], 0xaa); in cros_ec_proto_test_cmd_xfer_normal()
1592 KUNIT_EXPECT_EQ(test, buf.data[0], 0xaa); in cros_ec_proto_test_cmd_xfer_normal()
1593 KUNIT_EXPECT_EQ(test, buf.data[1], 0x55); in cros_ec_proto_test_cmd_xfer_normal()
1594 KUNIT_EXPECT_EQ(test, buf.data[2], 0xcc); in cros_ec_proto_test_cmd_xfer_normal()
1595 KUNIT_EXPECT_EQ(test, buf.data[3], 0x33); in cros_ec_proto_test_cmd_xfer_normal()
1599 static void cros_ec_proto_test_cmd_xfer_excess_msg_insize(struct kunit *test) in cros_ec_proto_test_cmd_xfer_excess_msg_insize() argument
1601 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1620 mock = cros_kunit_ec_xfer_mock_add(test, 0xcc); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1621 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1625 KUNIT_EXPECT_EQ(test, ret, 0xcc); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1629 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1631 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1632 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1633 KUNIT_EXPECT_EQ(test, mock->msg.insize, 0xee); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1634 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 2); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1638 static void cros_ec_proto_test_cmd_xfer_excess_msg_outsize_without_passthru(struct kunit *test) in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_without_passthru() argument
1640 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_without_passthru()
1658 KUNIT_EXPECT_EQ(test, ret, -EMSGSIZE); in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_without_passthru()
1661 static void cros_ec_proto_test_cmd_xfer_excess_msg_outsize_with_passthru(struct kunit *test) in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_with_passthru() argument
1663 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_with_passthru()
1681 KUNIT_EXPECT_EQ(test, ret, -EMSGSIZE); in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_with_passthru()
1684 static void cros_ec_proto_test_cmd_xfer_protocol_v3_normal(struct kunit *test) in cros_ec_proto_test_cmd_xfer_protocol_v3_normal() argument
1686 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1698 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1700 KUNIT_EXPECT_EQ(test, cros_kunit_ec_cmd_xfer_mock_called, 0); in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1701 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 1); in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1704 static void cros_ec_proto_test_cmd_xfer_protocol_v3_no_op(struct kunit *test) in cros_ec_proto_test_cmd_xfer_protocol_v3_no_op() argument
1706 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v3_no_op()
1718 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_cmd_xfer_protocol_v3_no_op()
1721 static void cros_ec_proto_test_cmd_xfer_protocol_v2_normal(struct kunit *test) in cros_ec_proto_test_cmd_xfer_protocol_v2_normal() argument
1723 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1735 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1737 KUNIT_EXPECT_EQ(test, cros_kunit_ec_cmd_xfer_mock_called, 1); in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1738 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 0); in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1741 static void cros_ec_proto_test_cmd_xfer_protocol_v2_no_op(struct kunit *test) in cros_ec_proto_test_cmd_xfer_protocol_v2_no_op() argument
1743 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v2_no_op()
1755 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_cmd_xfer_protocol_v2_no_op()
1758 static void cros_ec_proto_test_cmd_xfer_in_progress_normal(struct kunit *test) in cros_ec_proto_test_cmd_xfer_in_progress_normal() argument
1760 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1772 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1773 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1780 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1781 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1788 KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_comms_status)); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1790 KUNIT_EXPECT_EQ(test, msg.result, EC_RES_SUCCESS); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1795 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1801 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1803 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1804 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_COMMS_STATUS); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1805 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1807 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1810 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1813 static void cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain(struct kunit *test) in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain() argument
1815 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1827 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1828 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1835 KUNIT_EXPECT_EQ(test, ret, -EAGAIN); in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1838 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 51); in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1841 static void cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing(struct kunit *test) in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing() argument
1843 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1855 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1856 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1865 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1866 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1874 KUNIT_EXPECT_EQ(test, ret, -EAGAIN); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1877 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 51); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1880 static void cros_ec_proto_test_cmd_xfer_in_progress_xfer_error(struct kunit *test) in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error() argument
1882 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1892 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1893 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1898 mock = cros_kunit_ec_xfer_mock_addx(test, -EIO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1899 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1903 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1906 static void cros_ec_proto_test_cmd_xfer_in_progress_return_error(struct kunit *test) in cros_ec_proto_test_cmd_xfer_in_progress_return_error() argument
1908 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1920 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1921 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1926 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1927 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1931 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1933 KUNIT_EXPECT_EQ(test, msg.result, EC_RES_INVALID_COMMAND); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1935 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1938 static void cros_ec_proto_test_cmd_xfer_in_progress_return0(struct kunit *test) in cros_ec_proto_test_cmd_xfer_in_progress_return0() argument
1940 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1952 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1953 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1958 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1959 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1963 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1965 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1968 static void cros_ec_proto_test_cmd_xfer_status_normal(struct kunit *test) in cros_ec_proto_test_cmd_xfer_status_normal() argument
1970 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_status_normal()
1980 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_cmd_xfer_status_normal()
1981 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_status_normal()
1985 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_status_normal()
1988 static void cros_ec_proto_test_cmd_xfer_status_xfer_error(struct kunit *test) in cros_ec_proto_test_cmd_xfer_status_xfer_error() argument
1990 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_status_xfer_error()
2000 mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_cmd_xfer_status_xfer_error()
2001 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_status_xfer_error()
2005 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_cmd_xfer_status_xfer_error()
2008 static void cros_ec_proto_test_cmd_xfer_status_return_error(struct kunit *test) in cros_ec_proto_test_cmd_xfer_status_return_error() argument
2010 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_status_return_error()
2048 mock = cros_kunit_ec_xfer_mock_addx(test, 0, i, 0); in cros_ec_proto_test_cmd_xfer_status_return_error()
2049 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_status_return_error()
2052 KUNIT_EXPECT_EQ(test, ret, map[i]); in cros_ec_proto_test_cmd_xfer_status_return_error()
2056 static void cros_ec_proto_test_get_next_event_no_mkbp_event(struct kunit *test) in cros_ec_proto_test_get_next_event_no_mkbp_event() argument
2058 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_no_mkbp_event()
2076 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2077 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2084 KUNIT_EXPECT_EQ(test, ret, sizeof(union ec_response_get_next_data_v1)); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2086 KUNIT_EXPECT_EQ(test, ec_dev->event_data.event_type, EC_MKBP_EVENT_KEY_MATRIX); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2087 KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.host_event, 0xbeef); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2089 KUNIT_EXPECT_TRUE(test, wake_event); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2090 KUNIT_EXPECT_FALSE(test, more_events); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2095 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2097 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2098 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MKBP_STATE); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2099 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(union ec_response_get_next_data_v1)); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2100 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2104 static void cros_ec_proto_test_get_next_event_mkbp_event_ec_suspended(struct kunit *test) in cros_ec_proto_test_get_next_event_mkbp_event_ec_suspended() argument
2106 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_ec_suspended()
2114 KUNIT_EXPECT_EQ(test, ret, -EHOSTDOWN); in cros_ec_proto_test_get_next_event_mkbp_event_ec_suspended()
2117 static void cros_ec_proto_test_get_next_event_mkbp_event_version0(struct kunit *test) in cros_ec_proto_test_get_next_event_mkbp_event_version0() argument
2119 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2137 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2138 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2146 KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_next_event)); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2148 KUNIT_EXPECT_EQ(test, ec_dev->event_data.event_type, EC_MKBP_EVENT_SENSOR_FIFO); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2149 KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.sysrq, 0xbeef); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2151 KUNIT_EXPECT_FALSE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2152 KUNIT_EXPECT_TRUE(test, more_events); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2157 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2159 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2160 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2161 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_get_next_event)); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2162 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2166 static void cros_ec_proto_test_get_next_event_mkbp_event_version2(struct kunit *test) in cros_ec_proto_test_get_next_event_mkbp_event_version2() argument
2168 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2186 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2187 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2195 KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_next_event_v1)); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2197 KUNIT_EXPECT_EQ(test, ec_dev->event_data.event_type, EC_MKBP_EVENT_FINGERPRINT); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2198 KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.sysrq, 0xbeef); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2200 KUNIT_EXPECT_TRUE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2201 KUNIT_EXPECT_FALSE(test, more_events); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2206 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2208 KUNIT_EXPECT_EQ(test, mock->msg.version, 2); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2209 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2210 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2212 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2216 static void cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc(struct kunit *test) in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc() argument
2218 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2235 mock = cros_kunit_ec_xfer_mock_add(test, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2238 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2246 KUNIT_EXPECT_EQ(test, ret, sizeof(data->event_type) + sizeof(data->data.host_event)); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2248 KUNIT_EXPECT_EQ(test, ec_dev->event_data.event_type, EC_MKBP_EVENT_HOST_EVENT); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2250 KUNIT_EXPECT_FALSE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2255 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2257 KUNIT_EXPECT_EQ(test, mock->msg.version, 2); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2258 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2259 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2261 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2265 static void cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked(struct kunit *test) in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked() argument
2267 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2284 mock = cros_kunit_ec_xfer_mock_add(test, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2287 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2296 KUNIT_EXPECT_EQ(test, ret, sizeof(data->event_type) + sizeof(data->data.host_event)); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2298 KUNIT_EXPECT_EQ(test, ec_dev->event_data.event_type, EC_MKBP_EVENT_HOST_EVENT); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2300 KUNIT_EXPECT_FALSE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2305 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2307 KUNIT_EXPECT_EQ(test, mock->msg.version, 2); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2308 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2309 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2311 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2315 static void cros_ec_proto_test_get_host_event_no_mkbp_event(struct kunit *test) in cros_ec_proto_test_get_host_event_no_mkbp_event() argument
2317 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_no_mkbp_event()
2324 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_get_host_event_no_mkbp_event()
2327 static void cros_ec_proto_test_get_host_event_not_host_event(struct kunit *test) in cros_ec_proto_test_get_host_event_not_host_event() argument
2329 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_not_host_event()
2337 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_get_host_event_not_host_event()
2340 static void cros_ec_proto_test_get_host_event_wrong_event_size(struct kunit *test) in cros_ec_proto_test_get_host_event_wrong_event_size() argument
2342 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_wrong_event_size()
2351 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_get_host_event_wrong_event_size()
2354 static void cros_ec_proto_test_get_host_event_normal(struct kunit *test) in cros_ec_proto_test_get_host_event_normal() argument
2356 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_normal()
2367 KUNIT_EXPECT_EQ(test, ret, EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC)); in cros_ec_proto_test_get_host_event_normal()
2370 static void cros_ec_proto_test_check_features_cached(struct kunit *test) in cros_ec_proto_test_check_features_cached() argument
2383 KUNIT_EXPECT_TRUE(test, ret); in cros_ec_proto_test_check_features_cached()
2386 KUNIT_EXPECT_FALSE(test, ret); in cros_ec_proto_test_check_features_cached()
2392 static void cros_ec_proto_test_check_features_not_cached(struct kunit *test) in cros_ec_proto_test_check_features_not_cached() argument
2394 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_check_features_not_cached()
2412 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_check_features_not_cached()
2413 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_check_features_not_cached()
2425 KUNIT_EXPECT_TRUE(test, ret); in cros_ec_proto_test_check_features_not_cached()
2428 KUNIT_EXPECT_FALSE(test, ret); in cros_ec_proto_test_check_features_not_cached()
2436 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_check_features_not_cached()
2438 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_check_features_not_cached()
2439 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_FEATURES); in cros_ec_proto_test_check_features_not_cached()
2440 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_get_features)); in cros_ec_proto_test_check_features_not_cached()
2441 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_check_features_not_cached()
2445 static void cros_ec_proto_test_get_sensor_count_normal(struct kunit *test) in cros_ec_proto_test_get_sensor_count_normal() argument
2447 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_sensor_count_normal()
2463 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_normal()
2464 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_normal()
2471 KUNIT_EXPECT_EQ(test, ret, 0xbf); in cros_ec_proto_test_get_sensor_count_normal()
2478 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_normal()
2480 KUNIT_EXPECT_EQ(test, mock->msg.version, 1); in cros_ec_proto_test_get_sensor_count_normal()
2481 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD); in cros_ec_proto_test_get_sensor_count_normal()
2482 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_motion_sense)); in cros_ec_proto_test_get_sensor_count_normal()
2483 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_normal()
2486 KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP); in cros_ec_proto_test_get_sensor_count_normal()
2490 static void cros_ec_proto_test_get_sensor_count_xfer_error(struct kunit *test) in cros_ec_proto_test_get_sensor_count_xfer_error() argument
2492 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_sensor_count_xfer_error()
2506 mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_get_sensor_count_xfer_error()
2507 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_xfer_error()
2511 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_get_sensor_count_xfer_error()
2518 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_xfer_error()
2520 KUNIT_EXPECT_EQ(test, mock->msg.version, 1); in cros_ec_proto_test_get_sensor_count_xfer_error()
2521 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD); in cros_ec_proto_test_get_sensor_count_xfer_error()
2522 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_motion_sense)); in cros_ec_proto_test_get_sensor_count_xfer_error()
2523 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_xfer_error()
2526 KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP); in cros_ec_proto_test_get_sensor_count_xfer_error()
2530 static void cros_ec_proto_test_get_sensor_count_legacy(struct kunit *test) in cros_ec_proto_test_get_sensor_count_legacy() argument
2532 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_sensor_count_legacy()
2555 mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_get_sensor_count_legacy()
2556 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_legacy()
2561 cros_kunit_readmem_mock_data = kunit_kzalloc(test, 1, GFP_KERNEL); in cros_ec_proto_test_get_sensor_count_legacy()
2562 KUNIT_ASSERT_PTR_NE(test, cros_kunit_readmem_mock_data, NULL); in cros_ec_proto_test_get_sensor_count_legacy()
2569 KUNIT_EXPECT_EQ(test, ret, test_data[i].expected_result); in cros_ec_proto_test_get_sensor_count_legacy()
2576 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_legacy()
2578 KUNIT_EXPECT_EQ(test, mock->msg.version, 1); in cros_ec_proto_test_get_sensor_count_legacy()
2579 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD); in cros_ec_proto_test_get_sensor_count_legacy()
2580 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_sensor_count_legacy()
2582 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_legacy()
2585 KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP); in cros_ec_proto_test_get_sensor_count_legacy()
2590 KUNIT_EXPECT_EQ(test, cros_kunit_readmem_mock_offset, EC_MEMMAP_ACC_STATUS); in cros_ec_proto_test_get_sensor_count_legacy()
2595 static void cros_ec_proto_test_ec_cmd(struct kunit *test) in cros_ec_proto_test_ec_cmd() argument
2597 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_ec_cmd()
2613 mock = cros_kunit_ec_xfer_mock_add(test, 2); in cros_ec_proto_test_ec_cmd()
2614 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_ec_cmd()
2622 KUNIT_EXPECT_EQ(test, ret, 2); in cros_ec_proto_test_ec_cmd()
2628 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_ec_cmd()
2630 KUNIT_EXPECT_EQ(test, mock->msg.version, 0x88); in cros_ec_proto_test_ec_cmd()
2631 KUNIT_EXPECT_EQ(test, mock->msg.command, 0x77); in cros_ec_proto_test_ec_cmd()
2632 KUNIT_EXPECT_EQ(test, mock->msg.insize, ARRAY_SIZE(in)); in cros_ec_proto_test_ec_cmd()
2633 KUNIT_EXPECT_EQ(test, mock->msg.outsize, ARRAY_SIZE(out)); in cros_ec_proto_test_ec_cmd()
2636 KUNIT_EXPECT_EQ(test, data[0], 0xdd); in cros_ec_proto_test_ec_cmd()
2637 KUNIT_EXPECT_EQ(test, data[1], 0xcc); in cros_ec_proto_test_ec_cmd()
2638 KUNIT_EXPECT_EQ(test, data[2], 0xbb); in cros_ec_proto_test_ec_cmd()
2646 static int cros_ec_proto_test_init(struct kunit *test) in cros_ec_proto_test_init() argument
2651 priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); in cros_ec_proto_test_init()
2654 test->priv = priv; in cros_ec_proto_test_init()
2662 ec_dev->dev = kunit_kzalloc(test, sizeof(*ec_dev->dev), GFP_KERNEL); in cros_ec_proto_test_init()
2678 static void cros_ec_proto_test_exit(struct kunit *test) in cros_ec_proto_test_exit() argument
2680 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_exit()