6 #include "device-handler.h"
10 struct device_handler *handler;
11 struct discover_context *ctx;
18 /* interface required for parsers */
19 void __register_parser(struct parser *parser);
22 struct discover_device *test_create_device(struct discover_context *ctx,
25 #define test_read_conf_data(t, d) \
26 __test_read_conf_data(t, d, sizeof(d))
28 void __test_read_conf_data(struct parser_test *test,
29 const char *buf, size_t len);
30 void test_read_conf_file(struct parser_test *test, const char *filename);
31 void test_set_conf_source(struct parser_test *test, const char *url);
33 int test_run_parser(struct parser_test *test, const char *parser_name);
35 void test_hotplug_device(struct parser_test *test, struct discover_device *dev);
37 struct discover_boot_option *get_boot_option(struct discover_context *ctx,
41 extern const char __embedded_config[];
42 extern const size_t __embedded_config_size;
43 #define test_read_conf_embedded(t) \
44 __test_read_conf_data(t, __embedded_config, __embedded_config_size)
47 * Checks for parser results.
49 * These return void, but will respond to check failures by printing a reason
50 * for the failure, and exit the test with a non-zero exit status.
54 * Check that we have an expected number of boot options parsed. If not,
55 * print out what we did find, then exit.
57 #define check_boot_option_count(ctx, count) \
58 __check_boot_option_count(ctx, count, __FILE__, __LINE__)
59 void __check_boot_option_count(struct discover_context *ctx, int count,
60 const char *file, int line);
62 * Check that a boot option @opt has args @args
64 void __check_args(struct discover_boot_option *opt, const char *args,
65 const char *file, int line);
66 #define check_args(opt, args) \
67 __check_args(opt, args, __FILE__, __LINE__)
70 * Check that a boot option @opt has name @name
72 void __check_name(struct discover_boot_option *opt, const char *name,
73 const char *file, int line);
74 #define check_name(opt, name) \
75 __check_name(opt, name, __FILE__, __LINE__)
78 * Check that a resource (@res) is present, resolved, and has a local path
79 * (within @dev's mount point) of @path.
81 #define check_resolved_local_resource(res, dev, path) \
82 __check_resolved_local_resource(res, dev, path, __FILE__, __LINE__)
84 void __check_resolved_local_resource(struct resource *res,
85 struct discover_device *dev, const char *local_path,
86 const char *file, int line);
89 * Check that a resource (@res) is present, resolved, and has a URL of
92 #define check_resolved_url_resource(res, url) \
93 __check_resolved_url_resource(res, url, __FILE__, __LINE__)
94 void __check_resolved_url_resource(struct resource *res,
95 const char *url, const char *file, int line);
97 * Check that a resource (@res) is present but not resolved
99 void __check_unresolved_resource(struct resource *res,
100 const char *file, int line);
101 #define check_unresolved_resource(res) \
102 __check_unresolved_resource(res, __FILE__, __LINE__)
105 * Check that a resource (@res) is not present
107 void __check_not_present_resource(struct resource *res,
108 const char *file, int line);
109 #define check_not_present_resource(res) \
110 __check_not_present_resource(res, __FILE__, __LINE__)
112 #endif /* PARSER_TEST_H */