Browse Source

tests: Remove DejaGNU, automake already supports tallying exit based tests

* Automake already knows how to tally up exit status based tests. There's
  not much point wrapping such unit tests up in a whole ball of tcl and
  expect to scrape the output to determine the same thing and tally.

  Remove the DejaGNU stuff. Run the tests directly from automake, using
  TESTS = ...

  This removes the "check output doesn't differ" testcli and testcommand
  tests from testing, but those were testing exit status of the diff, which
  was succesful anyway.  So would pass even if output differed and should
  fail.

* test-cli.c: Add example usage.
* test-commands.c: ditto. And add missing nodes.
Paul Jakma 4 years ago
parent
commit
1d4b282f79

+ 0 - 14
configure.ac

@@ -1576,18 +1576,6 @@ dnl ----------
 CONFDATE=`date '+%Y%m%d'`
 AC_SUBST(CONFDATE)
 
-dnl -------
-dnl DejaGNU
-dnl -------
-if test x"$DEJAGNU" = x
-then
-  DEJAGNU="\$(top_srcdir)/tests/global-conf.exp"
-fi
-RUNTESTDEFAULTFLAGS="-x --tool \$\$tool"
-
-AC_SUBST(DEJAGNU)
-AC_SUBST(RUNTESTDEFAULTFLAGS)
-
 dnl ------------------------------
 dnl set paths for state directory
 dnl ------------------------------
@@ -1664,8 +1652,6 @@ AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile
 	  ospf6d/Makefile isisd/Makefile vtysh/Makefile
 	  doc/Makefile ospfclient/Makefile tests/Makefile m4/Makefile
 	  pimd/Makefile nhrpd/Makefile
-	  tests/bgpd.tests/Makefile
-	  tests/libzebra.tests/Makefile
 	  redhat/Makefile
 	  pkgsrc/Makefile
 	  fpm/Makefile

+ 4 - 11
tests/Makefile.am

@@ -1,15 +1,5 @@
-AUTOMAKE_OPTIONS    = dejagnu
-DEJATOOL = libzebra
-
-SUBDIRS = \
-	bgpd.tests \
-	libzebra.tests
 
 EXTRA_DIST = \
-	config/unix.exp \
-	lib/bgpd.exp \
-	lib/libzebra.exp \
-	global-conf.exp \
 	testcommands.in \
 	testcommands.refout \
 	testcli.in \
@@ -20,7 +10,6 @@ DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\"
 
 if BGPD
 TESTS_BGPD = aspathtest testbgpcap ecommtest testbgpmpattr testbgpmpath
-DEJATOOL += bgpd
 else
 TESTS_BGPD =
 endif
@@ -31,6 +20,10 @@ check_PROGRAMS = testsig testsegv testbuffer testmemory heavy heavywq heavythrea
 		testcli \
 		$(TESTS_BGPD)
 
+TESTS = $(TESTS_BGPD) teststream tabletest testmemory testnexthopiter \
+	test-timer-correctness tabletest
+
+
 ../vtysh/vtysh_cmd.c:
 	$(MAKE) -C ../vtysh vtysh_cmd.c
 

+ 0 - 7
tests/bgpd.tests/Makefile.am

@@ -1,7 +0,0 @@
-EXTRA_DIST = \
-	aspathtest.exp \
-	ecommtest.exp \
-	testbgpcap.exp \
-	testbgpmpath.exp \
-	testbgpmpattr.exp
-

+ 0 - 76
tests/bgpd.tests/aspathtest.exp

