Go to the source code of this file.
◆ test_args_setup()
int test_args_setup |
( |
UNUSED void ** |
state | ) |
|
Definition at line 62 of file test_amxrt_args.c.
void amxrt_new(void)
Create the ambiorix runtime.
◆ test_args_teardown()
int test_args_teardown |
( |
UNUSED void ** |
state | ) |
|
Definition at line 67 of file test_amxrt_args.c.
void amxrt_delete(void)
Clean-up ambiorix runtime.
◆ test_can_accept_option()
void test_can_accept_option |
( |
UNUSED void ** |
state | ) |
|
Definition at line 168 of file test_amxrt_args.c.
169 char* argv[] = {
"amxrt",
"-o option=new_option",
"-o",
"text=hallo"};
172 assert_null(GET_ARG(
config,
"option"));
173 assert_null(GET_ARG(
config,
"text"));
176 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
178 assert_non_null(GET_ARG(
config,
"option"));
179 assert_non_null(GET_ARG(
config,
"text"));
181 assert_string_equal(GET_CHAR(
config,
"option"),
"new_option");
182 assert_string_equal(GET_CHAR(
config,
"text"),
"hallo");
int amxrt_cmd_line_parse(int argc, char *argv[], amxrt_arg_fn_t fn)
Starts parsing the command line options.
amxc_var_t * amxrt_get_config(void)
Gets the htable variant containing the configuration options.
◆ test_can_add_backend()
void test_can_add_backend |
( |
UNUSED void ** |
state | ) |
|
Definition at line 128 of file test_amxrt_args.c.
129 char* argv[] = {
"amxrt",
"-B",
"/usr/bin/mods/amx/mod_amxb_test.so",
"-B",
"/usr/bin/mods/amx/mod_amxb_dummy.so" };
132 const char* include_dirs[] = {
133 "/usr/bin/mods/amx/mod_amxb_test.so",
"/usr/bin/mods/amx/mod_amxb_dummy.so"
137 assert_non_null(option);
140 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
142 amxc_var_for_each(var, option) {
143 assert_string_equal(GET_CHAR(var, NULL), include_dirs[index]);
#define AMXRT_COPT_BACKENDS
◆ test_can_add_custom_options()
void test_can_add_custom_options |
( |
UNUSED void ** |
state | ) |
|
Definition at line 354 of file test_amxrt_args.c.
355 char* argv1[] = {
"amxrt",
"-z"};
int amxrt_cmd_line_add_option(int id, char short_option, const char *long_option, int has_args, const char *doc, const char *arg_doc)
Adds a command line option definition.
static int test_args(UNUSED amxc_var_t *config, int arg_id, UNUSED const char *value)
◆ test_can_add_forced_option()
void test_can_add_forced_option |
( |
UNUSED void ** |
state | ) |
|
◆ test_can_add_import_dir()
void test_can_add_import_dir |
( |
UNUSED void ** |
state | ) |
|
Definition at line 108 of file test_amxrt_args.c.
109 char* argv[] = {
"amxrt",
"-L",
"/tmp/include/",
"-L",
"/etc/odl/" };
112 const char* include_dirs[] = {
113 ".",
"/tmp/include/",
"/etc/odl/"
117 assert_non_null(option);
120 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
122 amxc_var_for_each(var, option) {
123 assert_string_equal(GET_CHAR(var, NULL), include_dirs[index]);
#define AMXRT_COPT_LIBDIRS
◆ test_can_add_include_dir()
void test_can_add_include_dir |
( |
UNUSED void ** |
state | ) |
|
Definition at line 88 of file test_amxrt_args.c.
89 char* argv[] = {
"amxrt",
"-I",
"/tmp/include/",
"-I",
"/etc/odl/" };
92 const char* include_dirs[] = {
93 ".",
"/tmp/include/",
"/etc/odl/"
97 assert_non_null(option);
100 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
102 amxc_var_for_each(var, option) {
103 assert_string_equal(GET_CHAR(var, NULL), include_dirs[index]);
#define AMXRT_COPT_INCDIRS
◆ test_can_add_required_objects()
void test_can_add_required_objects |
( |
UNUSED void ** |
state | ) |
|
Definition at line 319 of file test_amxrt_args.c.
320 char* argv[] = {
"amxrt",
"-R",
"NetModel.",
"-R",
"NetDev." };
323 const char* include_dirs[] = {
324 "NetModel.",
"NetDev."
328 assert_non_null(option);
331 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
333 amxc_var_for_each(var, option) {
334 assert_string_equal(GET_CHAR(var, NULL), include_dirs[index]);
#define AMXRT_COPT_REQUIRES
◆ test_can_add_uri()
void test_can_add_uri |
( |
UNUSED void ** |
state | ) |
|
Definition at line 148 of file test_amxrt_args.c.
149 char* argv[] = {
"amxrt",
"-u",
"dummy:/var/run/dummy.sock",
"-u",
"dummy:/var/run/ubus.sock" };
152 const char* include_dirs[] = {
153 "dummy:/var/run/dummy.sock",
"dummy:/var/run/ubus.sock"
157 assert_non_null(option);
160 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
162 amxc_var_for_each(var, option) {
163 assert_string_equal(GET_CHAR(var, NULL), include_dirs[index]);
◆ test_can_disable_auto_connect()
void test_can_disable_auto_connect |
( |
UNUSED void ** |
state | ) |
|
Definition at line 223 of file test_amxrt_args.c.
224 char* argv[] = {
"amxrt",
"-C"};
231 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
#define AMXRT_COPT_AUTO_CONNECT
◆ test_can_disable_auto_detect()
void test_can_disable_auto_detect |
( |
UNUSED void ** |
state | ) |
|
Definition at line 211 of file test_amxrt_args.c.
212 char* argv[] = {
"amxrt",
"-A"};
219 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
#define AMXRT_COPT_AUTO_DETECT
◆ test_can_disable_pid_file_creation()
void test_can_disable_pid_file_creation |
( |
UNUSED void ** |
state | ) |
|
Definition at line 283 of file test_amxrt_args.c.
284 char* argv[] = {
"amxrt",
"-N"};
291 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
#define AMXRT_COPT_PID_FILE
◆ test_can_enable_daemonize()
void test_can_enable_daemonize |
( |
UNUSED void ** |
state | ) |
|
Definition at line 235 of file test_amxrt_args.c.
236 char* argv[] = {
"amxrt",
"-D"};
243 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
#define AMXRT_COPT_DAEMON
◆ test_can_enable_dump_config()
void test_can_enable_dump_config |
( |
UNUSED void ** |
state | ) |
|
Definition at line 259 of file test_amxrt_args.c.
260 char* argv[] = {
"amxrt",
"-d"};
267 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
#define AMXRT_COPT_DUMP_CONFIG
◆ test_can_enable_eventing()
void test_can_enable_eventing |
( |
UNUSED void ** |
state | ) |
|
Definition at line 247 of file test_amxrt_args.c.
248 char* argv[] = {
"amxrt",
"-E"};
255 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
◆ test_can_enable_syslog()
void test_can_enable_syslog |
( |
UNUSED void ** |
state | ) |
|
Definition at line 307 of file test_amxrt_args.c.
308 char* argv[] = {
"amxrt",
"-l"};
315 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
◆ test_can_overwrite_option()
void test_can_overwrite_option |
( |
UNUSED void ** |
state | ) |
|
Definition at line 185 of file test_amxrt_args.c.
186 char* argv[] = {
"amxrt",
"-o cfg-dir=my_cfg_dir",
"-o",
"daemon=no"};
193 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
#define AMXRT_COPT_CFG_DIR
◆ test_can_pass_odl_string()
void test_can_pass_odl_string |
( |
UNUSED void ** |
state | ) |
|
Definition at line 295 of file test_amxrt_args.c.
296 char* argv[] = {
"amxrt",
"-O",
"%%config { test = 123; }"};
302 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
◆ test_can_print_extended_help()
void test_can_print_extended_help |
( |
UNUSED void ** |
state | ) |
|
◆ test_can_print_help()
void test_can_print_help |
( |
UNUSED void ** |
state | ) |
|
Definition at line 72 of file test_amxrt_args.c.
74 char* argv[] = {
"amxrt",
"-h" };
76 amxc_var_add_key(cstring_t,
config,
"name",
"amxrt");
◆ test_can_set_nice_level()
void test_can_set_nice_level |
( |
UNUSED void ** |
state | ) |
|
Definition at line 271 of file test_amxrt_args.c.
272 char* argv[] = {
"amxrt",
"-p",
"-5"};
279 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv) /
sizeof(argv[0]), argv, NULL),
sizeof(argv) /
sizeof(argv[0]));
#define AMXRT_COPT_PRIORITY
◆ test_can_set_usage_doc()
void test_can_set_usage_doc |
( |
UNUSED void ** |
state | ) |
|
Definition at line 381 of file test_amxrt_args.c.
void amxrt_cmd_line_set_usage_doc(const char *usage)
Set the overall usage documentation string.
void amxrt_print_usage(void)
Prints the usage information and all available options to stdout.
◆ test_cmd_line_parse_fails_after_reset()
void test_cmd_line_parse_fails_after_reset |
( |
UNUSED void ** |
state | ) |
|
Definition at line 364 of file test_amxrt_args.c.
365 char* argv1[] = {
"amxrt",
"-z"};
366 char* argv2[] = {
"amxrt",
"-z",
"-t"};
void amxrt_cmd_line_options_reset(void)
Removes all default options.
◆ test_ignores_invalid_options()
void test_ignores_invalid_options |
( |
UNUSED void ** |
state | ) |
|
Definition at line 198 of file test_amxrt_args.c.
199 char* argv1[] = {
"amxrt",
"-o"};
200 char* argv2[] = {
"amxrt",
"-o option2"};
207 assert_int_equal(
amxrt_cmd_line_parse(
sizeof(argv2) /
sizeof(argv2[0]), argv2, NULL),
sizeof(argv2) /
sizeof(argv2[0]));
208 assert_null(GET_CHAR(
config,
"option2"));