Add test for IPv4 (currently fails)
authorWouter Verhelst <w@uter.be>
Thu, 13 Jan 2022 10:55:20 +0000 (12:55 +0200)
committerWouter Verhelst <w@uter.be>
Thu, 13 Jan 2022 10:56:57 +0000 (12:56 +0200)
tests/parse/Makefile.am
tests/parse/ipv4 [new file with mode: 0644]
tests/parse/parser.c

index 74e5d5e..03f1ea9 100644 (file)
@@ -3,5 +3,5 @@ check_PROGRAMS = parser
 TESTS_ENVIRONMENT = $(builddir)/parser
 parser_SOURCES = parser.c
 parser_LDADD = $(top_builddir)/libnbdclt.la $(top_builddir)/libcliserv.la
-TESTS = empty noopts singleopt multiopt ipv6
+TESTS = empty noopts singleopt multiopt ipv6 ipv4
 EXTRA_DIST=$(TESTS)
diff --git a/tests/parse/ipv4 b/tests/parse/ipv4
new file mode 100644 (file)
index 0000000..7282a63
--- /dev/null
@@ -0,0 +1 @@
+nbd0 192.168.1.1 test
index e148a87..9f74ddc 100644 (file)
@@ -35,7 +35,14 @@ CLIENT client_ipv6 = {
        .hostn = "2a01:4f8:200:91e8::2",
 };
 
+CLIENT client_ipv4 = {
+       .name = "test",
+       .dev = "nbd0",
+       .hostn = "192.168.1.1",
+};
+
 CLIENT *cur_client;
+bool seen_commit = false;
 
 void nbdtab_set_property(char *property, char *val) {
        printf("property %s set to %s\n", property, val);
@@ -54,6 +61,7 @@ void nbdtab_commit_line(char *devn, char *hostn, char *exportname) {
        assert(strcmp(cur_client->dev, devn) == 0);
        assert(strcmp(cur_client->hostn, hostn) == 0);
        assert(strcmp(cur_client->name, exportname) == 0);
+       seen_commit = true;
 }
 
 void yyerror(char *s) {
@@ -80,10 +88,13 @@ int main(int argc, char**argv) {
        KNOW_CONF(singleopt);
        KNOW_CONF(multiopt);
        KNOW_CONF(ipv6);
+       KNOW_CONF(ipv4);
 
 #undef KNOW_CONF
 
        assert(cur_client != NULL);
 
        yyparse();
+
+       assert(cur_client == &client_empty || seen_commit == true);
 }