@@ -1,76 +0,0 @@
-set timeout 10
-set testprefix "aspathtest "
-set aborted 0
-set color 1
-
-spawn "./aspathtest"
-
-# proc onetest { test_name note start } {
-# proc headerline { line } {
- 
-set parserno 0
-proc parsertest { test_name } {
-	global parserno
-	headerline "test $parserno"
-	onetest "parse $test_name" " ($parserno)" "$test_name:"
-	onetest "parse $test_name +empty_prepend" " (#$parserno)" "empty prepend $test_name:"
-	incr parserno 1
-}
-set attrno 0
-proc attrtest { test_name } {
-	global attrno
-	headerline "aspath_attr test $attrno"
-	onetest "attr $test_name" " (#$attrno)" "$test_name"
-	incr attrno 1
-}
-
-
-parsertest "seq1"
-parsertest "seq2"
-parsertest "seq3"
-parsertest "seqset"
-parsertest "seqset2"
-parsertest "multi"
-parsertest "confed"
-parsertest "confed2"
-parsertest "confset"
-parsertest "confmulti"
-parsertest "seq4"
-parsertest "tripleseq1"
-parsertest "someprivate"
-parsertest "allprivate"
-parsertest "long"
-parsertest "seq1extra"
-parsertest "empty"
-parsertest "redundantset"
-parsertest "reconcile_lead_asp"
-parsertest "reconcile_new_asp"
-parsertest "reconcile_confed"
-parsertest "reconcile_start_trans"
-parsertest "reconcile_start_trans4"
-parsertest "reconcile_start_trans_error"
-parsertest "redundantset2"
-parsertest "zero-size overflow"
-parsertest "zero-size overflow + valid segment"
-parsertest "invalid segment type"
-
-for {set i 0} {$i < 10} {incr i 1} { onetest "prepend $i" "" "prepend test $i"; }
-for {set i 0} {$i <  5} {incr i 1} { onetest "aggregate $i" "" "aggregate test $i"; }
-for {set i 0} {$i <  5} {incr i 1} { onetest "reconcile $i" "" "reconcile test $i"; }
-for {set i 0} {$i < 22} {incr i 1} { onetest "compare $i" "" "left cmp "; }
-
-onetest "empty_get" "" "empty_get_test"
-attrtest "basic test"
-attrtest "length too short"
-attrtest "length too long"
-attrtest "incorrect flag"
-attrtest "as4_path, with as2 format data"
-attrtest "as4, with incorrect attr length"
-attrtest "basic 4-byte as-path"
-attrtest "4b AS_PATH: too short"
-attrtest "4b AS_PATH: too long"
-attrtest "4b AS_PATH: too long2"
-attrtest "4b AS_PATH: bad flags"
-attrtest "4b AS4_PATH w/o AS_PATH"
-attrtest "4b AS4_PATH: confed"
-

+ 0 - 13
tests/bgpd.tests/ecommtest.exp

@@ -1,13 +0,0 @@
-set timeout 10
-set testprefix "ecommtest "
-set aborted 0
-set color 0
-
-spawn "./ecommtest"
-
-# proc simpletest { start } {
-
-simpletest "ipaddr"
-simpletest "ipaddr-so"
-simpletest "asn"
-simpletest "asn4"

+ 0 - 51
tests/bgpd.tests/testbgpcap.exp

