aboutsummaryrefslogtreecommitdiff
path: root/include/linux/i2c_testcase.h
blob: d2f9620978e6eea0b1ebb8458567e44fe3f8e063 (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
41
42
43
44
45
46
47
/*
        I2C Stress Test include file

*/
#ifndef __AXI_I2C_TEST_CASE_H__
#define __AXI_I2C_TEST_CASE_H__
#include <linux/i2c.h>

#define I2C_TEST_PASS (0)
//if test fail, the return value should be negative.

//typedef int (*run_i2c_test)(struct i2c_client *apClient);

#define I2C_TEST_CASE_NAME_SIZE 20

#define ARRAY_AND_SIZE(x)       (x), ARRAY_SIZE(x)

#define __I2C_STRESS_TEST_CASE_ATTR(_name) { \
	.name = __stringify(_name),	\
	.run	= _name,					\
}

/**
 * struct i2c_test_case_info - for i2c stress test
 * @type: name for test case
 * @run: the main function for test
 *
 * The concrete of I2C test case struct should be added to i2c test run before 
 * running tests. Recommend to be called in probe function in i2c driver. The
 * function run should be implemented by i2c driver and the negative value(error
 * code) should be returned if the test fails. Otherwise, zero should be returned.
 */
struct i2c_test_case_info {
	const char		*name;
	int (*run)(struct i2c_client *apClient);
};


extern int i2c_add_test_case(struct i2c_client *apClient,
	  const char		*apTestSetName,
	  struct i2c_test_case_info const *apTestCaseList,
	  unsigned anNum);  

/*log function for logging in running tests*/
extern int i2c_log_in_test_case(
	const char *fmt, ...);
#endif //__AXI_I2C_TEST_CASE_H__