diff options
author | Chris Johns <chrisj@rtems.org> | 2017-04-27 13:57:28 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2017-04-27 13:57:28 +1000 |
commit | 443757313e0f2c4da58cf25009e2964026043957 (patch) | |
tree | 45b1fea0aee399ace1bbac6eb047e1f89700ed04 /testsuite/rcconf01 | |
parent | rc_conf: Do not use a local variable for the rc_conf context. (diff) | |
download | rtems-libbsd-443757313e0f2c4da58cf25009e2964026043957.tar.bz2 |
rc_conf: Add support for ifconfig_<interface>_alias[0-9]+.
The interface alias allows extra IP addresses to be set on and
interface and it also allows the MAC address to be set.
Examples:
ifconfig_em0="inet 10.10.5.33 netmask 255.255.255.0"
ifconfig_em0_alias0="ether 10:22:33:44:55:66"
ifconfig_em0_alias1="inet 10.1.1.111 netmask 0xffffffff"
Diffstat (limited to 'testsuite/rcconf01')
-rw-r--r-- | testsuite/rcconf01/test_main.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/testsuite/rcconf01/test_main.c b/testsuite/rcconf01/test_main.c index be878a38..51723bc7 100644 --- a/testsuite/rcconf01/test_main.c +++ b/testsuite/rcconf01/test_main.c @@ -69,6 +69,12 @@ test_service(rtems_bsd_rc_conf* rc_conf) test_service_last_num = 1; + /* + * Fill match of anything. + */ + puts("test_service regex: 'test_regex_.*'"); + test_regex_last_num = 0; + assert((aa = rtems_bsd_rc_conf_argc_argv_create()) != NULL); r = rtems_bsd_rc_conf_find(rc_conf, "test_regex_.*", aa); assert(r == 0 || (r < 0 && errno == ENOENT)); @@ -78,7 +84,7 @@ test_service(rtems_bsd_rc_conf* rc_conf) while (r == 0) { int num; int arg; - rtems_bsd_rc_conf_print_cmd(rc_conf, "test_service", aa->argc, aa->argv); + rtems_bsd_rc_conf_print_cmd(rc_conf, "test_service[1]", aa->argc, aa->argv); assert(strncasecmp(aa->argv[0], "test_regex_", strlen("test_regex_")) == 0); num = atoi(aa->argv[0] + strlen("test_regex_")); assert(num == (test_regex_last_num + 1)); @@ -98,6 +104,43 @@ test_service(rtems_bsd_rc_conf* rc_conf) r = rtems_bsd_rc_conf_find_next(rc_conf, aa); assert(r == 0 || (r < 0 && errno == ENOENT)); } + + /* + * Specific match of only numbers. + */ + puts("test_service regex: 'test_regex_[0-9]+'"); + test_regex_last_num = 0; + + assert((aa = rtems_bsd_rc_conf_argc_argv_create()) != NULL); + r = rtems_bsd_rc_conf_find(rc_conf, "test_regex_[0-9]+", aa); + assert(r == 0 || (r < 0 && errno == ENOENT)); + if (r < 0 && errno == ENOENT) + return -1; + + while (r == 0) { + int num; + int arg; + rtems_bsd_rc_conf_print_cmd(rc_conf, "test_service[2]", aa->argc, aa->argv); + assert(strncasecmp(aa->argv[0], "test_regex_", strlen("test_regex_")) == 0); + num = atoi(aa->argv[0] + strlen("test_regex_")); + assert(num == (test_regex_last_num + 1)); + assert((num - 1) < NUM_OF_TEST_REGEX_); + for (arg = 0; arg < aa->argc; ++arg) { + const char* a = aa->argv[arg]; + size_t l = strlen(a); + if (l > 0) { + assert(!isspace(a[0])); + assert(!isspace(a[l - 1])); + assert(a[0] != '"'); + assert(a[l - 1] != '"'); + } + } + test_regex_results[num - 1] = true; + ++test_regex_last_num; + r = rtems_bsd_rc_conf_find_next(rc_conf, aa); + assert(r == 0 || (r < 0 && errno == ENOENT)); + } + rtems_bsd_rc_conf_argc_argv_destroy(aa); puts("test_service done"); return 0; |