@@ -1,51 +0,0 @@
-set timeout 10
-set testprefix "testbgpcap "
-set aborted 0
-set color 1
-
-spawn "./testbgpcap"
-
-# proc simpletest { start } {
-
-simpletest "MP4: MP IP/Uni"
-simpletest "MPv6: MP IPv6/Uni"
-simpletest "MP2: MP IP/Multicast"
-simpletest "MP3: MP IP6/MPLS-labeled VPN"
-simpletest "MP5: MP IP6/MPLS-VPN"
-simpletest "MP6: MP IP4/MPLS-laveled VPN"
-simpletest "MP8: MP unknown AFI/SAFI"
-simpletest "MP-short: MP IP4/Unicast, length too short (< minimum)"
-simpletest "MP-overflow: MP IP4/Unicast, length too long"
-simpletest "caphdr: capability header, and no more"
-simpletest "nodata: header, no data but length says there is"
-simpletest "padded: valid, with padding"
-simpletest "minsize: violates minsize requirement"
-simpletest "ORF: ORF, simple, single entry, single tuple"
-simpletest "ORF-many: ORF, multi entry/tuple"
-simpletest "ORFlo: ORF, multi entry/tuple, hdr length too short"
-simpletest "ORFlu: ORF, multi entry/tuple, length too long"
-simpletest "ORFnu: ORF, multi entry/tuple, entry number too long"
-simpletest "ORFno: ORF, multi entry/tuple, entry number too short"
-simpletest "ORFpad: ORF, multi entry/tuple, padded to align"
-simpletest "AS4: AS4 capability"
-simpletest "GR: GR capability"
-simpletest "GR-short: GR capability, but header length too short"
-simpletest "GR-long: GR capability, but header length too long"
-simpletest "GR-trunc: GR capability, but truncated"
-simpletest "GR-empty: GR capability, but empty."
-simpletest "MP-empty: MP capability, but empty."
-simpletest "ORF-empty: ORF capability, but empty."
-simpletest "AS4-empty: AS4 capability, but empty."
-simpletest "dyn-empty: Dynamic capability, but empty."
-simpletest "dyn-old: Dynamic capability (deprecated version)"
-simpletest "Cap-singlets: One capability per Optional-Param"
-simpletest "Cap-series: Series of capability, one Optional-Param"
-simpletest "AS4more: AS4 capability after other caps (singlets)"
-simpletest "AS4series: AS4 capability, in series of capabilities"
-simpletest "AS4real: AS4 capability, in series of capabilities"
-simpletest "AS4real2: AS4 capability, in series of capabilities"
-simpletest "DynCap: Dynamic Capability Message, IP/Multicast"
-simpletest "DynCapLong: Dynamic Capability Message, IP/Multicast, truncated"
-simpletest "DynCapPadded: Dynamic Capability Message, IP/Multicast, padded"
-simpletest "DynCapMPCpadded: Dynamic Capability Message, IP/Multicast, cap data padded"
-simpletest "DynCapMPCoverflow: Dynamic Capability Message, IP/Multicast, cap data != length"

+ 0 - 12
tests/bgpd.tests/testbgpmpath.exp

@@ -1,12 +0,0 @@
-set timeout 10
-set testprefix "testbgpmpath "
-set aborted 0
-set color 1
-
-spawn "./testbgpmpath"
-
-# proc simpletest { start } {
-
-simpletest "bgp maximum-paths config"
-simpletest "bgp_mp_list"
-simpletest "bgp_info_mpath_update"

+ 0 - 38
tests/bgpd.tests/testbgpmpattr.exp

@@ -1,38 +0,0 @@
-set timeout 10
-set testprefix "testbgpmpattr "
-set aborted 0
-set color 1
-
-spawn "./testbgpmpattr"
-
-# proc simpletest { start } {
-
-simpletest "IPv6: IPV6 MP Reach, global nexthop, 1 NLRI"
-simpletest "IPv6-2: IPV6 MP Reach, global nexthop, 2 NLRIs"
-simpletest "IPv6-default: IPV6 MP Reach, global nexthop, 2 NLRIs + default"
-simpletest "IPv6-lnh: IPV6 MP Reach, global+local nexthops, 2 NLRIs + default"
-simpletest "IPv6-nhlen: IPV6 MP Reach, inappropriate nexthop length"
-simpletest "IPv6-nhlen2: IPV6 MP Reach, invalid nexthop length"
-simpletest "IPv6-nhlen3: IPV6 MP Reach, nexthop length overflow"
-simpletest "IPv6-nhlen4: IPV6 MP Reach, nexthop length short"
-simpletest "IPv6-nlri: IPV6 MP Reach, NLRI bitlen overflow"
-simpletest "IPv4: IPv4 MP Reach, 2 NLRIs + default"
-simpletest "IPv4-nhlen: IPv4 MP Reach, nexthop lenth overflow"
-simpletest "IPv4-nlrilen: IPv4 MP Reach, nlri lenth overflow"
-simpletest "IPv4-VPNv4: IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs"
-simpletest "IPv4-VPNv4-bogus-plen: IPv4/MPLS-labeled VPN MP Reach, RD, Nexthop, NLRI / bogus p'len"
-simpletest "IPv4-VPNv4-plen1-short: IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs, 1st plen short"
-simpletest "IPv4-VPNv4-plen1-long: IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs, 1st plen long"
-simpletest "IPv4-VPNv4-plenn-long: IPv4/VPNv4 MP Reach, RD, Nexthop, 3 NLRIs, last plen long"
-simpletest "IPv4-VPNv4-plenn-short: IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs, last plen short"
-simpletest "IPv4-VPNv4-bogus-rd-type: IPv4/VPNv4 MP Reach, RD, NH, 2 NLRI, unknown RD in 1st (log, but parse)"
-simpletest "IPv4-VPNv4-0-nlri: IPv4/VPNv4 MP Reach, RD, Nexthop, 3 NLRI, 3rd 0 bogus"
-simpletest "IPv6-bug: IPv6, global nexthop, 1 default NLRI"
-simpletest "IPv6-unreach: IPV6 MP Unreach, 1 NLRI"
-simpletest "IPv6-unreach2: IPV6 MP Unreach, 2 NLRIs"
-simpletest "IPv6-unreach-default: IPV6 MP Unreach, 2 NLRIs + default"
-simpletest "IPv6-unreach-nlri: IPV6 MP Unreach, NLRI bitlen overflow"
-simpletest "IPv4-unreach: IPv4 MP Unreach, 2 NLRIs + default"
-simpletest "IPv4-unreach-nlrilen: IPv4 MP Unreach, nlri length overflow"
-simpletest "IPv4-unreach-VPNv4: IPv4/MPLS-labeled VPN MP Unreach, RD, 3 NLRIs"
-

