Imported Upstream version 0.8.4
[platform/upstream/multipath-tools.git] / tests / test-lib.h
1 #ifndef __LIB_H
2 #define __LIB_H
3
4 extern const int default_mask;
5 extern const char default_devnode[];
6 extern const char default_wwid[];
7 extern const char default_wwid_1[];
8
9 enum {
10         BL_BY_DEVNODE   = (1 << 0),
11         BL_BY_DEVICE    = (1 << 1),
12         BL_BY_WWID      = (1 << 2),
13         BL_BY_PROPERTY  = (1 << 3),
14         BL_MASK = BL_BY_DEVNODE|BL_BY_DEVICE|BL_BY_WWID|BL_BY_PROPERTY,
15         NEED_SELECT_PRIO = (1 << 8),
16         NEED_FD         = (1 << 9),
17         USE_GETUID      = (1 << 10),
18         DEV_HIDDEN      = (1 << 11),
19 };
20
21 struct mocked_path {
22         const char *vendor;
23         const char *product;
24         const char *rev;
25         const char *wwid;
26         const char *devnode;
27         unsigned int flags;
28 };
29
30 struct mocked_path *fill_mocked_path(struct mocked_path *mp,
31                                      const char *vendor,
32                                      const char *product,
33                                      const char *rev,
34                                      const char *wwid,
35                                      const char *devnode,
36                                      unsigned int flags);
37
38 struct mocked_path *mocked_path_from_path(struct mocked_path *mp,
39                                           const struct path *pp);
40
41 void mock_pathinfo(int mask, const struct mocked_path *mp);
42 void mock_store_pathinfo(int mask, const struct mocked_path *mp);
43 struct path *__mock_path(vector pathvec,
44                          const char *vnd, const char *prd,
45                          const char *rev, const char *wwid,
46                          const char *dev,
47                          unsigned int flags, int mask);
48
49 #define mock_path(v, p) \
50         __mock_path(hwt->vecs->pathvec, (v), (p), "0", NULL, NULL,      \
51                     0, default_mask)
52 #define mock_path_flags(v, p, f) \
53         __mock_path(hwt->vecs->pathvec, (v), (p), "0", NULL, NULL, \
54                     (f), default_mask)
55 #define mock_path_blacklisted(v, p) \
56         __mock_path(hwt->vecs->pathvec, (v), (p), "0", NULL, NULL, \
57                     BL_BY_DEVICE, default_mask)
58 #define mock_path_wwid(v, p, w) \
59         __mock_path(hwt->vecs->pathvec, (v), (p), "0", (w), NULL,       \
60                     0, default_mask)
61 #define mock_path_wwid_flags(v, p, w, f) \
62         __mock_path(hwt->vecs->pathvec, (v), (p), "0", (w),             \
63                     NULL, (f), default_mask)
64
65 struct multipath *__mock_multipath(struct vectors *vecs, struct path *pp);
66 #define mock_multipath(pp) __mock_multipath(hwt->vecs, (pp))
67
68 #endif