aboutsummaryrefslogtreecommitdiff
path: root/drivers/platform/chrome/cros_kunit_util.h
blob: ae4080cb13f14e8e0c63eaf5e1a81406e5c4e704 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * CrOS Kunit tests utilities.
 */

#ifndef _CROS_KUNIT_UTIL_H_
#define _CROS_KUNIT_UTIL_H_

#include <linux/platform_data/cros_ec_proto.h>

struct ec_xfer_mock {
	struct list_head list;
	struct kunit *test;

	/* input */
	struct cros_ec_command msg;
	void *i_data;

	/* output */
	int ret;
	int result;
	void *o_data;
	u32 o_data_len;
};

extern int cros_kunit_ec_xfer_mock_default_ret;
extern int cros_kunit_ec_cmd_xfer_mock_called;
extern int cros_kunit_ec_pkt_xfer_mock_called;

int cros_kunit_ec_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_command *msg);
int cros_kunit_ec_cmd_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_command *msg);
int cros_kunit_ec_pkt_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_command *msg);
struct ec_xfer_mock *cros_kunit_ec_xfer_mock_add(struct kunit *test, size_t size);
struct ec_xfer_mock *cros_kunit_ec_xfer_mock_addx(struct kunit *test,
						  int ret, int result, size_t size);
struct ec_xfer_mock *cros_kunit_ec_xfer_mock_next(void);

void cros_kunit_mock_reset(void);

#endif