+ 0 - 102
tests/config/unix.exp

@@ -1,102 +0,0 @@
-
-# every test should always be run and always return some status.
-# so, if we lose sync with a multi-test program, aborted will be used
-# to flag the remainder of the tests as untested.
-#set aborted 0
-
-# only match with color codes since "failed" / "OK" might otherwise
-# be part of the output...
-#set color 1
-
-set xfail 0
-
-proc onesimple { test_name match } {
-	global verbose
-	global aborted
-	global testprefix
-	if { $aborted > 0 } {
-		untested "$testprefix$test_name"
-		return
-	}
-	if { $verbose > 0 } {
-		send_user "$testprefix$test_name$note\n"
-	}
-	expect {
-		"$match"	{ pass "$testprefix$test_name"; }
-		eof		{ fail "$testprefix$test_name"; set aborted 1; }
-		timeout		{ unresolved "$testprefix$test_name"; set aborted 1; }
-	}
-}
-
-proc onetest { test_name note start } {
-	global aborted
-	global testprefix
-	global verbose
-	global color
-	global xfail
-
-	if { $aborted > 0 } {
-		untested "$testprefix$test_name"
-		return
-	}
-
-	if { $verbose > 0 } {
-		send_user "$testprefix$test_name$note\n"
-	}
-	expect {
-		"$start"	{ }
-
-		eof	{ unresolved "$testprefix$test_name"; set aborted 1; }
-		timeout	{ unresolved "$testprefix$test_name"; set aborted 1; }
-	}
-
-	if { $aborted > 0 } {
-		send_user "sync failed: $testprefix$test_name$note -- $testprefix aborted!\n"
-		return
-	}
-
-	if { $color } {
-		set pat "(32mOK|31mfailed)"
-	} else {
-		set pat "(OK|failed)"
-	}
-	expect {
-		# need this because otherwise expect will skip over a "failed" and
-		# grab the next "OK" (or the other way around)
-		-re "$pat"  {
-			if { "$expect_out(0,string)" == "32mOK" || "$expect_out(0,string)" == "OK" } {
-				pass "$testprefix$test_name"
-			} else {
-				if { $xfail } {
-					xfail "$testprefix$test_name"
-				} else {
-					fail "$testprefix$test_name"
-				}
-			}
-			return
-		}
-
-		eof	{ unresolved "$testprefix$test_name"; set aborted 1; }
-		timeout	{ unresolved "$testprefix$test_name"; set aborted 1; }
-	}
-
-	if { $aborted > 0 } {
-		send_user "failed: $testprefix$test_name$note -- $testprefix aborted!\n"
-		return
-	}
-}
-
-proc headerline { line } {
-	global aborted
-	if { $aborted > 0 } { return; }
-	expect {
-		$line	{ return; }
-		eof	{ send_user "numbering mismatch!\n"; set aborted 1; }
-		timeout	{ send_user "numbering mismatch!\n"; set aborted 1; }
-	}
-}
-
-proc simpletest { start } {
-	onetest "$start" "" "$start"
-}
-

