6 #include "device-handler.h"
10 struct device_handler *handler;
11 struct discover_context *ctx;
15 /* interface required for parsers */
16 void __register_parser(struct parser *parser);
19 struct discover_device *test_create_device(struct parser_test *test,
22 #define test_read_conf_data(t, f, d) \
23 __test_read_conf_data(t, t->ctx->device, f, d, sizeof(d))
25 void __test_read_conf_data(struct parser_test *test,
26 struct discover_device *dev, const char *conf_file,
27 const char *buf, size_t len);
28 void test_read_conf_file(struct parser_test *test, const char *filename,
29 const char *conf_file);
31 int test_run_parser(struct parser_test *test, const char *parser_name);
33 void test_hotplug_device(struct parser_test *test, struct discover_device *dev);
34 void test_remove_device(struct parser_test *test, struct discover_device *dev);
36 void test_add_file_data(struct parser_test *test, struct discover_device *dev,
37 const char *filename, const void *data, int size);
38 void test_add_dir(struct parser_test *test, struct discover_device *dev,
40 void test_set_event_source(struct parser_test *test);
41 void test_set_event_param(struct event *event, const char *name,
43 void test_set_event_device(struct event *event, const char *dev);
45 #define test_add_file_string(test, dev, filename, str) \
46 test_add_file_data(test, dev, filename, str, sizeof(str) - 1)
48 struct discover_boot_option *get_boot_option(struct discover_context *ctx,
52 extern const char __embedded_config[];
53 extern const size_t __embedded_config_size;
54 #define test_read_conf_embedded(t, f) \
55 __test_read_conf_data(t, t->ctx->device, f, \
56 __embedded_config, __embedded_config_size)
58 #define test_read_conf_embedded_url(t, u) \
59 __test_read_conf_data(t, NULL, u, \
60 __embedded_config, __embedded_config_size)
63 * Checks for parser results.
65 * These return void, but will respond to check failures by printing a reason
66 * for the failure, and exit the test with a non-zero exit status.
70 * Check that we have an expected number of boot options parsed. If not,
71 * print out what we did find, then exit.
73 #define check_boot_option_count(ctx, count) \
74 __check_boot_option_count(ctx, count, __FILE__, __LINE__)
75 void __check_boot_option_count(struct discover_context *ctx, int count,
76 const char *file, int line);
78 * Check that a boot option @opt has args @args
80 void __check_args(struct discover_boot_option *opt, const char *args,
81 const char *file, int line);
82 #define check_args(opt, args) \
83 __check_args(opt, args, __FILE__, __LINE__)
86 * Check that a boot option @opt has name @name
88 void __check_name(struct discover_boot_option *opt, const char *name,
89 const char *file, int line);
90 #define check_name(opt, name) \
91 __check_name(opt, name, __FILE__, __LINE__)
94 * Check that a boot option @opt is marked as default
96 void __check_is_default(struct discover_boot_option *opt,
97 const char *file, int line);
98 #define check_is_default(opt) \
99 __check_is_default(opt, __FILE__, __LINE__)
102 * Check that a resource (@res) is present, resolved, and has a local path
103 * (within @dev's mount point) of @path.
105 #define check_resolved_local_resource(res, dev, path) \
106 __check_resolved_local_resource(res, dev, path, __FILE__, __LINE__)
108 void __check_resolved_local_resource(struct resource *res,
109 struct discover_device *dev, const char *local_path,
110 const char *file, int line);
113 * Check that a resource (@res) is present, resolved, and has a URL of
116 #define check_resolved_url_resource(res, url) \
117 __check_resolved_url_resource(res, url, __FILE__, __LINE__)
118 void __check_resolved_url_resource(struct resource *res,
119 const char *url, const char *file, int line);
121 * Check that a resource (@res) is present but not resolved
123 void __check_unresolved_resource(struct resource *res,
124 const char *file, int line);
125 #define check_unresolved_resource(res) \
126 __check_unresolved_resource(res, __FILE__, __LINE__)
129 * Check that a resource (@res) is not present
131 void __check_not_present_resource(struct resource *res,
132 const char *file, int line);
133 #define check_not_present_resource(res) \
134 __check_not_present_resource(res, __FILE__, __LINE__)
137 * Check the contents of a file - file @filename must be present on @dev,
138 * and match the @len bytes of @buf.
140 void __check_file_contents(struct parser_test *test,
141 struct discover_device *dev, const char *filename,
142 const char *buf, int len,
143 const char *srcfile, int srcline);
144 #define check_file_contents(test, dev, filename, buf, len) \
145 __check_file_contents(test, dev, filename, buf, len, __FILE__, __LINE__)
147 #endif /* PARSER_TEST_H */