summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2017-04-27 13:57:28 +1000
committerChris Johns <chrisj@rtems.org>2017-04-27 13:57:28 +1000
commit443757313e0f2c4da58cf25009e2964026043957 (patch)
tree45b1fea0aee399ace1bbac6eb047e1f89700ed04 /testsuite
parentrc_conf: Do not use a local variable for the rc_conf context. (diff)
downloadrtems-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')
-rw-r--r--testsuite/rcconf01/test_main.c45
-rw-r--r--testsuite/rcconf02/test_main.c17
2 files changed, 60 insertions, 2 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;
diff --git a/testsuite/rcconf02/test_main.c b/testsuite/rcconf02/test_main.c
index 0b7c6d17..ad177d25 100644
--- a/testsuite/rcconf02/test_main.c
+++ b/testsuite/rcconf02/test_main.c
@@ -75,8 +75,11 @@
#define IFACE_IPV4(iface) \
"ifconfig_" # iface "=\"inet " NET_CFG_SELF_IP " netmask " NET_CFG_NETMASK "\"\n"
+#define IFACE_ALIAS(iface) \
+ "ifconfig_" # iface "_alias0=\"ether 10:22:33:44:55:66\"\n" \
+ "ifconfig_" # iface "_alias1=\"inet 10.1.1.111 netmask 0xffffffff\"\n"
-#define RC_CONF_IFACES \
+#define RC_CONF_IFACES_IPV4 \
IFACE_IPV4(dmc0) \
IFACE_IPV4(sm0) \
IFACE_IPV4(cgem0) \
@@ -84,6 +87,18 @@
IFACE_IPV4(em0) \
IFACE_IPV4(re0)
+#define RC_CONF_IFACES_ALIAS \
+ IFACE_ALIAS(dmc0) \
+ IFACE_ALIAS(sm0) \
+ IFACE_ALIAS(cgem0) \
+ IFACE_ALIAS(fec0) \
+ IFACE_ALIAS(em0) \
+ IFACE_ALIAS(re0)
+
+#define RC_CONF_IFACES \
+ RC_CONF_IFACES_IPV4 \
+ RC_CONF_IFACES_ALIAS
+
#define IFACE_VLAN(iface) \
"vlans_" # iface "=\"101 102\"\n" \
"ifconfig_" # iface "_101=\"inet 192.0.101.1/24\"\n" \