+ 0 - 0
tests/global-conf.exp


+ 0 - 0
tests/lib/bgpd.exp


+ 0 - 0
tests/lib/libzebra.exp


+ 0 - 9
tests/libzebra.tests/tabletest.exp

@@ -1,9 +0,0 @@
-set timeout 10
-set testprefix "tabletest "
-set aborted 0
-
-spawn "./tabletest"
-
-for {set i 0} {$i <  6} {incr i 1} { onesimple "cmp $i" "Verifying cmp"; }
-for {set i 0} {$i < 11} {incr i 1} { onesimple "succ $i" "Verifying successor"; }
-onesimple "pause" "Verified pausing"

+ 0 - 7
tests/libzebra.tests/test-timer-correctness.exp

@@ -1,7 +0,0 @@
-set timeout 10
-set testprefix "test-timer-correctness"
-set aborted 0
-
-spawn "./test-timer-correctness"
-
-onesimple "" "Expected output and actual output match."

+ 0 - 23
tests/libzebra.tests/testcli.exp

@@ -1,23 +0,0 @@
-set timeout 30
-set test_name "testcli"
-
-spawn sh -c "./testcli < $env(srcdir)/testcli.in | diff -au $env(srcdir)/testcli.refout -"
-
-expect {
-	eof {
-	}
-	timeout {
-		exp_close
-		fail "$test_name: timeout"
-	}
-}
-
-catch wait result
-set os_error    [lindex $result 2]
-set exit_status [lindex $result 3]
-
-if { $os_error == 0 && $exit_status == 0 } {
-	pass "$test_name"
-} else {
-	fail "$test_name"
-}

+ 0 - 31
tests/libzebra.tests/testcommands.exp

@@ -1,31 +0,0 @@
-set timeout 30
-set test_name "testcommands"
-
-if {![info exists env(QUAGGA_TEST_COMMANDS)]} {
-	# sadly, the test randomly fails when configure parameters differ from
-	# what was used to create testcommands.refout.  this can be fixed by
-	# shipping a matching vtysh_cmd.c, which we'll add after 0.99.23
-	unresolved "$test_name"
-	exit 0
-}
-
-spawn sh -c "./testcommands -e 0 < $env(srcdir)/testcommands.in | diff -au - $env(srcdir)/testcommands.refout"
-
-expect {
-	eof {
-	}
-	timeout {
-		exp_close
-		fail "$test_name: timeout"
-	}
-}
-
-catch wait result
-set os_error    [lindex $result 2]
-set exit_status [lindex $result 3]
-
-if { $os_error == 0 && $exit_status == 0 } {
-	pass "$test_name"
-} else {
-	fail "$test_name"
-}

+ 0 - 8
tests/libzebra.tests/testnexthopiter.exp

@@ -1,8 +0,0 @@
-set timeout 10
-set testprefix "testnexthopiter "
-set aborted 0
-
-spawn "./testnexthopiter"
-
-onesimple "simple" "Simple test passed."
-onesimple "prng" "PRNG test passed."

+ 0 - 28
tests/libzebra.tests/teststream.exp

