aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2016-03-05 23:40:11 +0200
committerSergey Poznyakoff <gray@gnu.org>2016-03-05 23:44:50 +0200
commit2dbad2727f1d00b223353965b326cfffa96fc776 (patch)
tree3e76daff8a9bf0a1268e183acce13d6ef828ccf7 /tests
parent8241dc04501f62b613f17f5c165f915a216ba30c (diff)
downloadgrecs-2dbad2727f1d00b223353965b326cfffa96fc776.tar.gz
grecs-2dbad2727f1d00b223353965b326cfffa96fc776.tar.bz2
Improve dhcpd parser
* src/dhcpd-gram.y: Support assignments and conditional expressions. * src/dhcpd-lex.l: New exclusive states BOOL and EXPR. * src/parsertab.c (parser_tab) [ENABLE_DHCPD_PARSER]: Define dhcpd parser. * tests/parser-dhcpd.at: New file. * tests/Makefile.am: Add parser-dhcpd.at * tests/testsuite.at: Likewise.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/dhcpd.conf61
-rw-r--r--tests/parser-dhcpd.at59
-rw-r--r--tests/testsuite.at5
4 files changed, 131 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7014b17..71498a6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,6 +24,7 @@ EXTRA_DIST = \
bind.int.conf\
bind.ext.conf\
bind.dlz\
+ dhcpd.conf\
meta1.conf\
git.conf
@@ -40,6 +41,10 @@ if GRECS_COND_BIND_PARSER
PARSER_DEFS += ENABLE_BIND_PARSER
endif
+if GRECS_COND_DHCPD_PARSER
+ PARSER_DEFS += ENABLE_DHCPD_PARSER
+endif
+
if GRECS_COND_GIT_PARSER
PARSER_DEFS += ENABLE_GIT_PARSER
endif
@@ -100,6 +105,7 @@ TESTSUITE_AT = \
locus-bind.at\
locus-git.at\
locus-meta1.at\
+ parser-dhcpd.at\
parser-bind.at\
parser-git.at\
parser-meta1.at\
diff --git a/tests/dhcpd.conf b/tests/dhcpd.conf
new file mode 100644
index 0000000..654add7
--- /dev/null
+++ b/tests/dhcpd.conf
@@ -0,0 +1,61 @@
+# Sample DHCPD configuration file for Grecs testsuite.
+
+authoritative;
+pid-file-name "/var/run/dhcpd.pid";
+log-facility daemon;
+
+default-lease-time 28800;
+max-lease-time 86400;
+
+ddns-update-style none;
+get-lease-hostnames yes;
+ddns-update-style interim;
+ignore client-updates; # Overwrite client configured FQHNs
+ddns-rev-domainname "in-addr.arpa.";
+use-host-decl-names on;
+
+include "bind.keys";
+
+zone lan.example.com. {
+ primary 127.0.0.1;
+ key "foo";
+}
+
+option domain-search "example.com", "example.org", "example.net";
+
+if option dhcp-user-class = "accounting" {
+ max-lease-time 17600;
+ option domain-name "accounting.example.org";
+ option domain-name-servers ns1.accounting.example.org,
+ ns2.accounting.example.org;
+} elsif option dhcp-user-class = "sales" {
+ max-lease-time 17600;
+ option domain-name "sales.example.org";
+ option domain-name-servers ns1.sales.example.org,
+ ns2.sales.example.org;
+} elsif option dhcp-user-class = "engineering" {
+ max-lease-time 17600;
+ option domain-name "engineering.example.org";
+ option domain-name-servers ns1.engineering.example.org,
+ ns2.engineering.example.org;
+} else {
+ max-lease-time 600;
+ option domain-name "misc.example.org";
+ option domain-name-servers ns1.misc.example.org,
+ ns2.misc.example.org;
+}
+
+shared-network "LAN" {
+ subnet 192.168.0.0 netmask 255.255.255.0 {
+ option routers 192.168.0.1;
+ option domain-name-servers 192.168.0.1;
+ update-static-leases on;
+
+ pool {
+ range 192.168.0.1 192.168.0.254;
+ deny known-clients;
+ ddns-hostname = binary-to-ascii(10, 8, "-", leased-address);
+ }
+ }
+}
+
diff --git a/tests/parser-dhcpd.at b/tests/parser-dhcpd.at
new file mode 100644
index 0000000..1a05147
--- /dev/null
+++ b/tests/parser-dhcpd.at
@@ -0,0 +1,59 @@
+# This file is part of grecs -*- Autotest -*-
+# Copyright (C) 2011-2012, 2016 Sergey Poznyakoff
+#
+# Grecs is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Grecs is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Grecs. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([DHCPD-style parser])
+AT_KEYWORDS([parser dhcpd])
+
+AT_CHECK([gcffmt -type=dhcpd -I$abs_srcdir $abs_srcdir/dhcpd.conf|sed 's/ *$//'],
+[0],
+[.authoritative:
+.pid-file-name: "/var/run/dhcpd.pid"
+.log-facility: "daemon"
+.default-lease-time: "28800"
+.max-lease-time: "86400"
+.ddns-update-style: "none"
+.get-lease-hostnames: "yes"
+.ddns-update-style: "interim"
+.ignore: "client-updates"
+.ddns-rev-domainname: "in-addr.arpa."
+.use-host-decl-names: "on"
+.key="rndc-key".algorithm: "hmac-md5"
+.key="rndc-key".secret: "1111111111111111111111=="
+.zone="lan.example.com.".primary: "127.0.0.1"
+.zone="lan.example.com.".key: "foo"
+.option: "domain-search" ("example.com", "example.org", "example.net")
+.if="option dhcp-user-class = \"accounting\"".max-lease-time: "17600"
+.if="option dhcp-user-class = \"accounting\"".option: "domain-name" "accounting.example.org"
+.if="option dhcp-user-class = \"accounting\"".option: "domain-name-servers" ("ns1.accounting.example.org", "ns2.accounting.example.org")
+.elsif="option dhcp-user-class = \"sales\"".max-lease-time: "17600"
+.elsif="option dhcp-user-class = \"sales\"".option: "domain-name" "sales.example.org"
+.elsif="option dhcp-user-class = \"sales\"".option: "domain-name-servers" ("ns1.sales.example.org", "ns2.sales.example.org")
+.elsif="option dhcp-user-class = \"engineering\"".max-lease-time: "17600"
+.elsif="option dhcp-user-class = \"engineering\"".option: "domain-name" "engineering.example.org"
+.elsif="option dhcp-user-class = \"engineering\"".option: "domain-name-servers" ("ns1.engineering.example.org", "ns2.engineering.example.org")
+.else.max-lease-time: "600"
+.else.option: "domain-name" "misc.example.org"
+.else.option: "domain-name-servers" ("ns1.misc.example.org", "ns2.misc.example.org")
+.shared-network="LAN".subnet="192.168.0.0" "netmask" "255.255.255.0".option: "routers" "192.168.0.1"
+.shared-network="LAN".subnet="192.168.0.0" "netmask" "255.255.255.0".option: "domain-name-servers" "192.168.0.1"
+.shared-network="LAN".subnet="192.168.0.0" "netmask" "255.255.255.0".update-static-leases: "on"
+.shared-network="LAN".subnet="192.168.0.0" "netmask" "255.255.255.0".pool.range: "192.168.0.1" "192.168.0.254"
+.shared-network="LAN".subnet="192.168.0.0" "netmask" "255.255.255.0".pool.deny: "known-clients"
+.shared-network="LAN".subnet="192.168.0.0" "netmask" "255.255.255.0".pool.ddns-hostname: "binary-to-ascii(10, 8, \"-\", leased-address)"
+])
+
+AT_CLEANUP
+
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 67fc54a..79aa0f8 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -94,6 +94,11 @@ m4_include([bind00.at])
m4_include([locus-bind.at])
])
+m4_ifdef([ENABLE_DHCPD_PARSER],[
+AT_BANNER([DHCPD Parser])
+m4_include([parser-dhcpd.at])
+])
+
m4_ifdef([ENABLE_META1_PARSER],[
AT_BANNER([MeTA1 Parser])
m4_include([parser-meta1.at])

Return to:

Send suggestions and report system problems to the System administrator.