Lines Matching refs:test

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()
1565 mock = cros_kunit_ec_xfer_mock_add(test, 4); in cros_ec_proto_test_cmd_xfer_normal()
1566 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_normal()
1576 KUNIT_EXPECT_EQ(test, ret, 4); in cros_ec_proto_test_cmd_xfer_normal()
1582 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_normal()
1584 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_cmd_xfer_normal()
1585 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_cmd_xfer_normal()
1586 KUNIT_EXPECT_EQ(test, mock->msg.insize, 4); in cros_ec_proto_test_cmd_xfer_normal()
1587 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 2); in cros_ec_proto_test_cmd_xfer_normal()
1590 KUNIT_EXPECT_EQ(test, data[0], 0x55); in cros_ec_proto_test_cmd_xfer_normal()
1591 KUNIT_EXPECT_EQ(test, data[1], 0xaa); in cros_ec_proto_test_cmd_xfer_normal()
1593 KUNIT_EXPECT_EQ(test, buf.data[0], 0xaa); in cros_ec_proto_test_cmd_xfer_normal()
1594 KUNIT_EXPECT_EQ(test, buf.data[1], 0x55); in cros_ec_proto_test_cmd_xfer_normal()
1595 KUNIT_EXPECT_EQ(test, buf.data[2], 0xcc); in cros_ec_proto_test_cmd_xfer_normal()
1596 KUNIT_EXPECT_EQ(test, buf.data[3], 0x33); in cros_ec_proto_test_cmd_xfer_normal()
1600 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
1602 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1621 mock = cros_kunit_ec_xfer_mock_add(test, 0xcc); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1622 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1626 KUNIT_EXPECT_EQ(test, ret, 0xcc); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1630 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1632 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1633 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_HELLO); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1634 KUNIT_EXPECT_EQ(test, mock->msg.insize, 0xee); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1635 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 2); in cros_ec_proto_test_cmd_xfer_excess_msg_insize()
1639 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
1641 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_without_passthru()
1659 KUNIT_EXPECT_EQ(test, ret, -EMSGSIZE); in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_without_passthru()
1662 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
1664 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_with_passthru()
1682 KUNIT_EXPECT_EQ(test, ret, -EMSGSIZE); in cros_ec_proto_test_cmd_xfer_excess_msg_outsize_with_passthru()
1685 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
1687 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1699 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1701 KUNIT_EXPECT_EQ(test, cros_kunit_ec_cmd_xfer_mock_called, 0); in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1702 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 1); in cros_ec_proto_test_cmd_xfer_protocol_v3_normal()
1705 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
1707 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v3_no_op()
1719 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_cmd_xfer_protocol_v3_no_op()
1722 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
1724 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1736 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1738 KUNIT_EXPECT_EQ(test, cros_kunit_ec_cmd_xfer_mock_called, 1); in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1739 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 0); in cros_ec_proto_test_cmd_xfer_protocol_v2_normal()
1742 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
1744 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_protocol_v2_no_op()
1756 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_cmd_xfer_protocol_v2_no_op()
1759 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
1761 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1773 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1774 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1781 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1782 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1789 KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_comms_status)); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1791 KUNIT_EXPECT_EQ(test, msg.result, EC_RES_SUCCESS); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1796 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1802 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1804 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1805 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_COMMS_STATUS); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1806 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1808 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1811 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2); in cros_ec_proto_test_cmd_xfer_in_progress_normal()
1814 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
1816 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1828 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()
1829 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1836 KUNIT_EXPECT_EQ(test, ret, -EAGAIN); in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1839 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 51); in cros_ec_proto_test_cmd_xfer_in_progress_retries_eagain()
1842 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
1844 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1856 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()
1857 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1866 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1867 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1875 KUNIT_EXPECT_EQ(test, ret, -EAGAIN); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1878 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 51); in cros_ec_proto_test_cmd_xfer_in_progress_retries_status_processing()
1881 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
1883 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1893 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()
1894 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1899 mock = cros_kunit_ec_xfer_mock_addx(test, -EIO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1900 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1904 KUNIT_EXPECT_EQ(test, ret, -EIO); in cros_ec_proto_test_cmd_xfer_in_progress_xfer_error()
1907 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
1909 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1921 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()
1922 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1927 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()
1928 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1932 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1934 KUNIT_EXPECT_EQ(test, msg.result, EC_RES_INVALID_COMMAND); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1936 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2); in cros_ec_proto_test_cmd_xfer_in_progress_return_error()
1939 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
1941 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1953 mock = cros_kunit_ec_xfer_mock_addx(test, 0, EC_RES_IN_PROGRESS, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1954 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1959 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1960 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1964 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1966 KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2); in cros_ec_proto_test_cmd_xfer_in_progress_return0()
1969 static void cros_ec_proto_test_cmd_xfer_status_normal(struct kunit *test) in cros_ec_proto_test_cmd_xfer_status_normal() argument
1971 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_status_normal()
1981 mock = cros_kunit_ec_xfer_mock_add(test, 0); in cros_ec_proto_test_cmd_xfer_status_normal()
1982 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_status_normal()
1986 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_cmd_xfer_status_normal()
1989 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
1991 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_status_xfer_error()
2001 mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_cmd_xfer_status_xfer_error()
2002 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_status_xfer_error()
2006 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_cmd_xfer_status_xfer_error()
2009 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
2011 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_cmd_xfer_status_return_error()
2049 mock = cros_kunit_ec_xfer_mock_addx(test, 0, i, 0); in cros_ec_proto_test_cmd_xfer_status_return_error()
2050 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_cmd_xfer_status_return_error()
2053 KUNIT_EXPECT_EQ(test, ret, map[i]); in cros_ec_proto_test_cmd_xfer_status_return_error()
2057 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
2059 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_no_mkbp_event()
2077 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2078 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2085 KUNIT_EXPECT_EQ(test, ret, sizeof(union ec_response_get_next_data_v1)); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2087 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()
2088 KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.host_event, 0xbeef); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2090 KUNIT_EXPECT_TRUE(test, wake_event); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2091 KUNIT_EXPECT_FALSE(test, more_events); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2096 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2098 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2099 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MKBP_STATE); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2100 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()
2101 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_no_mkbp_event()
2105 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
2107 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_ec_suspended()
2115 KUNIT_EXPECT_EQ(test, ret, -EHOSTDOWN); in cros_ec_proto_test_get_next_event_mkbp_event_ec_suspended()
2118 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
2120 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2138 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2139 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2147 KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_next_event)); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2149 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()
2150 KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.sysrq, 0xbeef); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2152 KUNIT_EXPECT_FALSE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2153 KUNIT_EXPECT_TRUE(test, more_events); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2158 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2160 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2161 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2162 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()
2163 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_version0()
2167 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
2169 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2187 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2188 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2196 KUNIT_EXPECT_EQ(test, ret, sizeof(struct ec_response_get_next_event_v1)); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2198 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()
2199 KUNIT_EXPECT_EQ(test, ec_dev->event_data.data.sysrq, 0xbeef); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2201 KUNIT_EXPECT_TRUE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2202 KUNIT_EXPECT_FALSE(test, more_events); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2207 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2209 KUNIT_EXPECT_EQ(test, mock->msg.version, 2); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2210 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_NEXT_EVENT); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2211 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2213 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_version2()
2217 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
2219 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2236 mock = cros_kunit_ec_xfer_mock_add(test, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2239 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2247 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()
2249 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()
2251 KUNIT_EXPECT_FALSE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2256 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2258 KUNIT_EXPECT_EQ(test, mock->msg.version, 2); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2259 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()
2260 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2262 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc()
2266 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
2268 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2285 mock = cros_kunit_ec_xfer_mock_add(test, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2288 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2297 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()
2299 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()
2301 KUNIT_EXPECT_FALSE(test, wake_event); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2306 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2308 KUNIT_EXPECT_EQ(test, mock->msg.version, 2); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2309 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()
2310 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2312 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked()
2316 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
2318 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_no_mkbp_event()
2325 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_get_host_event_no_mkbp_event()
2328 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
2330 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_not_host_event()
2338 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_get_host_event_not_host_event()
2341 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
2343 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_wrong_event_size()
2352 KUNIT_EXPECT_EQ(test, ret, 0); in cros_ec_proto_test_get_host_event_wrong_event_size()
2355 static void cros_ec_proto_test_get_host_event_normal(struct kunit *test) in cros_ec_proto_test_get_host_event_normal() argument
2357 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_host_event_normal()
2368 KUNIT_EXPECT_EQ(test, ret, EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC)); in cros_ec_proto_test_get_host_event_normal()
2371 static void cros_ec_proto_test_check_features_cached(struct kunit *test) in cros_ec_proto_test_check_features_cached() argument
2384 KUNIT_EXPECT_TRUE(test, ret); in cros_ec_proto_test_check_features_cached()
2387 KUNIT_EXPECT_FALSE(test, ret); in cros_ec_proto_test_check_features_cached()
2393 static void cros_ec_proto_test_check_features_not_cached(struct kunit *test) in cros_ec_proto_test_check_features_not_cached() argument
2395 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_check_features_not_cached()
2413 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_check_features_not_cached()
2414 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_check_features_not_cached()
2426 KUNIT_EXPECT_TRUE(test, ret); in cros_ec_proto_test_check_features_not_cached()
2429 KUNIT_EXPECT_FALSE(test, ret); in cros_ec_proto_test_check_features_not_cached()
2437 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_check_features_not_cached()
2439 KUNIT_EXPECT_EQ(test, mock->msg.version, 0); in cros_ec_proto_test_check_features_not_cached()
2440 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_GET_FEATURES); in cros_ec_proto_test_check_features_not_cached()
2441 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_get_features)); in cros_ec_proto_test_check_features_not_cached()
2442 KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); in cros_ec_proto_test_check_features_not_cached()
2446 static void cros_ec_proto_test_get_sensor_count_normal(struct kunit *test) in cros_ec_proto_test_get_sensor_count_normal() argument
2448 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_sensor_count_normal()
2464 mock = cros_kunit_ec_xfer_mock_add(test, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_normal()
2465 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_normal()
2472 KUNIT_EXPECT_EQ(test, ret, 0xbf); in cros_ec_proto_test_get_sensor_count_normal()
2479 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_normal()
2481 KUNIT_EXPECT_EQ(test, mock->msg.version, 1); in cros_ec_proto_test_get_sensor_count_normal()
2482 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD); in cros_ec_proto_test_get_sensor_count_normal()
2483 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_motion_sense)); in cros_ec_proto_test_get_sensor_count_normal()
2484 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_normal()
2487 KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP); in cros_ec_proto_test_get_sensor_count_normal()
2491 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
2493 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_sensor_count_xfer_error()
2507 mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_get_sensor_count_xfer_error()
2508 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_xfer_error()
2512 KUNIT_EXPECT_EQ(test, ret, -EPROTO); in cros_ec_proto_test_get_sensor_count_xfer_error()
2519 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_xfer_error()
2521 KUNIT_EXPECT_EQ(test, mock->msg.version, 1); in cros_ec_proto_test_get_sensor_count_xfer_error()
2522 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD); in cros_ec_proto_test_get_sensor_count_xfer_error()
2523 KUNIT_EXPECT_EQ(test, mock->msg.insize, sizeof(struct ec_response_motion_sense)); in cros_ec_proto_test_get_sensor_count_xfer_error()
2524 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_xfer_error()
2527 KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP); in cros_ec_proto_test_get_sensor_count_xfer_error()
2531 static void cros_ec_proto_test_get_sensor_count_legacy(struct kunit *test) in cros_ec_proto_test_get_sensor_count_legacy() argument
2533 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_get_sensor_count_legacy()
2556 mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0); in cros_ec_proto_test_get_sensor_count_legacy()
2557 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_legacy()
2562 cros_kunit_readmem_mock_data = kunit_kzalloc(test, 1, GFP_KERNEL); in cros_ec_proto_test_get_sensor_count_legacy()
2563 KUNIT_ASSERT_PTR_NE(test, cros_kunit_readmem_mock_data, NULL); in cros_ec_proto_test_get_sensor_count_legacy()
2570 KUNIT_EXPECT_EQ(test, ret, test_data[i].expected_result); in cros_ec_proto_test_get_sensor_count_legacy()
2577 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_get_sensor_count_legacy()
2579 KUNIT_EXPECT_EQ(test, mock->msg.version, 1); in cros_ec_proto_test_get_sensor_count_legacy()
2580 KUNIT_EXPECT_EQ(test, mock->msg.command, EC_CMD_MOTION_SENSE_CMD); in cros_ec_proto_test_get_sensor_count_legacy()
2581 KUNIT_EXPECT_EQ(test, mock->msg.insize, in cros_ec_proto_test_get_sensor_count_legacy()
2583 KUNIT_EXPECT_EQ(test, mock->msg.outsize, sizeof(*data)); in cros_ec_proto_test_get_sensor_count_legacy()
2586 KUNIT_EXPECT_EQ(test, data->cmd, MOTIONSENSE_CMD_DUMP); in cros_ec_proto_test_get_sensor_count_legacy()
2591 KUNIT_EXPECT_EQ(test, cros_kunit_readmem_mock_offset, EC_MEMMAP_ACC_STATUS); in cros_ec_proto_test_get_sensor_count_legacy()
2596 static void cros_ec_proto_test_ec_cmd(struct kunit *test) in cros_ec_proto_test_ec_cmd() argument
2598 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_ec_cmd()
2614 mock = cros_kunit_ec_xfer_mock_add(test, 2); in cros_ec_proto_test_ec_cmd()
2615 KUNIT_ASSERT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_ec_cmd()
2623 KUNIT_EXPECT_EQ(test, ret, 2); in cros_ec_proto_test_ec_cmd()
2629 KUNIT_EXPECT_PTR_NE(test, mock, NULL); in cros_ec_proto_test_ec_cmd()
2631 KUNIT_EXPECT_EQ(test, mock->msg.version, 0x88); in cros_ec_proto_test_ec_cmd()
2632 KUNIT_EXPECT_EQ(test, mock->msg.command, 0x77); in cros_ec_proto_test_ec_cmd()
2633 KUNIT_EXPECT_EQ(test, mock->msg.insize, ARRAY_SIZE(in)); in cros_ec_proto_test_ec_cmd()
2634 KUNIT_EXPECT_EQ(test, mock->msg.outsize, ARRAY_SIZE(out)); in cros_ec_proto_test_ec_cmd()
2637 KUNIT_EXPECT_EQ(test, data[0], 0xdd); in cros_ec_proto_test_ec_cmd()
2638 KUNIT_EXPECT_EQ(test, data[1], 0xcc); in cros_ec_proto_test_ec_cmd()
2639 KUNIT_EXPECT_EQ(test, data[2], 0xbb); in cros_ec_proto_test_ec_cmd()
2647 static int cros_ec_proto_test_init(struct kunit *test) in cros_ec_proto_test_init() argument
2652 priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); in cros_ec_proto_test_init()
2655 test->priv = priv; in cros_ec_proto_test_init()
2663 ec_dev->dev = kunit_kzalloc(test, sizeof(*ec_dev->dev), GFP_KERNEL); in cros_ec_proto_test_init()
2680 static void cros_ec_proto_test_exit(struct kunit *test) in cros_ec_proto_test_exit() argument
2682 struct cros_ec_proto_test_priv *priv = test->priv; in cros_ec_proto_test_exit()