summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am13
-rw-r--r--tests/testsuite.at1
-rw-r--r--tests/vty/fail_not_de-indented.cfg3
-rw-r--r--tests/vty/fail_tabs_and_spaces.cfg4
-rw-r--r--tests/vty/fail_too_much_indent.cfg3
-rw-r--r--tests/vty/ok.cfg3
-rw-r--r--tests/vty/ok_ignore_blank.cfg7
-rw-r--r--tests/vty/ok_ignore_comment.cfg7
-rw-r--r--tests/vty/ok_indented_root.cfg3
-rw-r--r--tests/vty/ok_more_spaces.cfg4
-rw-r--r--tests/vty/ok_tabs.cfg4
-rw-r--r--tests/vty/ok_tabs_and_spaces.cfg4
-rw-r--r--tests/vty/vty_test.c20
-rw-r--r--tests/vty/vty_test.ok20
14 files changed, 95 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 37378fbc..8935bf72 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -217,7 +217,18 @@ EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \
logging/logging_test.ok logging/logging_test.err \
fr/fr_test.ok loggingrb/logging_test.ok \
loggingrb/logging_test.err strrb/strrb_test.ok \
- vty/vty_test.ok comp128/comp128_test.ok \
+ vty/vty_test.ok \
+ vty/fail_not_de-indented.cfg \
+ vty/fail_tabs_and_spaces.cfg \
+ vty/fail_too_much_indent.cfg \
+ vty/ok.cfg \
+ vty/ok_ignore_blank.cfg \
+ vty/ok_ignore_comment.cfg \
+ vty/ok_indented_root.cfg \
+ vty/ok_more_spaces.cfg \
+ vty/ok_tabs_and_spaces.cfg \
+ vty/ok_tabs.cfg \
+ comp128/comp128_test.ok \
utils/utils_test.ok stats/stats_test.ok \
bitvec/bitvec_test.ok msgb/msgb_test.ok bits/bitcomp_test.ok \
sim/sim_test.ok tlv/tlv_test.ok abis/abis_test.ok \
diff --git a/tests/testsuite.at b/tests/testsuite.at
index f148cf5a..1954e66b 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -174,6 +174,7 @@ AT_CLEANUP
AT_SETUP([vty])
AT_KEYWORDS([vty])
cat $abs_srcdir/vty/vty_test.ok > expout
+cp $abs_srcdir/vty/*.cfg .
AT_CHECK([$abs_top_builddir/tests/vty/vty_test], [0], [expout], [ignore])
AT_CLEANUP
diff --git a/tests/vty/fail_not_de-indented.cfg b/tests/vty/fail_not_de-indented.cfg
new file mode 100644
index 00000000..5af833da
--- /dev/null
+++ b/tests/vty/fail_not_de-indented.cfg
@@ -0,0 +1,3 @@
+line vty
+ no login
+ log stderr
diff --git a/tests/vty/fail_tabs_and_spaces.cfg b/tests/vty/fail_tabs_and_spaces.cfg
new file mode 100644
index 00000000..fa6ce059
--- /dev/null
+++ b/tests/vty/fail_tabs_and_spaces.cfg
@@ -0,0 +1,4 @@
+line vty
+ no login
+ no login
+log stderr
diff --git a/tests/vty/fail_too_much_indent.cfg b/tests/vty/fail_too_much_indent.cfg
new file mode 100644
index 00000000..bacb3e1e
--- /dev/null
+++ b/tests/vty/fail_too_much_indent.cfg
@@ -0,0 +1,3 @@
+line vty
+ no login
+ log stderr
diff --git a/tests/vty/ok.cfg b/tests/vty/ok.cfg
new file mode 100644
index 00000000..d5ef23e4
--- /dev/null
+++ b/tests/vty/ok.cfg
@@ -0,0 +1,3 @@
+line vty
+ no login
+log stderr
diff --git a/tests/vty/ok_ignore_blank.cfg b/tests/vty/ok_ignore_blank.cfg
new file mode 100644
index 00000000..d16ff64e
--- /dev/null
+++ b/tests/vty/ok_ignore_blank.cfg
@@ -0,0 +1,7 @@
+line vty
+
+ no login
+
+ no login
+
+log stderr
diff --git a/tests/vty/ok_ignore_comment.cfg b/tests/vty/ok_ignore_comment.cfg
new file mode 100644
index 00000000..5813fc7c
--- /dev/null
+++ b/tests/vty/ok_ignore_comment.cfg
@@ -0,0 +1,7 @@
+line vty
+ ! comment
+ no login
+! comment
+ no login
+ ! comment
+log stderr
diff --git a/tests/vty/ok_indented_root.cfg b/tests/vty/ok_indented_root.cfg
new file mode 100644
index 00000000..313c6742
--- /dev/null
+++ b/tests/vty/ok_indented_root.cfg
@@ -0,0 +1,3 @@
+ line vty
+ no login
+ log stderr
diff --git a/tests/vty/ok_more_spaces.cfg b/tests/vty/ok_more_spaces.cfg
new file mode 100644
index 00000000..b66a9c21
--- /dev/null
+++ b/tests/vty/ok_more_spaces.cfg
@@ -0,0 +1,4 @@
+line vty
+ no login
+ no login
+log stderr
diff --git a/tests/vty/ok_tabs.cfg b/tests/vty/ok_tabs.cfg
new file mode 100644
index 00000000..e94609b7
--- /dev/null
+++ b/tests/vty/ok_tabs.cfg
@@ -0,0 +1,4 @@
+line vty
+ no login
+ no login
+log stderr
diff --git a/tests/vty/ok_tabs_and_spaces.cfg b/tests/vty/ok_tabs_and_spaces.cfg
new file mode 100644
index 00000000..2049b732
--- /dev/null
+++ b/tests/vty/ok_tabs_and_spaces.cfg
@@ -0,0 +1,4 @@
+line vty
+ no login
+ no login
+log stderr
diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c
index d84bf419..eba9995c 100644
--- a/tests/vty/vty_test.c
+++ b/tests/vty/vty_test.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -288,6 +289,15 @@ static void test_stats_vty(void)
destroy_test_vty(&test, vty);
}
+void test_exit_by_indent(const char *fname, int expect_rc)
+{
+ int rc;
+ printf("reading file %s, expecting rc=%d\n", fname, expect_rc);
+ rc = vty_read_config_file(fname, NULL);
+ printf("got rc=%d\n", rc);
+ OSMO_ASSERT(rc == expect_rc);
+}
+
int main(int argc, char **argv)
{
struct vty_app_info vty_info = {
@@ -322,6 +332,16 @@ int main(int argc, char **argv)
test_cmd_string_from_valstr();
test_node_tree_structure();
test_stats_vty();
+ test_exit_by_indent("ok.cfg", 0);
+ test_exit_by_indent("ok_more_spaces.cfg", 0);
+ test_exit_by_indent("ok_tabs.cfg", 0);
+ test_exit_by_indent("ok_tabs_and_spaces.cfg", 0);
+ test_exit_by_indent("ok_ignore_comment.cfg", 0);
+ test_exit_by_indent("ok_ignore_blank.cfg", 0);
+ test_exit_by_indent("fail_not_de-indented.cfg", -EINVAL);
+ test_exit_by_indent("fail_too_much_indent.cfg", -EINVAL);
+ test_exit_by_indent("fail_tabs_and_spaces.cfg", -EINVAL);
+ test_exit_by_indent("ok_indented_root.cfg", 0);
/* Leak check */
OSMO_ASSERT(talloc_total_blocks(stats_ctx) == 1);
diff --git a/tests/vty/vty_test.ok b/tests/vty/vty_test.ok
index 2b6d5a67..b2df1a11 100644
--- a/tests/vty/vty_test.ok
+++ b/tests/vty/vty_test.ok
@@ -108,4 +108,24 @@ Going to execute 'no stats reporter log'
Returned: 0, Current node: 4 '%s(config)# '
Going to execute 'no stats reporter statsd'
Returned: 0, Current node: 4 '%s(config)# '
+reading file ok.cfg, expecting rc=0
+got rc=0
+reading file ok_more_spaces.cfg, expecting rc=0
+got rc=0
+reading file ok_tabs.cfg, expecting rc=0
+got rc=0
+reading file ok_tabs_and_spaces.cfg, expecting rc=0
+got rc=0
+reading file ok_ignore_comment.cfg, expecting rc=0
+got rc=0
+reading file ok_ignore_blank.cfg, expecting rc=0
+got rc=0
+reading file fail_not_de-indented.cfg, expecting rc=-22
+got rc=-22
+reading file fail_too_much_indent.cfg, expecting rc=-22
+got rc=-22
+reading file fail_tabs_and_spaces.cfg, expecting rc=-22
+got rc=-22
+reading file ok_indented_root.cfg, expecting rc=0
+got rc=0
All tests passed