@@ -1,28 +0,0 @@
-set timeout 10
-spawn "./teststream"
-
-expect {
-	"endp: 15, readable: 15, writeable: 1009" { }
-	eof { fail "teststream"; exit; } timeout { fail "teststream"; exit; } }
-expect {
-	"0xef 0xbe 0xef 0xde 0xad 0xbe 0xef 0xde 0xad 0xbe 0xef 0xde 0xad 0xbe 0xef" { }
-	eof { fail "teststream"; exit; } timeout { fail "teststream"; exit; } }
-expect {
-	"endp: 15, readable: 15, writeable: 0" { }
-	eof { fail "teststream"; exit; } timeout { fail "teststream"; exit; } }
-expect {
-	"0xef 0xbe 0xef 0xde 0xad 0xbe 0xef 0xde 0xad 0xbe 0xef 0xde 0xad 0xbe 0xef" { }
-	eof { fail "teststream"; exit; } timeout { fail "teststream"; exit; } }
-expect {
-	"c: 0xef" { }
-	eof { fail "teststream"; exit; } timeout { fail "teststream"; exit; } }
-expect {
-	"w: 0xbeef" { }
-	eof { fail "teststream"; exit; } timeout { fail "teststream"; exit; } }
-expect {
-	"l: 0xdeadbeef" { }
-	eof { fail "teststream"; exit; } timeout { fail "teststream"; exit; } }
-expect {
-	"q: 0xdeadbeefdeadbeef" { }
-	eof { fail "teststream"; exit; } timeout { fail "teststream"; exit; } }
-pass "teststream"

+ 5 - 0
tests/test-cli.c

@@ -20,6 +20,11 @@
  * 02111-1307, USA.
  */
 
+ /* example usage:
+  *
+  * ./testcli < testcli.in | diff -au testcli.refout -
+  */
+
 #include <zebra.h>
 
 #include "common-cli.h"

+ 37 - 1
tests/test-commands.c

@@ -27,6 +27,11 @@
  * 02111-1307, USA.
  */
 
+ /* Example use for testing:
+  * ./testcommands -e 0 < testcommands.in | \
+  *	diff -au - testcommands.refout
+  */
+
 #define REALLY_NEED_PLAIN_GETOPT 1
 
 #include <zebra.h>
@@ -91,6 +96,12 @@ static struct cmd_node bgp_vpnv4_node =
   "%s(config-router-af)# "
 };
 
+static struct cmd_node bgp_vpnv6_node =
+{
+  BGP_VPNV6_NODE,
+  "%s(config-router-af-vpnv6)# ",
+};
+
 static struct cmd_node bgp_ipv4_node =
 {
   BGP_IPV4_NODE,
@@ -115,6 +126,18 @@ static struct cmd_node bgp_ipv6m_node =
   "%s(config-router-af)# "
 };
 
+static struct cmd_node bgp_encap_node =
+{
+  BGP_ENCAP_NODE,
+  "%s(config-router-af-encap)# ",
+};
+
+static struct cmd_node bgp_encapv6_node =
+{
+  BGP_ENCAPV6_NODE,
+  "%s(config-router-af-encapv6)# ",
+};
+
 static struct cmd_node ospf_node =
 {
   OSPF_NODE,
@@ -151,6 +174,14 @@ static struct cmd_node keychain_key_node =
   "%s(config-keychain-key)# "
 };
 
+static struct cmd_node link_params_node =
+{
+  LINK_PARAMS_NODE,
+  "%s(config-link-params)# ",
+};
+
+
+
 static int
 test_callback(struct cmd_element *cmd, struct vty *vty, int argc, const char *argv[])
 {
@@ -210,10 +241,13 @@ test_init(void)
   install_node (&rmap_node, NULL);
   install_node (&zebra_node, NULL);
   install_node (&bgp_vpnv4_node, NULL);
+  install_node (&bgp_vpnv6_node, NULL);
   install_node (&bgp_ipv4_node, NULL);
   install_node (&bgp_ipv4m_node, NULL);
   install_node (&bgp_ipv6_node, NULL);
   install_node (&bgp_ipv6m_node, NULL);
+  install_node (&bgp_encap_node, NULL);
+  install_node (&bgp_encapv6_node, NULL);
   install_node (&ospf_node, NULL);
   install_node (&ripng_node, NULL);
   install_node (&ospf6_node, NULL);
@@ -222,7 +256,9 @@ test_init(void)
   install_node (&keychain_key_node, NULL);
   install_node (&isis_node, NULL);
   install_node (&vty_node, NULL);
-
+  install_node (&link_params_node, NULL);
+  //install_node (&zebra_if_defaults_node, NULL);
+  
   test_init_cmd();
 
   for (node = 0; node < vector_active(cmdvec); node++)