Lines Matching full:test

6 #include <kunit/test.h>
26 static void cros_ec_proto_test_prepare_tx_legacy_normal(struct kunit *test) in cros_ec_proto_test_prepare_tx_legacy_normal() argument
28 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_prepare_tx_legacy_normal()
45 KUNIT_EXPECT_EQ(test, ret, EC_MSG_TX_PROTO_BYTES + EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_proto_test_prepare_tx_legacy_normal()
46 KUNIT_EXPECT_EQ(test, ec_dev->dout[0], EC_CMD_VERSION0); in cros_ec_proto_test_prepare_tx_legacy_normal()
47 KUNIT_EXPECT_EQ(test, ec_dev->dout[1], EC_CMD_HELLO); in cros_ec_proto_test_prepare_tx_legacy_normal()
48 KUNIT_EXPECT_EQ(test, ec_dev->dout[2], EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_proto_test_prepare_tx_legacy_normal()
49 KUNIT_EXPECT_EQ(test, EC_MSG_TX_HEADER_BYTES, 3); in cros_ec_proto_test_prepare_tx_legacy_normal()
50 KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 0], 0xde); in cros_ec_proto_test_prepare_tx_legacy_normal()
51 KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 1], 0xad); in cros_ec_proto_test_prepare_tx_legacy_normal()
52 KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 2], 0xbe); in cros_ec_proto_test_prepare_tx_legacy_normal()
53 KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + 3], 0xef); in cros_ec_proto_test_prepare_tx_legacy_normal()
55 KUNIT_EXPECT_EQ(test, ec_dev->dout[EC_MSG_TX_HEADER_BYTES + i], 0); in cros_ec_proto_test_prepare_tx_legacy_normal()
64 KUNIT_EXPECT_EQ(test, in cros_ec_proto_test_prepare_tx_legacy_normal()
69 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
71 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_prepare_tx_legacy_bad_msg_outsize()
81 KUNIT_EXPECT_EQ(test, ret, -EINVAL); in cros_ec_proto_test_prepare_tx_legacy_bad_msg_outsize()
84 static void cros_ec_proto_test_prepare_tx_normal(struct kunit *test) in cros_ec_proto_test_prepare_tx_normal() argument
86 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_prepare_tx_normal()
102 KUNIT_EXPECT_EQ(test, ret, sizeof(*request) + 0x88); in cros_ec_proto_test_prepare_tx_normal()
104 KUNIT_EXPECT_EQ(test, request->struct_version, EC_HOST_REQUEST_VERSION); in cros_ec_proto_test_prepare_tx_normal()
105 KUNIT_EXPECT_EQ(test, request->command, EC_CMD_HELLO); in cros_ec_proto_test_prepare_tx_normal()
106 KUNIT_EXPECT_EQ(test, request->command_version, 0); in cros_ec_proto_test_prepare_tx_normal()
107 KUNIT_EXPECT_EQ(test, request->data_len, 0x88); in cros_ec_proto_test_prepare_tx_normal()
108 KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 0], 0xde); in cros_ec_proto_test_prepare_tx_normal()
109 KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 1], 0xad); in cros_ec_proto_test_prepare_tx_normal()
110 KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 2], 0xbe); in cros_ec_proto_test_prepare_tx_normal()
111 KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + 3], 0xef); in cros_ec_proto_test_prepare_tx_normal()
113 KUNIT_EXPECT_EQ(test, ec_dev->dout[sizeof(*request) + i], 0); in cros_ec_proto_test_prepare_tx_normal()
122 KUNIT_EXPECT_EQ(test, request->checksum, (u8)-csum); in cros_ec_proto_test_prepare_tx_normal()
125 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
127 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_prepare_tx_bad_msg_outsize()
135 KUNIT_EXPECT_EQ(test, ret, -EINVAL); in cros_ec_proto_test_prepare_tx_bad_msg_outsize()
138 static void cros_ec_proto_test_check_result(struct kunit *test) in cros_ec_proto_test_check_result() argument
140 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_check_result()
170 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_check_result()
175 KUNIT_EXPECT_EQ(test, ret, -EAGAIN); in cros_ec_proto_test_check_result()
178 static void cros_ec_proto_test_query_all_pretest(struct kunit *test) in cros_ec_proto_test_query_all_pretest() argument
180 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_pretest()
193 static void cros_ec_proto_test_query_all_normal(struct kunit *test) in cros_ec_proto_test_query_all_normal() argument
195 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_normal()
204 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
205 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
217 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
218 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
228 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
229 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
239 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
240 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
250 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
251 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
257 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_normal()
259 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_normal()
264 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
266 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_normal()
267 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_normal()
268 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_normal()
270 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_normal()
272 KUNIT_EXPECT_EQ(test, ec_dev->max_request, 0xbe - sizeof(struct ec_host_request)); in cros_ec_proto_test_query_all_normal()
273 KUNIT_EXPECT_EQ(test, ec_dev->max_response, 0xef - sizeof(struct ec_host_response)); in cros_ec_proto_test_query_all_normal()
274 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, 3); in cros_ec_proto_test_query_all_normal()
275 KUNIT_EXPECT_EQ(test, ec_dev->din_size, 0xef + EC_MAX_RESPONSE_OVERHEAD); in cros_ec_proto_test_query_all_normal()
276 KUNIT_EXPECT_EQ(test, ec_dev->dout_size, 0xbe + EC_MAX_REQUEST_OVERHEAD); in cros_ec_proto_test_query_all_normal()
282 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
284 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_normal()
285 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_normal()
288 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_normal()
290 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_normal()
292 KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0xbf - sizeof(struct ec_host_request)); in cros_ec_proto_test_query_all_normal()
300 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
302 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_normal()
303 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_normal()
304 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_normal()
306 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
309 KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_query_all_normal()
311 KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 7); in cros_ec_proto_test_query_all_normal()
319 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
321 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_normal()
322 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_normal()
323 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_normal()
325 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_normal()
328 KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_HOST_SLEEP_EVENT); in cros_ec_proto_test_query_all_normal()
330 KUNIT_EXPECT_TRUE(test, ec_dev->host_sleep_v1); in cros_ec_proto_test_query_all_normal()
336 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_normal()
338 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_normal()
339 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HOST_EVENT_GET_WAKE_MASK); in cros_ec_proto_test_query_all_normal()
340 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_host_event_mask)); in cros_ec_proto_test_query_all_normal()
341 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_normal()
343 KUNIT_EXPECT_EQ(test, ec_dev->host_event_wake_mask, 0xbeef); in cros_ec_proto_test_query_all_normal()
347 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
349 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_pd_return_error()
361 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_pd_return_error()
362 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return_error()
375 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()
376 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return_error()
379 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_pd_return_error()
381 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
386 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return_error()
388 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
389 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_pd_return_error()
390 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_pd_return_error()
392 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
398 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return_error()
400 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
401 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_pd_return_error()
404 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_pd_return_error()
406 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
408 KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0); in cros_ec_proto_test_query_all_no_pd_return_error()
412 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
414 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_pd_return0()
426 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_pd_return0()
427 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return0()
440 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_no_pd_return0()
441 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return0()
444 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_pd_return0()
446 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_pd_return0()
451 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return0()
453 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_pd_return0()
454 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_pd_return0()
455 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_pd_return0()
457 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_pd_return0()
463 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_pd_return0()
465 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_pd_return0()
466 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_pd_return0()
469 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_pd_return0()
471 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_pd_return0()
473 KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0); in cros_ec_proto_test_query_all_no_pd_return0()
477 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
479 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
486 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()
487 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
494 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
495 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
501 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
503 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
508 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
510 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
511 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
512 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
514 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
522 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
524 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
525 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
526 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
527 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
530 KUNIT_EXPECT_EQ(test, data->in_data, 0xa0b0c0d0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
532 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, 2); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
533 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()
534 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()
535 KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
536 KUNIT_EXPECT_PTR_EQ(test, ec_dev->pkt_xfer, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
537 KUNIT_EXPECT_EQ(test, ec_dev->din_size, EC_PROTO2_MSG_BYTES); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
538 KUNIT_EXPECT_EQ(test, ec_dev->dout_size, EC_PROTO2_MSG_BYTES); in cros_ec_proto_test_query_all_legacy_normal_v3_return_error()
542 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
544 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
551 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
552 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
559 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
560 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
566 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
568 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
573 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
575 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
576 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
577 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
579 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
587 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
589 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
590 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
591 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
592 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
595 KUNIT_EXPECT_EQ(test, data->in_data, 0xa0b0c0d0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
597 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, 2); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
598 KUNIT_EXPECT_EQ(test, ec_dev->max_request, EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
599 KUNIT_EXPECT_EQ(test, ec_dev->max_response, EC_PROTO2_MAX_PARAM_SIZE); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
600 KUNIT_EXPECT_EQ(test, ec_dev->max_passthru, 0); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
601 KUNIT_EXPECT_PTR_EQ(test, ec_dev->pkt_xfer, NULL); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
602 KUNIT_EXPECT_EQ(test, ec_dev->din_size, EC_PROTO2_MSG_BYTES); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
603 KUNIT_EXPECT_EQ(test, ec_dev->dout_size, EC_PROTO2_MSG_BYTES); in cros_ec_proto_test_query_all_legacy_normal_v3_return0()
607 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
609 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_xfer_error()
616 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_xfer_error()
617 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_xfer_error()
622 mock = cros_kunit_ec_xfer_mock_addx(test, -EIO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_query_all_legacy_xfer_error()
623 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_xfer_error()
626 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_xfer_error()
628 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_query_all_legacy_xfer_error()
629 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN); in cros_ec_proto_test_query_all_legacy_xfer_error()
634 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_xfer_error()
636 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_xfer_error()
637 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_xfer_error()
638 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_xfer_error()
640 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_xfer_error()
646 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_xfer_error()
648 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_xfer_error()
649 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_xfer_error()
650 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_xfer_error()
651 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello)); in cros_ec_proto_test_query_all_legacy_xfer_error()
655 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
657 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_return_error()
664 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_return_error()
665 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return_error()
670 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_return_error()
671 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return_error()
674 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_return_error()
676 KUNIT_EXPECT_EQ(test, ret, -EOPNOTSUPP); in cros_ec_proto_test_query_all_legacy_return_error()
677 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN); in cros_ec_proto_test_query_all_legacy_return_error()
682 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return_error()
684 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_return_error()
685 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_return_error()
686 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_return_error()
688 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_return_error()
694 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return_error()
696 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_return_error()
697 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_return_error()
698 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_return_error()
699 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello)); in cros_ec_proto_test_query_all_legacy_return_error()
703 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
705 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_data_error()
712 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_data_error()
713 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_data_error()
720 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_legacy_data_error()
721 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_data_error()
727 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_data_error()
729 KUNIT_EXPECT_EQ(test, ret, -EBADMSG); in cros_ec_proto_test_query_all_legacy_data_error()
730 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN); in cros_ec_proto_test_query_all_legacy_data_error()
735 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_data_error()
737 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_data_error()
738 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_data_error()
739 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_data_error()
741 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_data_error()
747 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_data_error()
749 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_data_error()
750 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_data_error()
751 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_data_error()
752 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello)); in cros_ec_proto_test_query_all_legacy_data_error()
756 static void cros_ec_proto_test_query_all_legacy_return0(struct kunit *test) in cros_ec_proto_test_query_all_legacy_return0() argument
758 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_legacy_return0()
765 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_legacy_return0()
766 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return0()
771 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_legacy_return0()
772 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return0()
775 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_legacy_return0()
777 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_query_all_legacy_return0()
778 KUNIT_EXPECT_EQ(test, ec_dev->proto_version, EC_PROTO_VERSION_UNKNOWN); in cros_ec_proto_test_query_all_legacy_return0()
783 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return0()
785 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_return0()
786 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_legacy_return0()
787 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_legacy_return0()
789 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_legacy_return0()
795 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_legacy_return0()
797 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_legacy_return0()
798 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_query_all_legacy_return0()
799 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_hello)); in cros_ec_proto_test_query_all_legacy_return0()
800 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_hello)); in cros_ec_proto_test_query_all_legacy_return0()
804 static void cros_ec_proto_test_query_all_no_mkbp(struct kunit *test) in cros_ec_proto_test_query_all_no_mkbp() argument
806 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_mkbp()
818 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp()
819 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
832 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_no_mkbp()
833 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
840 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp()
841 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
847 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_mkbp()
849 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_mkbp()
854 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
856 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp()
857 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_mkbp()
858 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp()
860 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp()
866 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
868 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp()
869 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_mkbp()
872 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp()
874 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp()
882 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp()
884 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp()
885 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_mkbp()
886 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp()
888 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp()
891 KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_query_all_no_mkbp()
893 KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0); in cros_ec_proto_test_query_all_no_mkbp()
897 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
899 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_mkbp_return_error()
911 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp_return_error()
912 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
925 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()
926 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
931 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()
932 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
935 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_mkbp_return_error()
937 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
942 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
944 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
945 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_mkbp_return_error()
946 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return_error()
948 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
954 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
956 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
957 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_mkbp_return_error()
960 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return_error()
962 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
970 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return_error()
972 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
973 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_mkbp_return_error()
974 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return_error()
976 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp_return_error()
979 KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_query_all_no_mkbp_return_error()
981 KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0); in cros_ec_proto_test_query_all_no_mkbp_return_error()
985 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
987 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_mkbp_return0()
999 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp_return0()
1000 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1013 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1014 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1019 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1020 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1023 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_mkbp_return0()
1025 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1030 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1032 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1033 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_mkbp_return0()
1034 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return0()
1036 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1042 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1044 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1045 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_mkbp_return0()
1048 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return0()
1050 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1058 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_mkbp_return0()
1060 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1061 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_mkbp_return0()
1062 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_mkbp_return0()
1064 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_query_all_no_mkbp_return0()
1067 KUNIT_EXPECT_EQ(test, data->cmd, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_query_all_no_mkbp_return0()
1069 KUNIT_EXPECT_EQ(test, ec_dev->mkbp_event_supported, 0); in cros_ec_proto_test_query_all_no_mkbp_return0()
1073 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
1075 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_host_sleep()
1087 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_host_sleep()
1088 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1101 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_INVALID_COMMAND, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1102 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1107 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1108 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1115 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_host_sleep()
1116 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1122 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_host_sleep()
1124 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1129 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1131 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1132 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_host_sleep()
1133 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep()
1135 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1141 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1143 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1144 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_host_sleep()
1147 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep()
1149 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1155 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1157 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1158 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_host_sleep()
1159 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep()
1161 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); in cros_ec_proto_test_query_all_no_host_sleep()
1167 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep()
1169 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep()
1170 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_host_sleep()
1171 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep()
1173 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(struct ec_params_get_cmd_versions)); in cros_ec_proto_test_query_all_no_host_sleep()
1175 KUNIT_EXPECT_FALSE(test, ec_dev->host_sleep_v1); in cros_ec_proto_test_query_all_no_host_sleep()
1179 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
1181 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_no_host_sleep_return0()
1193 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1194 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1207 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()
1208 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1215 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1216 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1225 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1226 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1229 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1231 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1236 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1238 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1239 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1240 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep_return0()
1242 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1248 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1250 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1251 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_no_host_sleep_return0()
1254 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep_return0()
1256 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1262 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1264 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1265 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1266 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep_return0()
1268 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()
1274 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1276 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1277 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1278 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_no_host_sleep_return0()
1280 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()
1282 KUNIT_EXPECT_FALSE(test, ec_dev->host_sleep_v1); in cros_ec_proto_test_query_all_no_host_sleep_return0()
1286 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
1288 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1300 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1301 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1314 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()
1315 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1320 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1321 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1326 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1327 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1332 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()
1333 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1336 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1338 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1343 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1345 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1346 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1347 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1349 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1355 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1357 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1358 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1361 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1363 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1369 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1371 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1372 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1373 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1375 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()
1381 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1383 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1384 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1385 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1387 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()
1395 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1397 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1398 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()
1399 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()
1400 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 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_LID_CLOSED), 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_AC_DISCONNECTED), 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_LOW), 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_CRITICAL), 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_BATTERY), 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_PD_MCU), 0); in cros_ec_proto_test_query_all_default_wake_mask_return_error()
1409 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()
1413 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
1415 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_query_all_default_wake_mask_return0()
1427 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1428 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1441 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()
1442 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1447 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1448 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1453 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1454 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1459 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1460 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1463 cros_ec_proto_test_query_all_pretest(test); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1465 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1470 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1472 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1473 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_PROTOCOL_INFO); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1474 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return0()
1476 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1482 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1484 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1485 KUNIT_EXPECT_EQ(test, mock->msg.command, in cros_ec_proto_test_query_all_default_wake_mask_return0()
1488 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return0()
1490 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1496 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1498 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1499 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1500 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return0()
1502 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()
1508 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1510 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1511 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_CMD_VERSIONS); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1512 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_query_all_default_wake_mask_return0()
1514 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()
1522 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1524 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1525 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()
1526 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()
1527 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 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_LID_CLOSED), 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_AC_DISCONNECTED), 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_LOW), 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_CRITICAL), 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_BATTERY), 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_PD_MCU), 0); in cros_ec_proto_test_query_all_default_wake_mask_return0()
1536 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()
1540 static void cros_ec_proto_test_cmd_xfer_normal(struct kunit *test) in cros_ec_proto_test_cmd_xfer_normal() argument
1542 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_normal()
1562 mock = cros_kunit_ec_xfer_mock_add(test, 4); in cros_ec_proto_test_cmd_xfer_normal()
1563 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_normal()
1573 KUNIT_EXPECT_EQ(test, ret, 4); in cros_ec_proto_test_cmd_xfer_normal()
1579 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_normal()
1581 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_cmd_xfer_normal()
1582 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_cmd_xfer_normal()
1583 KUNIT_EXPECT_EQ(test, mock->msg.insize, 4); in cros_ec_proto_test_cmd_xfer_normal()
1584 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 2); in cros_ec_proto_test_cmd_xfer_normal()
1587 KUNIT_EXPECT_EQ(test, data[0], 0x55); in cros_ec_proto_test_cmd_xfer_normal()
1588 KUNIT_EXPECT_EQ(test, data[1], 0xaa); in cros_ec_proto_test_cmd_xfer_normal()
1590 KUNIT_EXPECT_EQ(test, buf->data[0], 0xaa); in cros_ec_proto_test_cmd_xfer_normal()
1591 KUNIT_EXPECT_EQ(test, buf->data[1], 0x55); in cros_ec_proto_test_cmd_xfer_normal()
1592 KUNIT_EXPECT_EQ(test, buf->data[2], 0xcc); in cros_ec_proto_test_cmd_xfer_normal()
1593 KUNIT_EXPECT_EQ(test, buf->data[3], 0x33); in cros_ec_proto_test_cmd_xfer_normal()
1597 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
1599 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1615 mock = cros_kunit_ec_xfer_mock_add(test, 0xcc); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1616 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1620 KUNIT_EXPECT_EQ(test, ret, 0xcc); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1624 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1626 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1627 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1628 KUNIT_EXPECT_EQ(test, mock->msg.insize, 0xee); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1629 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 2); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1633 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
1635 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_without_passthru()
1650 KUNIT_EXPECT_EQ(test, ret, -EMSGSIZE); in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_without_passthru()
1653 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
1655 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_with_passthru()
1670 KUNIT_EXPECT_EQ(test, ret, -EMSGSIZE); in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_with_passthru()
1673 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
1675 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1687 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1689 KUNIT_EXPECT_EQ(test, cros_kunit_ec_cmd_xfer_mock_called, 0); in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1690 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 1); in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1693 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
1695 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v3_no_op()
1707 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_cmd_xfer_protocol_v3_no_op()
1710 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
1712 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1724 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1726 KUNIT_EXPECT_EQ(test, cros_kunit_ec_cmd_xfer_mock_called, 1); in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1727 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 0); in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1730 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
1732 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v2_no_op()
1744 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_cmd_xfer_protocol_v2_no_op()
1747 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
1749 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1761 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1762 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1769 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1770 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1777 KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_comms_status)); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1779 KUNIT_EXPECT_EQ(test, msg.result, EC_RES_SUCCESS); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1784 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1790 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1792 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1793 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_COMMS_STATUS); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1794 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1796 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1799 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1802 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
1804 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1816 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()
1817 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1824 KUNIT_EXPECT_EQ(test, ret, -EAGAIN); in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1827 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 51); in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1830 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
1832 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1844 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()
1845 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1854 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1855 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1863 KUNIT_EXPECT_EQ(test, ret, -EAGAIN); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1866 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 51); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1869 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
1871 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1881 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()
1882 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1887 mock = cros_kunit_ec_xfer_mock_addx(test, -EIO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1888 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1892 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1895 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
1897 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1909 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()
1910 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1915 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()
1916 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1920 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1922 KUNIT_EXPECT_EQ(test, msg.result, EC_RES_INVALID_COMMAND); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1924 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1927 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
1929 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1941 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1942 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1947 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1948 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1952 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1954 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1957 static void cros_ec_proto_test_cmd_xfer_status_normal(struct kunit *test) in cros_ec_proto_test_cmd_xfer_status_normal() argument
1959 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_status_normal()
1969 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_cmd_xfer_status_normal()
1970 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_status_normal()
1974 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_status_normal()
1977 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
1979 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_status_xfer_error()
1989 mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_cmd_xfer_status_xfer_error()
1990 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_status_xfer_error()
1994 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_cmd_xfer_status_xfer_error()
1997 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
1999 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_status_return_error()
2037 mock = cros_kunit_ec_xfer_mock_addx(test, 0, i, 0); in cros_ec_proto_test_cmd_xfer_status_return_error()
2038 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_status_return_error()
2041 KUNIT_EXPECT_EQ(test, ret, map[i]); in cros_ec_proto_test_cmd_xfer_status_return_error()
2045 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
2047 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_no_mkbp_event()
2065 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2066 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2073 KUNIT_EXPECT_EQ(test, ret, sizeof(union ec_response_get_next_data_v3)); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2075 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()
2076 KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.host_event, 0xbeef); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2078 KUNIT_EXPECT_TRUE(test, wake_event); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2079 KUNIT_EXPECT_FALSE(test, more_events); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2084 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2086 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2087 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MKBP_STATE); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2088 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(union ec_response_get_next_data_v3)); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2089 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2093 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
2095 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_ec_suspended()
2103 KUNIT_EXPECT_EQ(test, ret, -EHOSTDOWN); in cros_ec_proto_test_get_next_event_mkbp_event_ec_suspended()
2106 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
2108 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2126 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2127 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2135 KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_next_event)); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2137 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()
2138 KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.sysrq, 0xbeef); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2140 KUNIT_EXPECT_FALSE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2141 KUNIT_EXPECT_TRUE(test, more_events); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2146 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2148 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2149 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2150 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()
2151 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2155 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
2157 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2175 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2176 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2184 KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_next_event_v1)); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2186 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()
2187 KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.sysrq, 0xbeef); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2189 KUNIT_EXPECT_TRUE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2190 KUNIT_EXPECT_FALSE(test, more_events); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2195 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2197 KUNIT_EXPECT_EQ(test, mock->msg.version, 2); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2198 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2199 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2201 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2205 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
2207 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2224 mock = cros_kunit_ec_xfer_mock_add(test, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2227 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2235 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()
2237 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()
2239 KUNIT_EXPECT_FALSE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2244 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2246 KUNIT_EXPECT_EQ(test, mock->msg.version, 2); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2247 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()
2248 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2250 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2254 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
2256 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2273 mock = cros_kunit_ec_xfer_mock_add(test, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2276 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2285 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()
2287 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()
2289 KUNIT_EXPECT_FALSE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2294 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2296 KUNIT_EXPECT_EQ(test, mock->msg.version, 2); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2297 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()
2298 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2300 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2304 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
2306 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_no_mkbp_event()
2313 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_get_host_event_no_mkbp_event()
2316 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
2318 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_not_host_event()
2326 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_get_host_event_not_host_event()
2329 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
2331 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_wrong_event_size()
2340 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_get_host_event_wrong_event_size()
2343 static void cros_ec_proto_test_get_host_event_normal(struct kunit *test) in cros_ec_proto_test_get_host_event_normal() argument
2345 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_normal()
2356 KUNIT_EXPECT_EQ(test, ret, EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC)); in cros_ec_proto_test_get_host_event_normal()
2359 static void cros_ec_proto_test_check_features_cached(struct kunit *test) in cros_ec_proto_test_check_features_cached() argument
2372 KUNIT_EXPECT_TRUE(test, ret); in cros_ec_proto_test_check_features_cached()
2375 KUNIT_EXPECT_FALSE(test, ret); in cros_ec_proto_test_check_features_cached()
2381 static void cros_ec_proto_test_check_features_not_cached(struct kunit *test) in cros_ec_proto_test_check_features_not_cached() argument
2383 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_check_features_not_cached()
2401 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_check_features_not_cached()
2402 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_check_features_not_cached()
2414 KUNIT_EXPECT_TRUE(test, ret); in cros_ec_proto_test_check_features_not_cached()
2417 KUNIT_EXPECT_FALSE(test, ret); in cros_ec_proto_test_check_features_not_cached()
2425 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_check_features_not_cached()
2427 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_check_features_not_cached()
2428 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_FEATURES); in cros_ec_proto_test_check_features_not_cached()
2429 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_get_features)); in cros_ec_proto_test_check_features_not_cached()
2430 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_check_features_not_cached()
2434 static void cros_ec_proto_test_get_sensor_count_normal(struct kunit *test) in cros_ec_proto_test_get_sensor_count_normal() argument
2436 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_sensor_count_normal()
2452 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_normal()
2453 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_normal()
2460 KUNIT_EXPECT_EQ(test, ret, 0xbf); in cros_ec_proto_test_get_sensor_count_normal()
2467 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_normal()
2469 KUNIT_EXPECT_EQ(test, mock->msg.version, 1); in cros_ec_proto_test_get_sensor_count_normal()
2470 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD); in cros_ec_proto_test_get_sensor_count_normal()
2471 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_motion_sense)); in cros_ec_proto_test_get_sensor_count_normal()
2472 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_normal()
2475 KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP); in cros_ec_proto_test_get_sensor_count_normal()
2479 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
2481 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_sensor_count_xfer_error()
2495 mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_get_sensor_count_xfer_error()
2496 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_xfer_error()
2500 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_get_sensor_count_xfer_error()
2507 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_xfer_error()
2509 KUNIT_EXPECT_EQ(test, mock->msg.version, 1); in cros_ec_proto_test_get_sensor_count_xfer_error()
2510 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD); in cros_ec_proto_test_get_sensor_count_xfer_error()
2511 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_motion_sense)); in cros_ec_proto_test_get_sensor_count_xfer_error()
2512 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_xfer_error()
2515 KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP); in cros_ec_proto_test_get_sensor_count_xfer_error()
2519 static void cros_ec_proto_test_get_sensor_count_legacy(struct kunit *test) in cros_ec_proto_test_get_sensor_count_legacy() argument
2521 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_sensor_count_legacy()
2544 mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_get_sensor_count_legacy()
2545 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_legacy()
2550 cros_kunit_readmem_mock_data = kunit_kzalloc(test, 1, GFP_KERNEL); in cros_ec_proto_test_get_sensor_count_legacy()
2551 KUNIT_ASSERT_PTR_NE(test, cros_kunit_readmem_mock_data, NULL); in cros_ec_proto_test_get_sensor_count_legacy()
2558 KUNIT_EXPECT_EQ(test, ret, test_data[i].expected_result); in cros_ec_proto_test_get_sensor_count_legacy()
2565 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_legacy()
2567 KUNIT_EXPECT_EQ(test, mock->msg.version, 1); in cros_ec_proto_test_get_sensor_count_legacy()
2568 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD); in cros_ec_proto_test_get_sensor_count_legacy()
2569 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_sensor_count_legacy()
2571 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_legacy()
2574 KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP); in cros_ec_proto_test_get_sensor_count_legacy()
2579 KUNIT_EXPECT_EQ(test, cros_kunit_readmem_mock_offset, EC_MEMMAP_ACC_STATUS); in cros_ec_proto_test_get_sensor_count_legacy()
2584 static void cros_ec_proto_test_ec_cmd(struct kunit *test) in cros_ec_proto_test_ec_cmd() argument
2586 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_ec_cmd()
2602 mock = cros_kunit_ec_xfer_mock_add(test, 2); in cros_ec_proto_test_ec_cmd()
2603 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_ec_cmd()
2611 KUNIT_EXPECT_EQ(test, ret, 2); in cros_ec_proto_test_ec_cmd()
2617 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_ec_cmd()
2619 KUNIT_EXPECT_EQ(test, mock->msg.version, 0x88); in cros_ec_proto_test_ec_cmd()
2620 KUNIT_EXPECT_EQ(test, mock->msg.command, 0x77); in cros_ec_proto_test_ec_cmd()
2621 KUNIT_EXPECT_EQ(test, mock->msg.insize, ARRAY_SIZE(in)); in cros_ec_proto_test_ec_cmd()
2622 KUNIT_EXPECT_EQ(test, mock->msg.outsize, ARRAY_SIZE(out)); in cros_ec_proto_test_ec_cmd()
2625 KUNIT_EXPECT_EQ(test, data[0], 0xdd); in cros_ec_proto_test_ec_cmd()
2626 KUNIT_EXPECT_EQ(test, data[1], 0xcc); in cros_ec_proto_test_ec_cmd()
2627 KUNIT_EXPECT_EQ(test, data[2], 0xbb); in cros_ec_proto_test_ec_cmd()
2635 static int cros_ec_proto_test_init(struct kunit *test) in cros_ec_proto_test_init() argument
2640 priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); in cros_ec_proto_test_init()
2643 test->priv = priv; in cros_ec_proto_test_init()
2651 ec_dev->dev = kunit_kzalloc(test, sizeof(*ec_dev->dev), GFP_KERNEL); in cros_ec_proto_test_init()
2668 static void cros_ec_proto_test_exit(struct kunit *test) in cros_ec_proto_test_exit() argument
2670 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_exit()