All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup
@ 2015-01-23  9:36 Xing Gu
  2015-01-23  9:36 ` [LTP] [PATCH 2/7] lib6/asapi_02.c: cleanup Xing Gu
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Xing Gu @ 2015-01-23  9:36 UTC (permalink / raw)
  To: ltp-list

* Remove useless comments.

* Modify the format of ftab[].

* Move the test body from main() to do_test().

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
 testcases/network/lib6/asapi_01.c | 438 ++++++++++++++++----------------------
 1 file changed, 188 insertions(+), 250 deletions(-)

diff --git a/testcases/network/lib6/asapi_01.c b/testcases/network/lib6/asapi_01.c
index 8d1fed8..1de4c78 100644
--- a/testcases/network/lib6/asapi_01.c
+++ b/testcases/network/lib6/asapi_01.c
@@ -1,6 +1,7 @@
 /*
  *
  *   Copyright (c) International Business Machines  Corp., 2001
+ *   Author: David L Stevens
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -13,26 +14,13 @@
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *   along with this program;  if not, write to the Free Software Foundation,
+ *   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-
 /*
- * Test Name: asapi_01
- *
- * Test Description:
- *  These tests are for the "Advanced Sockets API" (RFC 3542)
- *  Verify that in6 and sockaddr fields are present.
- *
- * Usage:  <for command-line>
- *  asapi_01
- *
- * HISTORY
- *	01/2005 written by David L Stevens
- *
- * RESTRICTIONS:
- *  None.
- *
+ *   Description:
+ *     These tests are for the "Advanced Sockets API" (RFC 3542)
+ *     Verify that in6 and sockaddr fields are present.
  */
 
 #include <stdio.h>
@@ -47,13 +35,9 @@
 #include "usctest.h"
 #include "runcc.h"
 
-char *TCID = "asapi_01";	/* Test program identifier.    */
-
-void setup(void), cleanup(void);
-
 enum ttype { EXISTS, ALIAS, VALUE };
 
-struct ftent {
+static struct ftent {
 	char *ft_tname;		/* test name */
 	int ft_type;		/* test type */
 	char *ft_incl;		/* include file list */
@@ -67,258 +51,212 @@ struct ftent {
 #define ft_value	ftun.fu_value
 #define ft_dname	ftun.fu_dname
 } ftab[] = {
-/* section 2.1 structure & field definitions */
-	{
-		"ip6_hdr un1_flow", EXISTS, IP6_H, "ip6_hdr",
-		    "ip6_ctlun.ip6_un1.ip6_un1_flow", "0", {
-	"4"}}, {
-		"ip6_hdr ip6_flow", ALIAS, IP6_H, "ip6_hdr",
-		    "ip6_ctlun.ip6_un1.ip6_un1_flow", NULL, {
-	"ip6_flow"}}, {
-		"ip6_hdr un1_plen", EXISTS, IP6_H, "ip6_hdr",
-		    "ip6_ctlun.ip6_un1.ip6_un1_plen", "4", {
-	"2"}}, {
-		"ip6_hdr ip6_plen", ALIAS, IP6_H, "ip6_hdr",
-		    "ip6_ctlun.ip6_un1.ip6_un1_plen", "4", {
-	"ip6_plen"}}, {
-		"ip6_hdr un1_nxt", EXISTS, IP6_H, "ip6_hdr",
-		    "ip6_ctlun.ip6_un1.ip6_un1_nxt", "6", {
-	"1"}}, {
-		"ip6_hdr ip6_nxt", ALIAS, IP6_H, "ip6_hdr",
-		    "ip6_ctlun.ip6_un1.ip6_un1_nxt", NULL, {
-	"ip6_nxt"}}, {
-		"ip6_hdr un1_hlim", EXISTS, IP6_H, "ip6_hdr",
-		    "ip6_ctlun.ip6_un1.ip6_un1_hlim", "7", {
-	"1"}}, {
-		"ip6_hdr ip6_hlim", ALIAS, IP6_H, "ip6_hdr",
-		    "ip6_ctlun.ip6_un1.ip6_un1_hlim", NULL, {
-	"ip6_hlim"}}, {
-		"ip6_hdr un1_vfc", EXISTS, IP6_H, "ip6_hdr",
-		    "ip6_ctlun.ip6_un2_vfc", "0", {
-	"1"}}, {
-		"ip6_hdr ip6_src", EXISTS, IP6_H, "ip6_hdr", "ip6_src",
-		    "sizeof(struct ip6_hdrctl)", {
-	"sizeof(struct in6_addr)"}}, {
-		"ip6_hdr ip6_dst", EXISTS, IP6_H, "ip6_hdr", "ip6_dst",
-		    "(sizeof(struct ip6_hdrctl)+sizeof(struct in6_addr))", {
-	"sizeof(struct in6_addr)"}},
-/* section 2.2 structure and field definitions */
-	{
-		"IPPROTO_HOPOPTS", VALUE, IN_H, "IPPROTO_HOPOPTS", NULL, NULL, {
-	"0"}}, {
-		"IPPROTO_IPV6", VALUE, IN_H, "IPPROTO_IPV6", NULL, NULL, {
-	"41"}}, {
-		"IPPROTO_ROUTING", VALUE, IN_H, "IPPROTO_ROUTING", NULL, NULL, {
-	"43"}}, {
-		"IPPROTO_FRAGMENT", VALUE, IN_H, "IPPROTO_FRAGMENT", NULL, NULL, {
-	"44"}}, {
-		"IPPROTO_ESP", VALUE, IN_H, "IPPROTO_ESP", NULL, NULL, {
-	"50"}}, {
-		"IPPROTO_AH", VALUE, IN_H, "IPPROTO_AH", NULL, NULL, {
-	"51"}}, {
-		"IPPROTO_ICMPV6", VALUE, IN_H, "IPPROTO_ICMPV6", NULL, NULL, {
-	"58"}}, {
-		"IPPROTO_NONE", VALUE, IN_H, "IPPROTO_NONE", NULL, NULL, {
-	"59"}}, {
-		"IPPROTO_DSTOPTS", VALUE, IN_H, "IPPROTO_DSTOPTS", NULL, NULL, {
-	"60"}},
-/* ip6_hbh */
-	{
-		"ip6_hbh ip6h_nxt", EXISTS, IP6_H, "ip6_hbh", "ip6h_nxt", "0", {
-	"1"}}, {
-		"ip6_hbh ip6h_nxt", EXISTS, IP6_H, "ip6_hbh", "ip6h_len", "1", {
-	"1"}},
-/* ip6_dest */
-	{
-		"ip6_dest ip6d_nxt", EXISTS, IP6_H, "ip6_dest", "ip6d_nxt", "0", {
-	"1"}}, {
-		"ip6_dest ip6d_nxt", EXISTS, IP6_H, "ip6_dest", "ip6d_len", "1", {
-	"1"}},
-/* ip6_rthdr0 */
-	{
-		"ip6_rthdr0 ip6r0_nxt", EXISTS, IP6_H, "ip6_rthdr0",
-		    "ip6r0_nxt", "0", {
-	"1"}}, {
-		"ip6_rthdr0 ip6r0_len", EXISTS, IP6_H, "ip6_rthdr0",
-		    "ip6r0_len", "1", {
-	"1"}}, {
-		"ip6_rthdr0 ip6r0_type", EXISTS, IP6_H, "ip6_rthdr0",
-		    "ip6r0_type", "2", {
-	"1"}}, {
-		"ip6_rthdr0 ip6r0_segleft", EXISTS, IP6_H, "ip6_rthdr0",
-		    "ip6r0_segleft", "3", {
-	"1"}}, {
-		"ip6_rthdr0 ip6r0_reserved", EXISTS, IP6_H, "ip6_rthdr0",
-		    "ip6r0_reserved", "4", {
-	"1"}},
-/* ip6_frag */
-	{
-		"ip6_frag ip6f_nxt", EXISTS, IP6_H, "ip6_frag", "ip6f_nxt", "0", {
-	"1"}}, {
-		"ip6_frag ip6f_reserved", EXISTS, IP6_H, "ip6_frag",
-		    "ip6f_reserved", "1", {
-	"1"}}, {
-		"ip6_frag ip6f_offlg", EXISTS, IP6_H, "ip6_frag",
-		    "ip6f_offlg", "2", {
-	"2"}}, {
-		"ip6_frag ip6f_ident", EXISTS, IP6_H, "ip6_frag",
-		    "ip6f_ident", "4", {
-	"4"}}, {
-		"IP6F_OFF_MASK", VALUE, IP6_H, "IP6F_OFF_MASK", NULL, NULL, {
-	"htons(0xfff8)"}}, {
-		"IP6F_RESERVED_MASK", VALUE, IP6_H, "IP6F_RESERVED_MASK",
-		    NULL, NULL, {
-	"htons(0x0006)"}}, {
-		"IP6F_MORE_FRAG", VALUE, IP6_H, "IP6F_MORE_FRAG", NULL, NULL, {
-	"htons(0x0001)"}}, {
-		"IP6OPT_TYPE", VALUE, IP6_H, "IP6OPT_TYPE(0xff)", NULL, NULL, {
-	"0xc0"}}, {
-		"IP6OPT_TYPE_SKIP", VALUE, IP6_H, "IP6OPT_TYPE_SKIP",
-		    NULL, NULL, {
-	"0x00"}}, {
-		"IP6OPT_TYPE_DISCARD", VALUE, IP6_H, "IP6OPT_TYPE_DISCARD",
-		    NULL, NULL, {
-	"0x40"}}, {
-		"IP6OPT_TYPE_FORCEICMP", VALUE, IP6_H, "IP6OPT_TYPE_FORCEICMP",
-		    NULL, NULL, {
-	"0x80"}}, {
-		"IP6OPT_TYPE_ICMP", VALUE, IP6_H, "IP6OPT_TYPE_ICMP",
-		    NULL, NULL, {
-	"0xc0"}}, {
-		"IP6OPT_TYPE_MUTABLE", VALUE, IP6_H, "IP6OPT_TYPE_MUTABLE",
-		    NULL, NULL, {
-	"0x20"}}, {
-		"IP6OPT_PAD1", VALUE, IP6_H, "IP6OPT_PAD1", NULL, NULL, {
-	"0x00"}}, {
-		"IP6OPT_PADN", VALUE, IP6_H, "IP6OPT_PADN", NULL, NULL, {
-	"0x01"}}, {
-		"IP6OPT_JUMBO", VALUE, IP6_H, "IP6OPT_JUMBO", NULL, NULL, {
-	"0xc2"}}, {
-		"IP6OPT_NSAP_ADDR", VALUE, IP6_H, "IP6OPT_NSAP_ADDR",
-		    NULL, NULL, {
-	"0xc3"}}, {
-		"IP6OPT_TUNNEL_LIMIT", VALUE, IP6_H, "IP6OPT_TUNNEL_LIMIT",
-		    NULL, NULL, {
-	"0x04"}}, {
-		"IP6OPT_ROUTER_ALERT", VALUE, IP6_H, "IP6OPT_ROUTER_ALERT",
-		    NULL, NULL, {
-	"0x05"}},
-/* ip6_opt_jumbo */
-	{
-		"ip6_opt_jumbo ip6oj_type", EXISTS, IP6_H, "ip6_opt_jumbo",
-		    "ip6oj_type", "0", {
-	"1"}}, {
-		"ip6_opt_jumbo ip6oj_len", EXISTS, IP6_H, "ip6_opt_jumbo",
-		    "ip6oj_len", "1", {
-	"1"}}, {
-		"ip6_opt_jumbo ip6oj_jumbo_len element", EXISTS, IP6_H,
-		    "ip6_opt_jumbo", "ip6oj_jumbo_len[0]", "2", {
-	"1"}}, {
-		"ip6_opt_jumbo ip6oj_jumbo_len array", EXISTS, IP6_H,
-		    "ip6_opt_jumbo", "ip6oj_jumbo_len", "2", {
-	"4"}},
-/* ip6_opt_nsap */
-	{
-		"ip6_opt_nsap ip6on_type", EXISTS, IP6_H, "ip6_opt_nsap",
-		    "ip6on_type", "0", {
-	"1"}}, {
-		"ip6_opt_nsap ip6on_len", EXISTS, IP6_H, "ip6_opt_nsap",
-		    "ip6on_len", "1", {
-	"1"}}, {
-		"ip6_opt_nsap ip6on_src_nsap_len", EXISTS, IP6_H,
-		    "ip6_opt_nsap", "ip6on_src_nsap_len", "2", {
-	"1"}}, {
-		"ip6_opt_nsap ip6on_dst_nsap_len", EXISTS, IP6_H,
-		    "ip6_opt_nsap", "ip6on_dst_nsap_len", "3", {
-	"1"}},
-/* ip6_opt_tunnel */
-	{
-		"ip6_opt_tunnel ip6ot_type", EXISTS, IP6_H, "ip6_opt_tunnel",
-		    "ip6ot_type", "0", {
-	"1"}}, {
-		"ip6_opt_tunnel ip6ot_len", EXISTS, IP6_H, "ip6_opt_tunnel",
-		    "ip6ot_len", "1", {
-	"1"}}, {
-		"ip6_opt_tunnel ip6ot_encap_limit", EXISTS, IP6_H,
-		    "ip6_opt_tunnel", "ip6ot_encap_limit", "2", {
-	"1"}},
-/* ip6_opt_router */
-	{
-		"ip6_opt_router ip6or_type", EXISTS, IP6_H, "ip6_opt_router",
-		    "ip6or_type", "0", {
-	"1"}}, {
-		"ip6_opt_router ip6or_len", EXISTS, IP6_H, "ip6_opt_router",
-		    "ip6or_len", "1", {
-	"1"}}, {
-		"ip6_opt_router ip6or_value element", EXISTS, IP6_H,
-		    "ip6_opt_router", "ip6or_value[0]", "2", {
-	"1"}}, {
-		"ip6_opt_router ip6or_value array", EXISTS, IP6_H,
-		    "ip6_opt_router", "ip6or_value", "2", {
-	"2"}},
-/* IP6_ALERT_* definitions */
-	{
-		"IP6_ALERT_MLD", VALUE, IP6_H, "IP6_ALERT_MLD", NULL, NULL, {
-	"0"}}, {
-		"IP6_ALERT_RSVP", VALUE, IP6_H, "IP6_ALERT_RSVP", NULL, NULL, {
-	"htons(1)"}}, {
-		"IP6_ALERT_AN", VALUE, IP6_H, "IP6_ALERT_AN", NULL, NULL, {
-"htons(2)"}},};
+	/* section 2.1 structure & field definitions */
+	{ "ip6_hdr un1_flow", EXISTS, IP6_H, "ip6_hdr",
+		"ip6_ctlun.ip6_un1.ip6_un1_flow", "0", {"4"} },
+	{ "ip6_hdr ip6_flow", ALIAS, IP6_H, "ip6_hdr",
+		"ip6_ctlun.ip6_un1.ip6_un1_flow", NULL, {"ip6_flow"} },
+	{ "ip6_hdr un1_plen", EXISTS, IP6_H, "ip6_hdr",
+		"ip6_ctlun.ip6_un1.ip6_un1_plen", "4", {"2"} },
+	{ "ip6_hdr ip6_plen", ALIAS, IP6_H, "ip6_hdr",
+		"ip6_ctlun.ip6_un1.ip6_un1_plen", "4", {"ip6_plen"} },
+	{ "ip6_hdr un1_nxt", EXISTS, IP6_H, "ip6_hdr",
+		"ip6_ctlun.ip6_un1.ip6_un1_nxt", "6", {"1"} },
+	{ "ip6_hdr ip6_nxt", ALIAS, IP6_H, "ip6_hdr",
+		"ip6_ctlun.ip6_un1.ip6_un1_nxt", NULL, {"ip6_nxt"} },
+	{ "ip6_hdr un1_hlim", EXISTS, IP6_H, "ip6_hdr",
+		"ip6_ctlun.ip6_un1.ip6_un1_hlim", "7", {"1"} },
+	{ "ip6_hdr ip6_hlim", ALIAS, IP6_H, "ip6_hdr",
+		"ip6_ctlun.ip6_un1.ip6_un1_hlim", NULL, {"ip6_hlim"} },
+	{ "ip6_hdr un1_vfc", EXISTS, IP6_H, "ip6_hdr",
+		"ip6_ctlun.ip6_un2_vfc", "0", {"1"} },
+	{ "ip6_hdr ip6_src", EXISTS, IP6_H, "ip6_hdr",
+		"ip6_src", "sizeof(struct ip6_hdrctl)",
+		{"sizeof(struct in6_addr)"} },
+	{ "ip6_hdr ip6_dst", EXISTS, IP6_H, "ip6_hdr", "ip6_dst",
+		"(sizeof(struct ip6_hdrctl)+sizeof(struct in6_addr))",
+		{"sizeof(struct in6_addr)"} },
+	/* section 2.2 structure and field definitions */
+	{ "IPPROTO_HOPOPTS", VALUE, IN_H, "IPPROTO_HOPOPTS",
+		NULL, NULL, {"0"} },
+	{ "IPPROTO_IPV6", VALUE, IN_H, "IPPROTO_IPV6",
+		NULL, NULL, {"41"} },
+	{ "IPPROTO_ROUTING", VALUE, IN_H, "IPPROTO_ROUTING",
+		NULL, NULL, {"43"} },
+	{ "IPPROTO_FRAGMENT", VALUE, IN_H, "IPPROTO_FRAGMENT",
+		NULL, NULL, {"44"} },
+	{ "IPPROTO_ESP", VALUE, IN_H, "IPPROTO_ESP",
+		NULL, NULL, {"50"} },
+	{ "IPPROTO_AH", VALUE, IN_H, "IPPROTO_AH",
+		NULL, NULL, {"51"} },
+	{ "IPPROTO_ICMPV6", VALUE, IN_H, "IPPROTO_ICMPV6",
+		NULL, NULL, {"58"} },
+	{ "IPPROTO_NONE", VALUE, IN_H, "IPPROTO_NONE",
+		NULL, NULL, {"59"} },
+	{ "IPPROTO_DSTOPTS", VALUE, IN_H, "IPPROTO_DSTOPTS",
+		NULL, NULL, {"60"} },
+	/* ip6_hbh */
+	{ "ip6_hbh ip6h_nxt", EXISTS, IP6_H, "ip6_hbh",
+		"ip6h_nxt", "0", {"1"} },
+	{ "ip6_hbh ip6h_nxt", EXISTS, IP6_H, "ip6_hbh",
+		"ip6h_len", "1", {"1"} },
+	/* ip6_dest */
+	{ "ip6_dest ip6d_nxt", EXISTS, IP6_H, "ip6_dest",
+		"ip6d_nxt", "0", {"1"} },
+	{ "ip6_dest ip6d_nxt", EXISTS, IP6_H, "ip6_dest",
+		"ip6d_len", "1", {"1"} },
+	/* ip6_rthdr0 */
+	{ "ip6_rthdr0 ip6r0_nxt", EXISTS, IP6_H, "ip6_rthdr0",
+		"ip6r0_nxt", "0", {"1"} },
+	{ "ip6_rthdr0 ip6r0_len", EXISTS, IP6_H, "ip6_rthdr0",
+		"ip6r0_len", "1", {"1"} },
+	{ "ip6_rthdr0 ip6r0_type", EXISTS, IP6_H, "ip6_rthdr0",
+		"ip6r0_type", "2", {"1"} },
+	{ "ip6_rthdr0 ip6r0_segleft", EXISTS, IP6_H, "ip6_rthdr0",
+		"ip6r0_segleft", "3", {"1"} },
+	{ "ip6_rthdr0 ip6r0_reserved", EXISTS, IP6_H, "ip6_rthdr0",
+		"ip6r0_reserved", "4", {"1"} },
+	/* ip6_frag */
+	{ "ip6_frag ip6f_nxt", EXISTS, IP6_H, "ip6_frag",
+		"ip6f_nxt", "0", {"1"} },
+	{ "ip6_frag ip6f_reserved", EXISTS, IP6_H, "ip6_frag",
+		"ip6f_reserved", "1", {"1"} },
+	{ "ip6_frag ip6f_offlg", EXISTS, IP6_H, "ip6_frag",
+		"ip6f_offlg", "2", {"2"} },
+	{ "ip6_frag ip6f_ident", EXISTS, IP6_H, "ip6_frag",
+		"ip6f_ident", "4", {"4"} },
+	{ "IP6F_OFF_MASK", VALUE, IP6_H, "IP6F_OFF_MASK",
+		NULL, NULL, {"htons(0xfff8)"} },
+	{ "IP6F_RESERVED_MASK", VALUE, IP6_H, "IP6F_RESERVED_MASK",
+		NULL, NULL, {"htons(0x0006)"} },
+	{ "IP6F_MORE_FRAG", VALUE, IP6_H, "IP6F_MORE_FRAG",
+		NULL, NULL, {"htons(0x0001)"} },
+	{ "IP6OPT_TYPE", VALUE, IP6_H, "IP6OPT_TYPE(0xff)",
+		NULL, NULL, {"0xc0"} },
+	{ "IP6OPT_TYPE_SKIP", VALUE, IP6_H, "IP6OPT_TYPE_SKIP",
+		NULL, NULL, {"0x00"} },
+	{ "IP6OPT_TYPE_DISCARD", VALUE, IP6_H, "IP6OPT_TYPE_DISCARD",
+		NULL, NULL, {"0x40"} },
+	{ "IP6OPT_TYPE_FORCEICMP", VALUE, IP6_H, "IP6OPT_TYPE_FORCEICMP",
+		NULL, NULL, {"0x80"} },
+	{ "IP6OPT_TYPE_ICMP", VALUE, IP6_H, "IP6OPT_TYPE_ICMP",
+		NULL, NULL, {"0xc0"} },
+	{ "IP6OPT_TYPE_MUTABLE", VALUE, IP6_H, "IP6OPT_TYPE_MUTABLE",
+		NULL, NULL, {"0x20"} },
+	{ "IP6OPT_PAD1", VALUE, IP6_H, "IP6OPT_PAD1",
+		NULL, NULL, {"0x00"} },
+	{ "IP6OPT_PADN", VALUE, IP6_H, "IP6OPT_PADN",
+		NULL, NULL, {"0x01"} },
+	{ "IP6OPT_JUMBO", VALUE, IP6_H, "IP6OPT_JUMBO",
+		NULL, NULL, {"0xc2"} },
+	{ "IP6OPT_NSAP_ADDR", VALUE, IP6_H, "IP6OPT_NSAP_ADDR",
+		NULL, NULL, {"0xc3"} },
+	{ "IP6OPT_TUNNEL_LIMIT", VALUE, IP6_H, "IP6OPT_TUNNEL_LIMIT",
+		NULL, NULL, {"0x04"} },
+	{ "IP6OPT_ROUTER_ALERT", VALUE, IP6_H, "IP6OPT_ROUTER_ALERT",
+		NULL, NULL, {"0x05"} },
+	/* ip6_opt_jumbo */
+	{ "ip6_opt_jumbo ip6oj_type", EXISTS, IP6_H, "ip6_opt_jumbo",
+		"ip6oj_type", "0", {"1"} },
+	{ "ip6_opt_jumbo ip6oj_len", EXISTS, IP6_H, "ip6_opt_jumbo",
+		"ip6oj_len", "1", {"1"} },
+	{ "ip6_opt_jumbo ip6oj_jumbo_len element", EXISTS, IP6_H,
+		"ip6_opt_jumbo", "ip6oj_jumbo_len[0]", "2", {"1"} },
+	{ "ip6_opt_jumbo ip6oj_jumbo_len array", EXISTS, IP6_H,
+		"ip6_opt_jumbo", "ip6oj_jumbo_len", "2", {"4"} },
+	/* ip6_opt_nsap */
+	{ "ip6_opt_nsap ip6on_type", EXISTS, IP6_H, "ip6_opt_nsap",
+		"ip6on_type", "0", {"1"} },
+	{ "ip6_opt_nsap ip6on_len", EXISTS, IP6_H, "ip6_opt_nsap",
+		"ip6on_len", "1", {"1"} },
+	{ "ip6_opt_nsap ip6on_src_nsap_len", EXISTS, IP6_H,
+		"ip6_opt_nsap", "ip6on_src_nsap_len", "2", {"1"} },
+	{ "ip6_opt_nsap ip6on_dst_nsap_len", EXISTS, IP6_H,
+		"ip6_opt_nsap", "ip6on_dst_nsap_len", "3", {"1"} },
+	/* ip6_opt_tunnel */
+	{ "ip6_opt_tunnel ip6ot_type", EXISTS, IP6_H,
+		"ip6_opt_tunnel", "ip6ot_type", "0", {"1"} },
+	{ "ip6_opt_tunnel ip6ot_len", EXISTS, IP6_H,
+		"ip6_opt_tunnel", "ip6ot_len", "1", {"1"} },
+	{ "ip6_opt_tunnel ip6ot_encap_limit", EXISTS, IP6_H,
+		"ip6_opt_tunnel", "ip6ot_encap_limit", "2", {"1"} },
+	/* ip6_opt_router */
+	{ "ip6_opt_router ip6or_type", EXISTS, IP6_H,
+		"ip6_opt_router", "ip6or_type", "0", {"1"} },
+	{ "ip6_opt_router ip6or_len", EXISTS, IP6_H,
+		"ip6_opt_router", "ip6or_len", "1", {"1"} },
+	{ "ip6_opt_router ip6or_value element", EXISTS, IP6_H,
+		"ip6_opt_router", "ip6or_value[0]", "2", {"1"} },
+	{ "ip6_opt_router ip6or_value array", EXISTS, IP6_H,
+		"ip6_opt_router", "ip6or_value", "2", {"2"} },
+	/* IP6_ALERT_* definitions */
+	{ "IP6_ALERT_MLD", VALUE, IP6_H, "IP6_ALERT_MLD",
+		NULL, NULL, {"0"} },
+	{ "IP6_ALERT_RSVP", VALUE, IP6_H, "IP6_ALERT_RSVP",
+		NULL, NULL, {"htons(1)"} },
+	{ "IP6_ALERT_AN", VALUE, IP6_H, "IP6_ALERT_AN",
+		NULL, NULL, {"htons(2)"} },
+};
 
-#define FTCOUNT	(sizeof(ftab)/sizeof(ftab[0]))
+static void setup(void);
+static void cleanup(void);
+static void do_test(const struct ftent *);
 
-int TST_TOTAL = FTCOUNT;
+char *TCID = "asapi_01";
+int TST_TOTAL = ARRAY_SIZE(ftab);
 
 int main(int argc, char *argv[])
 {
 	int i, lc;
 	const char *msg;
 
-	/* Parse standard options given to run the test. */
 	msg = parse_opts(argc, argv, NULL, NULL);
-	if (msg != NULL) {
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-	}
 
 	setup();
 
 	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		for (i = 0; i < FTCOUNT; ++i) {
-			switch (ftab[i].ft_type) {
-			case EXISTS:
-				structcheck(ftab[i].ft_tname, ftab[i].ft_incl,
-					    ftab[i].ft_struct, ftab[i].ft_field,
-					    ftab[i].ft_offset,
-					    ftab[i].ft_value);
-				break;
-			case ALIAS:
-				aliascheck(ftab[i].ft_tname, ftab[i].ft_incl,
-					   ftab[i].ft_struct, ftab[i].ft_field,
-					   ftab[i].ft_dname);
-				break;
-			case VALUE:
-				valuecheck(ftab[i].ft_tname, ftab[i].ft_incl,
-					   ftab[i].ft_struct, ftab[i].ft_dname);
-				break;
-			default:
-				tst_resm(TBROK, "invalid type %d",
-					 ftab[i].ft_type);
-				break;
-			}
-		}
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; i++)
+			do_test(&ftab[i]);
 	}
 
 	cleanup();
-
 	tst_exit();
 }
 
 void setup(void)
 {
-	TEST_PAUSE;		/* if -P option specified */
+	TEST_PAUSE;
 }
 
 void cleanup(void)
 {
 	TEST_CLEANUP;
 }
+
+void do_test(const struct ftent *ftptr)
+{
+	switch (ftptr->ft_type) {
+	case EXISTS:
+		structcheck(ftptr->ft_tname, ftptr->ft_incl,
+			ftptr->ft_struct, ftptr->ft_field,
+			ftptr->ft_offset, ftptr->ft_value);
+		break;
+	case ALIAS:
+		aliascheck(ftptr->ft_tname, ftptr->ft_incl,
+			ftptr->ft_struct, ftptr->ft_field,
+			ftptr->ft_dname);
+		break;
+	case VALUE:
+		valuecheck(ftptr->ft_tname, ftptr->ft_incl,
+			ftptr->ft_struct, ftptr->ft_dname);
+		break;
+	default:
+		tst_resm(TBROK, "invalid type %d",
+			ftptr->ft_type);
+		break;
+	}
+}
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH 2/7] lib6/asapi_02.c: cleanup
  2015-01-23  9:36 [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup Xing Gu
@ 2015-01-23  9:36 ` Xing Gu
  2015-01-23  9:36 ` [LTP] [PATCH 3/7] lib6/asapi_03.c: cleanup Xing Gu
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Xing Gu @ 2015-01-23  9:36 UTC (permalink / raw)
  To: ltp-list

* Remove useless comments.

* Modify the format of ftab[].

* Move the test body from main() to do_test().

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
 testcases/network/lib6/asapi_02.c | 635 ++++++++++++++++----------------------
 1 file changed, 274 insertions(+), 361 deletions(-)

diff --git a/testcases/network/lib6/asapi_02.c b/testcases/network/lib6/asapi_02.c
index f597610..1258618 100644
--- a/testcases/network/lib6/asapi_02.c
+++ b/testcases/network/lib6/asapi_02.c
@@ -1,6 +1,7 @@
 /*
  *
  *   Copyright (c) International Business Machines  Corp., 2001
+ *   Author: David L Stevens
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -13,26 +14,13 @@
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *   along with this program;  if not, write to the Free Software Foundation,
+ *   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-
 /*
- * Test Name: asapi_02
- *
- * Test Description:
- *  These tests are for the "Advanced Sockets API" (RFC 3542)
- *  Verify that in6 and sockaddr fields are present.
- *
- * Usage:  <for command-line>
- *  asapi_02
- *
- * HISTORY
- *	01/2005 written by David L Stevens
- *
- * RESTRICTIONS:
- *  None.
- *
+ *   Description:
+ *     These tests are for the "Advanced Sockets API" (RFC 3542)
+ *     Verify that in6 and sockaddr fields are present.
  */
 
 #include <stdio.h>
@@ -47,10 +35,6 @@
 #include "usctest.h"
 #include "runcc.h"
 
-char *TCID = "asapi_02";	/* Test program identifier.    */
-
-void setup(void), cleanup(void);
-
 enum ttype { EXISTS, ALIAS, VALUE };
 
 struct ftent {
@@ -67,370 +51,299 @@ struct ftent {
 #define ft_value	ftun.fu_value
 #define ft_dname	ftun.fu_dname
 } ftab[] = {
-/* Section 2.2, icmp6_hdr & defines */
-	{
-		"icmp6_hdr icmp6_type", EXISTS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_type", "0", {
-	"1"}}, {
-		"icmp6_hdr icmp6_code", EXISTS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_code", "1", {
-	"1"}}, {
-		"icmp6_hdr icmp6_cksum", EXISTS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_cksum", "2", {
-	"2"}}, {
-		"icmp6_hdr icmp6_un_data32 element", EXISTS, ICMP6_H,
-		    "icmp6_hdr", "icmp6_dataun.icmp6_un_data32[0]", "4", {
-	"4"}}, {
-		"icmp6_hdr icmp6_un_data32 array", EXISTS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data32", "4", {
-	"4"}}, {
-		"icmp6_hdr icmp6_un_data16 element", EXISTS, ICMP6_H,
-		    "icmp6_hdr", "icmp6_dataun.icmp6_un_data16[0]", "4", {
-	"2"}}, {
-		"icmp6_hdr icmp6_un_data16 array", EXISTS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data16", "4", {
-	"4"}}, {
-		"icmp6_hdr icmp6_un_data8 element", EXISTS, ICMP6_H,
-		    "icmp6_hdr", "icmp6_dataun.icmp6_un_data8[0]", "4", {
-	"1"}}, {
-		"icmp6_hdr icmp6_un_data8 array", EXISTS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data8", "4", {
-	"4"}},
-/* icmp6_hdr definitions */
-	{
-		"icmp6_hdr icmp6_data32 define", ALIAS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data32", NULL, {
-	"icmp6_data32"}}, {
-		"icmp6_hdr icmp6_data16 define", ALIAS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data16", NULL, {
-	"icmp6_data16"}}, {
-		"icmp6_hdr icmp6_data8 define", ALIAS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data8", NULL, {
-	"icmp6_data8"}}, {
-		"icmp6_hdr icmp6_pptr define", ALIAS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data32[0]", NULL, {
-	"icmp6_pptr"}}, {
-		"icmp6_hdr icmp6_mtu define", ALIAS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data32[0]", NULL, {
-	"icmp6_mtu"}}, {
-		"icmp6_hdr icmp6_id define", ALIAS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data16[0]", NULL, {
-	"icmp6_id"}}, {
-		"icmp6_hdr icmp6_seq define", ALIAS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data16[1]", NULL, {
-	"icmp6_seq"}}, {
-		"icmp6_hdr icmp6_maxdelay define", ALIAS, ICMP6_H, "icmp6_hdr",
-		    "icmp6_dataun.icmp6_un_data16[0]", NULL, {
-	"icmp6_maxdelay"}},
-/* Section 2.2.1 ICMPv6 Type and Code Values */
-	{
-		"ICMP6_DST_UNREACH", VALUE, ICMP6_H, "ICMP6_DST_UNREACH",
-		    NULL, NULL, {
-	"1"}}, {
-		"ICMP6_PACKET_TOO_BIG", VALUE, ICMP6_H, "ICMP6_PACKET_TOO_BIG",
-		    NULL, NULL, {
-	"2"}}, {
-		"ICMP6_TIME_EXCEEDED", VALUE, ICMP6_H, "ICMP6_TIME_EXCEEDED",
-		    NULL, NULL, {
-	"3"}}, {
-		"ICMP6_PARAM_PROB", VALUE, ICMP6_H, "ICMP6_PARAM_PROB",
-		    NULL, NULL, {
-	"4"}}, {
-		"ICMP6_INFOMSG_MASK", VALUE, ICMP6_H, "ICMP6_INFOMSG_MASK",
-		    NULL, NULL, {
-	"0x80"}}, {
-		"ICMP6_ECHO_REQUEST", VALUE, ICMP6_H, "ICMP6_ECHO_REQUEST",
-		    NULL, NULL, {
-	"128"}}, {
-		"ICMP6_ECHO_REPLY", VALUE, ICMP6_H, "ICMP6_ECHO_REPLY",
-		    NULL, NULL, {
-	"129"}}, {
-		"ICMP6_DST_UNREACH_NOROUTE", VALUE, ICMP6_H,
-		    "ICMP6_DST_UNREACH_NOROUTE", NULL, NULL, {
-	"0"}}, {
-		"ICMP6_DST_UNREACH_ADMIN", VALUE, ICMP6_H,
-		    "ICMP6_DST_UNREACH_ADMIN", NULL, NULL, {
-	"1"}}, {
-		"ICMP6_DST_UNREACH_BEYONDSCOPE", VALUE, ICMP6_H,
-		    "ICMP6_DST_UNREACH_BEYONDSCOPE", NULL, NULL, {
-	"2"}}, {
-		"ICMP6_DST_UNREACH_ADDR", VALUE, ICMP6_H,
-		    "ICMP6_DST_UNREACH_ADDR", NULL, NULL, {
-	"3"}}, {
-		"ICMP6_DST_UNREACH_NOPORT", VALUE, ICMP6_H,
-		    "ICMP6_DST_UNREACH_NOPORT", NULL, NULL, {
-	"4"}}, {
-		"ICMP6_TIME_EXCEED_TRANSIT", VALUE, ICMP6_H,
-		    "ICMP6_TIME_EXCEED_TRANSIT", NULL, NULL, {
-	"0"}}, {
-		"ICMP6_TIME_EXCEED_REASSEMBLY", VALUE, ICMP6_H,
-		    "ICMP6_TIME_EXCEED_REASSEMBLY", NULL, NULL, {
-	"1"}}, {
-		"ICMP6_PARAMPROB_HEADER", VALUE, ICMP6_H,
-		    "ICMP6_PARAMPROB_HEADER", NULL, NULL, {
-	"0"}}, {
-		"ICMP6_PARAMPROB_NEXTHEADER", VALUE, ICMP6_H,
-		    "ICMP6_PARAMPROB_NEXTHEADER", NULL, NULL, {
-	"1"}}, {
-		"ICMP6_PARAMPROB_OPTION", VALUE, ICMP6_H,
-		    "ICMP6_PARAMPROB_OPTION", NULL, NULL, {
-	"2"}},
-/* section 2.2.2, Neighbor Discovery */
-	{
-		"ND_ROUTER_SOLICIT", VALUE, ICMP6_H, "ND_ROUTER_SOLICIT",
-		    NULL, NULL, {
-	"133"}}, {
-		"ND_ROUTER_ADVERT", VALUE, ICMP6_H, "ND_ROUTER_ADVERT",
-		    NULL, NULL, {
-	"134"}}, {
-		"ND_NEIGHBOR_SOLICIT", VALUE, ICMP6_H, "ND_NEIGHBOR_SOLICIT",
-		    NULL, NULL, {
-	"135"}}, {
-		"ND_NEIGHBOR_ADVERT", VALUE, ICMP6_H, "ND_NEIGHBOR_ADVERT",
-		    NULL, NULL, {
-	"136"}}, {
-		"ND_REDIRECT", VALUE, ICMP6_H, "ND_REDIRECT", NULL, NULL, {
-	"137"}}, {
-		"nd_router_solicit nd_rs_hdr", EXISTS, ICMP6_H,
-		    "nd_router_solicit", "nd_rs_hdr", "0", {
-	"sizeof(struct icmp6_hdr)"}}, {
-		"nd_router_solicit nd_rs_type define", ALIAS, ICMP6_H,
-		    "nd_router_solicit", "nd_rs_hdr.icmp6_type", NULL, {
-	"nd_rs_type"}}, {
-		"nd_router_solicit nd_rs_code define", ALIAS, ICMP6_H,
-		    "nd_router_solicit", "nd_rs_hdr.icmp6_code", NULL, {
-	"nd_rs_code"}}, {
-		"nd_router_solicit nd_rs_cksum define", ALIAS, ICMP6_H,
-		    "nd_router_solicit", "nd_rs_hdr.icmp6_cksum", NULL, {
-	"nd_rs_cksum"}}, {
-		"nd_router_solicit nd_rs_reserved define", ALIAS, ICMP6_H,
-		    "nd_router_solicit", "nd_rs_hdr.icmp6_data32[0]", NULL, {
-	"nd_rs_reserved"}}, {
-		"nd_router_advert nd_ra_hdr", EXISTS, ICMP6_H,
-		    "nd_router_advert", "nd_ra_hdr", "0", {
-	"sizeof(struct icmp6_hdr)"}}, {
-		"nd_router_advert nd_ra_reachable", EXISTS, ICMP6_H,
-		    "nd_router_advert", "nd_ra_reachable",
-		    "sizeof(struct icmp6_hdr)", {
-	"4"}}, {
-		"nd_router_advert nd_ra_retransmit", EXISTS, ICMP6_H,
-		    "nd_router_advert", "nd_ra_retransmit",
-		    "sizeof(struct icmp6_hdr)+4", {
-	"4"}}, {
-		"nd_router_advert nd_ra_type define", ALIAS, ICMP6_H,
-		    "nd_router_advert", "nd_ra_hdr.icmp6_type", NULL, {
-	"nd_ra_type"}}, {
-		"nd_router_advert nd_ra_code define", ALIAS, ICMP6_H,
-		    "nd_router_advert", "nd_ra_hdr.icmp6_code", NULL, {
-	"nd_ra_code"}}, {
-		"nd_router_advert nd_ra_cksum define", ALIAS, ICMP6_H,
-		    "nd_router_advert", "nd_ra_hdr.icmp6_cksum", NULL, {
-	"nd_ra_cksum"}}, {
-		"nd_router_advert nd_ra_curhoplimit define", ALIAS, ICMP6_H,
-		    "nd_router_advert", "nd_ra_hdr.icmp6_data8[0]", NULL, {
-	"nd_ra_curhoplimit"}}, {
-		"nd_router_advert nd_ra_flags_reserved define", ALIAS, ICMP6_H,
-		    "nd_router_advert", "nd_ra_hdr.icmp6_data8[1]", NULL, {
-	"nd_ra_flags_reserved"}}, {
-		"ND_RA_FLAG_MANAGED", VALUE, ICMP6_H, "ND_RA_FLAG_MANAGED",
-		    NULL, NULL, {
-	"0x80"}}, {
-		"ND_RA_FLAG_OTHER", VALUE, ICMP6_H, "ND_RA_FLAG_OTHER",
-		    NULL, NULL, {
-	"0x40"}}, {
-		"nd_router_advert nd_ra_router_lifetime define", ALIAS, ICMP6_H,
-		    "nd_router_advert", "nd_ra_hdr.icmp6_data16[1]", NULL, {
-	"nd_ra_router_lifetime"}}, {
-		"nd_neighbor_solicit nd_ns_hdr", EXISTS, ICMP6_H,
-		    "nd_neighbor_solicit", "nd_ns_hdr", "0", {
-	"sizeof(struct icmp6_hdr)"}}, {
-		"nd_neighbor_solicit nd_ns_target", EXISTS, ICMP6_H,
-		    "nd_neighbor_solicit", "nd_ns_target",
-		    "sizeof(struct icmp6_hdr)", {
-	"sizeof(struct in6_addr)"}}, {
-		"nd_neighbor_solicit nd_ns_type define", ALIAS, ICMP6_H,
-		    "nd_neighbor_solicit", "nd_ns_hdr.icmp6_type", NULL, {
-	"nd_ns_type"}}, {
-		"nd_neighbor_solicit nd_ns_code define", ALIAS, ICMP6_H,
-		    "nd_neighbor_solicit", "nd_ns_hdr.icmp6_code", NULL, {
-	"nd_ns_code"}}, {
-		"nd_neighbor_solicit nd_ns_cksum define", ALIAS, ICMP6_H,
-		    "nd_neighbor_solicit", "nd_ns_hdr.icmp6_cksum", NULL, {
-	"nd_ns_cksum"}}, {
-		"nd_neighbor_solicit nd_ns_reserved define", ALIAS, ICMP6_H,
-		    "nd_neighbor_solicit", "nd_ns_hdr.icmp6_data32[0]", NULL, {
-	"nd_ns_reserved"}}, {
-		"nd_neighbor_advert nd_na_hdr", EXISTS, ICMP6_H,
-		    "nd_neighbor_advert", "nd_na_hdr", "0", {
-	"sizeof(struct icmp6_hdr)"}}, {
-		"nd_neighbor_advert nd_na_target", EXISTS, ICMP6_H,
-		    "nd_neighbor_advert", "nd_na_target",
-		    "sizeof(struct icmp6_hdr)", {
-	"sizeof(struct in6_addr)"}}, {
-		"nd_neighbor_advert nd_na_type define", ALIAS, ICMP6_H,
-		    "nd_neighbor_advert", "nd_na_hdr.icmp6_type", NULL, {
-	"nd_na_type"}}, {
-		"nd_neighbor_advert nd_na_code define", ALIAS, ICMP6_H,
-		    "nd_neighbor_advert", "nd_na_hdr.icmp6_code", NULL, {
-	"nd_na_code"}}, {
-		"nd_neighbor_advert nd_na_cksum define", ALIAS, ICMP6_H,
-		    "nd_neighbor_advert", "nd_na_hdr.icmp6_cksum", NULL, {
-	"nd_na_cksum"}}, {
-		"nd_neighbor_advert nd_na_flags_reserved define", ALIAS,
-		    ICMP6_H, "nd_neighbor_advert", "nd_na_hdr.icmp6_data32[0]",
-		    NULL, {
-	"nd_na_flags_reserved"}}, {
-		"ND_NA_FLAG_ROUTER", VALUE, ICMP6_H, "ND_NA_FLAG_ROUTER",
-		    NULL, NULL, {
-	"htonl(0x80000000)"}}, {
-		"ND_NA_FLAG_SOLICITED", VALUE, ICMP6_H, "ND_NA_FLAG_SOLICITED",
-		    NULL, NULL, {
-	"htonl(0x40000000)"}}, {
-		"ND_NA_FLAG_OVERRIDE", VALUE, ICMP6_H, "ND_NA_FLAG_OVERRIDE",
-		    NULL, NULL, {
-	"htonl(0x20000000)"}}, {
-		"nd_redirect nd_rd_hdr", EXISTS, ICMP6_H, "nd_redirect",
-		    "nd_rd_hdr", "0", {
-	"sizeof(struct icmp6_hdr)"}}, {
-		"nd_redirect nd_rd_target", EXISTS, ICMP6_H,
-		    "nd_redirect", "nd_rd_target", "sizeof(struct icmp6_hdr)", {
-	"sizeof(struct in6_addr)"}}, {
-		"nd_redirect nd_rd_dst", EXISTS, ICMP6_H, "nd_redirect",
-		    "nd_rd_dst",
-		    "sizeof(struct icmp6_hdr)+sizeof(struct in6_addr)", {
-	"sizeof(struct in6_addr)"}}, {
-		"nd_redirect nd_rd_type define", ALIAS, ICMP6_H,
-		    "nd_neighbor_advert", "nd_na_hdr.icmp6_data32[0]", NULL, {
-	"nd_na_flags_reserved"}}, {
-		"nd_opt_hdr nd_rd_hdr", EXISTS, ICMP6_H, "nd_opt_hdr",
-		    "nd_opt_type", "0", {
-	"1"}}, {
-		"nd_opt_hdr nd_rd_hdr", EXISTS, ICMP6_H, "nd_opt_hdr",
-		    "nd_opt_len", "1", {
-	"1"}}, {
-		"ND_OPT_SOURCE_LINKADDR", VALUE, ICMP6_H,
-		    "ND_OPT_SOURCE_LINKADDR", NULL, NULL, {
-	"1"}}, {
-		"ND_OPT_TARGET_LINKADDR", VALUE, ICMP6_H,
-		    "ND_OPT_TARGET_LINKADDR", NULL, NULL, {
-	"2"}}, {
-		"ND_OPT_PREFIX_INFORMATION", VALUE, ICMP6_H,
-		    "ND_OPT_PREFIX_INFORMATION", NULL, NULL, {
-	"3"}}, {
-		"ND_OPT_REDIRECTED_HEADER", VALUE, ICMP6_H,
-		    "ND_OPT_REDIRECTED_HEADER", NULL, NULL, {
-	"4"}}, {
-		"ND_OPT_MTU", VALUE, ICMP6_H, "ND_OPT_MTU", NULL, NULL, {
-	"5"}}, {
-		"nd_opt_prefix_info nd_opt_pi_type", EXISTS, ICMP6_H,
-		    "nd_opt_prefix_info", "nd_opt_pi_type", "0", {
-	"1"}}, {
-		"nd_opt_prefix_info nd_opt_pi_len", EXISTS, ICMP6_H,
-		    "nd_opt_prefix_info", "nd_opt_pi_len", "1", {
-	"1"}}, {
-		"nd_opt_prefix_info nd_opt_pi_prefix_len", EXISTS, ICMP6_H,
-		    "nd_opt_prefix_info", "nd_opt_pi_prefix_len", "2", {
-	"1"}}, {
-		"nd_opt_prefix_info nd_opt_pi_flags_reserved", EXISTS, ICMP6_H,
-		    "nd_opt_prefix_info", "nd_opt_pi_flags_reserved", "3", {
-	"1"}}, {
-		"nd_opt_prefix_info nd_opt_pi_valid_time", EXISTS, ICMP6_H,
-		    "nd_opt_prefix_info", "nd_opt_pi_valid_time", "4", {
-	"4"}}, {
-		"nd_opt_prefix_info nd_opt_pi_preferred_time", EXISTS, ICMP6_H,
-		    "nd_opt_prefix_info", "nd_opt_pi_preferred_time", "8", {
-	"4"}}, {
-		"nd_opt_prefix_info nd_opt_pi_reserved2", EXISTS, ICMP6_H,
-		    "nd_opt_prefix_info", "nd_opt_pi_reserved2", "12", {
-	"4"}}, {
-		"nd_opt_prefix_info nd_opt_pi_prefix", EXISTS, ICMP6_H,
-		    "nd_opt_prefix_info", "nd_opt_pi_prefix", "16", {
-	"sizeof(struct in6_addr)"}}, {
-		"ND_OPT_PI_FLAG_ONLINK", VALUE, ICMP6_H,
-		    "ND_OPT_PI_FLAG_ONLINK", NULL, NULL, {
-	"0x80"}}, {
-		"ND_OPT_PI_FLAG_AUTO", VALUE, ICMP6_H, "ND_OPT_PI_FLAG_AUTO",
-		    NULL, NULL, {
-	"0x40"}}, {
-		"nd_opt_rd_hdr nd_opt_rh_type", EXISTS, ICMP6_H,
-		    "nd_opt_rd_hdr", "nd_opt_rh_type", "0", {
-	"1"}}, {
-		"nd_opt_rd_hdr nd_opt_rh_len", EXISTS, ICMP6_H, "nd_opt_rd_hdr",
-		    "nd_opt_rh_len", "1", {
-	"1"}}, {
-		"nd_opt_rd_hdr nd_opt_rh_reserved1", EXISTS, ICMP6_H,
-		    "nd_opt_rd_hdr", "nd_opt_rh_reserved1", "2", {
-	"2"}}, {
-		"nd_opt_rd_hdr nd_opt_rh_reserved2", EXISTS, ICMP6_H,
-		    "nd_opt_rd_hdr", "nd_opt_rh_reserved2", "4", {
-	"4"}}, {
-		"nd_opt_mtu nd_opt_mtu_type", EXISTS, ICMP6_H, "nd_opt_mtu",
-		    "nd_opt_mtu_type", "0", {
-	"1"}}, {
-		"nd_opt_mtu nd_opt_mtu_len", EXISTS, ICMP6_H, "nd_opt_mtu",
-		    "nd_opt_mtu_len", "1", {
-	"1"}}, {
-		"nd_opt_mtu nd_opt_mtu_reserved", EXISTS, ICMP6_H, "nd_opt_mtu",
-		    "nd_opt_mtu_reserved", "2", {
-	"2"}}, {
-		"nd_opt_mtu nd_opt_mtu_mtu", EXISTS, ICMP6_H, "nd_opt_mtu",
-		    "nd_opt_mtu_mtu", "4", {
-"4"}},};
+	/* Section 2.2, icmp6_hdr & defines */
+	{ "icmp6_hdr icmp6_type", EXISTS, ICMP6_H, "icmp6_hdr",
+		"icmp6_type", "0", {"1"} },
+	{ "icmp6_hdr icmp6_code", EXISTS, ICMP6_H, "icmp6_hdr",
+		"icmp6_code", "1", {"1"} },
+	{ "icmp6_hdr icmp6_cksum", EXISTS, ICMP6_H, "icmp6_hdr",
+		"icmp6_cksum", "2", {"2"} },
+	{ "icmp6_hdr icmp6_un_data32 element", EXISTS, ICMP6_H,
+		"icmp6_hdr", "icmp6_dataun.icmp6_un_data32[0]", "4", {"4"} },
+	{ "icmp6_hdr icmp6_un_data32 array", EXISTS, ICMP6_H,
+		"icmp6_hdr", "icmp6_dataun.icmp6_un_data32", "4", {"4"} },
+	{ "icmp6_hdr icmp6_un_data16 element", EXISTS, ICMP6_H,
+		"icmp6_hdr", "icmp6_dataun.icmp6_un_data16[0]", "4", {"2"} },
+	{ "icmp6_hdr icmp6_un_data16 array", EXISTS, ICMP6_H,
+		"icmp6_hdr", "icmp6_dataun.icmp6_un_data16", "4", {"4"} },
+	{ "icmp6_hdr icmp6_un_data8 element", EXISTS, ICMP6_H,
+		"icmp6_hdr", "icmp6_dataun.icmp6_un_data8[0]", "4", {"1"} },
+	{ "icmp6_hdr icmp6_un_data8 array", EXISTS, ICMP6_H,
+		"icmp6_hdr", "icmp6_dataun.icmp6_un_data8", "4", {"4"} },
+	/* icmp6_hdr definitions */
+	{ "icmp6_hdr icmp6_data32 define", ALIAS, ICMP6_H, "icmp6_hdr",
+		"icmp6_dataun.icmp6_un_data32", NULL, {"icmp6_data32"} },
+	{ "icmp6_hdr icmp6_data16 define", ALIAS, ICMP6_H, "icmp6_hdr",
+		"icmp6_dataun.icmp6_un_data16", NULL, {"icmp6_data16"} },
+	{ "icmp6_hdr icmp6_data8 define", ALIAS, ICMP6_H, "icmp6_hdr",
+		"icmp6_dataun.icmp6_un_data8", NULL, {"icmp6_data8"} },
+	{ "icmp6_hdr icmp6_pptr define", ALIAS, ICMP6_H, "icmp6_hdr",
+		"icmp6_dataun.icmp6_un_data32[0]", NULL, {"icmp6_pptr"} },
+	{ "icmp6_hdr icmp6_mtu define", ALIAS, ICMP6_H, "icmp6_hdr",
+		"icmp6_dataun.icmp6_un_data32[0]", NULL, {"icmp6_mtu"} },
+	{ "icmp6_hdr icmp6_id define", ALIAS, ICMP6_H, "icmp6_hdr",
+		"icmp6_dataun.icmp6_un_data16[0]", NULL, {"icmp6_id"} },
+	{ "icmp6_hdr icmp6_seq define", ALIAS, ICMP6_H, "icmp6_hdr",
+		"icmp6_dataun.icmp6_un_data16[1]", NULL, {"icmp6_seq"} },
+	{ "icmp6_hdr icmp6_maxdelay define", ALIAS, ICMP6_H, "icmp6_hdr",
+		"icmp6_dataun.icmp6_un_data16[0]", NULL, {"icmp6_maxdelay"} },
+	/* Section 2.2.1 ICMPv6 Type and Code Values */
+	{ "ICMP6_DST_UNREACH", VALUE, ICMP6_H, "ICMP6_DST_UNREACH",
+		NULL, NULL, {"1"} },
+	{ "ICMP6_PACKET_TOO_BIG", VALUE, ICMP6_H, "ICMP6_PACKET_TOO_BIG",
+		NULL, NULL, {"2"} },
+	{ "ICMP6_TIME_EXCEEDED", VALUE, ICMP6_H, "ICMP6_TIME_EXCEEDED",
+		NULL, NULL, {"3"} },
+	{ "ICMP6_PARAM_PROB", VALUE, ICMP6_H, "ICMP6_PARAM_PROB",
+		NULL, NULL, {"4"} },
+	{ "ICMP6_INFOMSG_MASK", VALUE, ICMP6_H, "ICMP6_INFOMSG_MASK",
+		NULL, NULL, {"0x80"} },
+	{ "ICMP6_ECHO_REQUEST", VALUE, ICMP6_H, "ICMP6_ECHO_REQUEST",
+		NULL, NULL, {"128"} },
+	{ "ICMP6_ECHO_REPLY", VALUE, ICMP6_H, "ICMP6_ECHO_REPLY",
+		NULL, NULL, {"129"} },
+	{ "ICMP6_DST_UNREACH_NOROUTE", VALUE, ICMP6_H,
+		"ICMP6_DST_UNREACH_NOROUTE", NULL, NULL, {"0"} },
+	{ "ICMP6_DST_UNREACH_ADMIN", VALUE, ICMP6_H,
+		"ICMP6_DST_UNREACH_ADMIN", NULL, NULL, {"1"} },
+	{ "ICMP6_DST_UNREACH_BEYONDSCOPE", VALUE, ICMP6_H,
+		"ICMP6_DST_UNREACH_BEYONDSCOPE", NULL, NULL, {"2"} },
+	{ "ICMP6_DST_UNREACH_ADDR", VALUE, ICMP6_H,
+		"ICMP6_DST_UNREACH_ADDR", NULL, NULL, {"3"} },
+	{ "ICMP6_DST_UNREACH_NOPORT", VALUE, ICMP6_H,
+		"ICMP6_DST_UNREACH_NOPORT", NULL, NULL, {"4"} },
+	{ "ICMP6_TIME_EXCEED_TRANSIT", VALUE, ICMP6_H,
+		"ICMP6_TIME_EXCEED_TRANSIT", NULL, NULL, {"0"} },
+	{ "ICMP6_TIME_EXCEED_REASSEMBLY", VALUE, ICMP6_H,
+		"ICMP6_TIME_EXCEED_REASSEMBLY", NULL, NULL, {"1"} },
+	{ "ICMP6_PARAMPROB_HEADER", VALUE, ICMP6_H,
+		"ICMP6_PARAMPROB_HEADER", NULL, NULL, {"0"} },
+	{ "ICMP6_PARAMPROB_NEXTHEADER", VALUE, ICMP6_H,
+		"ICMP6_PARAMPROB_NEXTHEADER", NULL, NULL, {"1"} },
+	{ "ICMP6_PARAMPROB_OPTION", VALUE, ICMP6_H,
+		"ICMP6_PARAMPROB_OPTION", NULL, NULL, {"2"} },
+	/* section 2.2.2, Neighbor Discovery */
+	{ "ND_ROUTER_SOLICIT", VALUE, ICMP6_H,
+		"ND_ROUTER_SOLICIT", NULL, NULL, {"133"} },
+	{ "ND_ROUTER_ADVERT", VALUE, ICMP6_H,
+		"ND_ROUTER_ADVERT", NULL, NULL, {"134"} },
+	{ "ND_NEIGHBOR_SOLICIT", VALUE, ICMP6_H,
+		"ND_NEIGHBOR_SOLICIT", NULL, NULL, {"135"} },
+	{ "ND_NEIGHBOR_ADVERT", VALUE, ICMP6_H,
+		"ND_NEIGHBOR_ADVERT", NULL, NULL, {"136"} },
+	{ "ND_REDIRECT", VALUE, ICMP6_H,
+		"ND_REDIRECT", NULL, NULL, {"137"} },
+	{ "nd_router_solicit nd_rs_hdr", EXISTS, ICMP6_H,
+		"nd_router_solicit", "nd_rs_hdr", "0",
+		{"sizeof(struct icmp6_hdr)"} },
+	{ "nd_router_solicit nd_rs_type define", ALIAS, ICMP6_H,
+		"nd_router_solicit", "nd_rs_hdr.icmp6_type",
+		NULL, {"nd_rs_type"} },
+	{ "nd_router_solicit nd_rs_code define", ALIAS, ICMP6_H,
+		"nd_router_solicit", "nd_rs_hdr.icmp6_code",
+		NULL, {"nd_rs_code"} },
+	{ "nd_router_solicit nd_rs_cksum define", ALIAS, ICMP6_H,
+		"nd_router_solicit", "nd_rs_hdr.icmp6_cksum",
+		NULL, {"nd_rs_cksum"} },
+	{ "nd_router_solicit nd_rs_reserved define", ALIAS, ICMP6_H,
+		"nd_router_solicit", "nd_rs_hdr.icmp6_data32[0]",
+		NULL, {"nd_rs_reserved"} },
+	{ "nd_router_advert nd_ra_hdr", EXISTS, ICMP6_H,
+		"nd_router_advert", "nd_ra_hdr", "0",
+		{"sizeof(struct icmp6_hdr)"} },
+	{ "nd_router_advert nd_ra_reachable", EXISTS, ICMP6_H,
+		"nd_router_advert", "nd_ra_reachable",
+		"sizeof(struct icmp6_hdr)", {"4"} },
+	{ "nd_router_advert nd_ra_retransmit", EXISTS, ICMP6_H,
+		"nd_router_advert", "nd_ra_retransmit",
+		"sizeof(struct icmp6_hdr)+4", {"4"} },
+	{ "nd_router_advert nd_ra_type define", ALIAS, ICMP6_H,
+		"nd_router_advert", "nd_ra_hdr.icmp6_type",
+		NULL, {"nd_ra_type"} },
+	{ "nd_router_advert nd_ra_code define", ALIAS, ICMP6_H,
+		"nd_router_advert", "nd_ra_hdr.icmp6_code",
+		NULL, {"nd_ra_code"} },
+	{ "nd_router_advert nd_ra_cksum define", ALIAS, ICMP6_H,
+		"nd_router_advert", "nd_ra_hdr.icmp6_cksum",
+		NULL, {"nd_ra_cksum"} },
+	{ "nd_router_advert nd_ra_curhoplimit define", ALIAS, ICMP6_H,
+		"nd_router_advert", "nd_ra_hdr.icmp6_data8[0]",
+		NULL, {"nd_ra_curhoplimit"} },
+	{ "nd_router_advert nd_ra_flags_reserved define", ALIAS, ICMP6_H,
+		"nd_router_advert", "nd_ra_hdr.icmp6_data8[1]",
+		NULL, {"nd_ra_flags_reserved"} },
+	{ "ND_RA_FLAG_MANAGED", VALUE, ICMP6_H,
+		"ND_RA_FLAG_MANAGED", NULL, NULL, {"0x80"} },
+	{ "ND_RA_FLAG_OTHER", VALUE, ICMP6_H,
+		"ND_RA_FLAG_OTHER", NULL, NULL, {"0x40"} },
+	{ "nd_router_advert nd_ra_router_lifetime define", ALIAS, ICMP6_H,
+		"nd_router_advert", "nd_ra_hdr.icmp6_data16[1]",
+		NULL, {"nd_ra_router_lifetime"} },
+	{ "nd_neighbor_solicit nd_ns_hdr", EXISTS, ICMP6_H,
+		"nd_neighbor_solicit", "nd_ns_hdr",
+		"0", {"sizeof(struct icmp6_hdr)"} },
+	{ "nd_neighbor_solicit nd_ns_target", EXISTS, ICMP6_H,
+		"nd_neighbor_solicit", "nd_ns_target",
+		"sizeof(struct icmp6_hdr)", {"sizeof(struct in6_addr)"} },
+	{ "nd_neighbor_solicit nd_ns_type define", ALIAS, ICMP6_H,
+		"nd_neighbor_solicit", "nd_ns_hdr.icmp6_type",
+		NULL, {"nd_ns_type"} },
+	{ "nd_neighbor_solicit nd_ns_code define", ALIAS, ICMP6_H,
+		"nd_neighbor_solicit", "nd_ns_hdr.icmp6_code",
+		NULL, {"nd_ns_code"} },
+	{ "nd_neighbor_solicit nd_ns_cksum define", ALIAS, ICMP6_H,
+		"nd_neighbor_solicit", "nd_ns_hdr.icmp6_cksum",
+		NULL, {"nd_ns_cksum"} },
+	{ "nd_neighbor_solicit nd_ns_reserved define", ALIAS, ICMP6_H,
+		"nd_neighbor_solicit", "nd_ns_hdr.icmp6_data32[0]",
+		NULL, {"nd_ns_reserved"} },
+	{ "nd_neighbor_advert nd_na_hdr", EXISTS, ICMP6_H,
+		"nd_neighbor_advert", "nd_na_hdr",
+		"0", {"sizeof(struct icmp6_hdr)"} },
+	{ "nd_neighbor_advert nd_na_target", EXISTS, ICMP6_H,
+		"nd_neighbor_advert", "nd_na_target",
+		"sizeof(struct icmp6_hdr)", {"sizeof(struct in6_addr)"} },
+	{ "nd_neighbor_advert nd_na_type define", ALIAS, ICMP6_H,
+		"nd_neighbor_advert", "nd_na_hdr.icmp6_type",
+		NULL, {"nd_na_type"} },
+	{ "nd_neighbor_advert nd_na_code define", ALIAS, ICMP6_H,
+		"nd_neighbor_advert", "nd_na_hdr.icmp6_code",
+		NULL, {"nd_na_code"} },
+	{ "nd_neighbor_advert nd_na_cksum define", ALIAS, ICMP6_H,
+		"nd_neighbor_advert", "nd_na_hdr.icmp6_cksum",
+		NULL, {"nd_na_cksum"} },
+	{ "nd_neighbor_advert nd_na_flags_reserved define", ALIAS,
+		ICMP6_H, "nd_neighbor_advert", "nd_na_hdr.icmp6_data32[0]",
+		NULL, {"nd_na_flags_reserved"}	},
+	{ "ND_NA_FLAG_ROUTER", VALUE, ICMP6_H, "ND_NA_FLAG_ROUTER",
+		NULL, NULL, {"htonl(0x80000000)"} },
+	{ "ND_NA_FLAG_SOLICITED", VALUE, ICMP6_H, "ND_NA_FLAG_SOLICITED",
+		NULL, NULL, {"htonl(0x40000000)"} },
+	{ "ND_NA_FLAG_OVERRIDE", VALUE, ICMP6_H, "ND_NA_FLAG_OVERRIDE",
+		NULL, NULL, {"htonl(0x20000000)"} },
+	{ "nd_redirect nd_rd_hdr", EXISTS, ICMP6_H, "nd_redirect",
+		"nd_rd_hdr", "0", {"sizeof(struct icmp6_hdr)"} },
+	{ "nd_redirect nd_rd_target", EXISTS, ICMP6_H,
+		"nd_redirect", "nd_rd_target",
+		"sizeof(struct icmp6_hdr)", {"sizeof(struct in6_addr)"} },
+	{ "nd_redirect nd_rd_dst", EXISTS, ICMP6_H, "nd_redirect",
+		"nd_rd_dst", "sizeof(struct icmp6_hdr)+sizeof(struct in6_addr)",
+		{"sizeof(struct in6_addr)"} },
+	{ "nd_redirect nd_rd_type define", ALIAS, ICMP6_H,
+		"nd_neighbor_advert", "nd_na_hdr.icmp6_data32[0]",
+		NULL, {"nd_na_flags_reserved"} },
+	{ "nd_opt_hdr nd_rd_hdr", EXISTS, ICMP6_H, "nd_opt_hdr",
+		"nd_opt_type", "0", {"1"} },
+	{ "nd_opt_hdr nd_rd_hdr", EXISTS, ICMP6_H, "nd_opt_hdr",
+		"nd_opt_len", "1", {"1"} },
+	{ "ND_OPT_SOURCE_LINKADDR", VALUE, ICMP6_H,
+		"ND_OPT_SOURCE_LINKADDR", NULL, NULL, {"1"} },
+	{ "ND_OPT_TARGET_LINKADDR", VALUE, ICMP6_H,
+		"ND_OPT_TARGET_LINKADDR", NULL, NULL, {"2"} },
+	{ "ND_OPT_PREFIX_INFORMATION", VALUE, ICMP6_H,
+		"ND_OPT_PREFIX_INFORMATION", NULL, NULL, {"3"} },
+	{ "ND_OPT_REDIRECTED_HEADER", VALUE, ICMP6_H,
+		"ND_OPT_REDIRECTED_HEADER", NULL, NULL, {"4"} },
+	{ "ND_OPT_MTU", VALUE, ICMP6_H, "ND_OPT_MTU",
+		NULL, NULL, {"5"} },
+	{ "nd_opt_prefix_info nd_opt_pi_type", EXISTS, ICMP6_H,
+		"nd_opt_prefix_info", "nd_opt_pi_type", "0", {"1"} },
+	{ "nd_opt_prefix_info nd_opt_pi_len", EXISTS, ICMP6_H,
+		"nd_opt_prefix_info", "nd_opt_pi_len", "1", {"1"} },
+	{ "nd_opt_prefix_info nd_opt_pi_prefix_len", EXISTS, ICMP6_H,
+		"nd_opt_prefix_info", "nd_opt_pi_prefix_len", "2", {"1"} },
+	{ "nd_opt_prefix_info nd_opt_pi_flags_reserved", EXISTS, ICMP6_H,
+		"nd_opt_prefix_info", "nd_opt_pi_flags_reserved", "3", {"1"} },
+	{ "nd_opt_prefix_info nd_opt_pi_valid_time", EXISTS, ICMP6_H,
+		"nd_opt_prefix_info", "nd_opt_pi_valid_time", "4", {"4"} },
+	{ "nd_opt_prefix_info nd_opt_pi_preferred_time", EXISTS, ICMP6_H,
+		"nd_opt_prefix_info", "nd_opt_pi_preferred_time", "8", {"4"} },
+	{ "nd_opt_prefix_info nd_opt_pi_reserved2", EXISTS, ICMP6_H,
+		"nd_opt_prefix_info", "nd_opt_pi_reserved2", "12", {"4"} },
+	{ "nd_opt_prefix_info nd_opt_pi_prefix", EXISTS, ICMP6_H,
+		"nd_opt_prefix_info", "nd_opt_pi_prefix",
+		"16", {"sizeof(struct in6_addr)"} },
+	{ "ND_OPT_PI_FLAG_ONLINK", VALUE, ICMP6_H,
+		"ND_OPT_PI_FLAG_ONLINK", NULL, NULL, {"0x80"} },
+	{ "ND_OPT_PI_FLAG_AUTO", VALUE, ICMP6_H,
+		"ND_OPT_PI_FLAG_AUTO", NULL, NULL, {"0x40"} },
+	{ "nd_opt_rd_hdr nd_opt_rh_type", EXISTS, ICMP6_H,
+		"nd_opt_rd_hdr", "nd_opt_rh_type", "0", {"1"} },
+	{ "nd_opt_rd_hdr nd_opt_rh_len", EXISTS, ICMP6_H,
+		"nd_opt_rd_hdr", "nd_opt_rh_len", "1", {"1"} },
+	{ "nd_opt_rd_hdr nd_opt_rh_reserved1", EXISTS, ICMP6_H,
+		"nd_opt_rd_hdr", "nd_opt_rh_reserved1", "2", {"2"} },
+	{ "nd_opt_rd_hdr nd_opt_rh_reserved2", EXISTS, ICMP6_H,
+		"nd_opt_rd_hdr", "nd_opt_rh_reserved2", "4", {"4"} },
+	{ "nd_opt_mtu nd_opt_mtu_type", EXISTS, ICMP6_H,
+		"nd_opt_mtu", "nd_opt_mtu_type", "0", {"1"} },
+	{ "nd_opt_mtu nd_opt_mtu_len", EXISTS, ICMP6_H,
+		"nd_opt_mtu", "nd_opt_mtu_len", "1", {"1"} },
+	{ "nd_opt_mtu nd_opt_mtu_reserved", EXISTS, ICMP6_H,
+		"nd_opt_mtu", "nd_opt_mtu_reserved", "2", {"2"} },
+	{ "nd_opt_mtu nd_opt_mtu_mtu", EXISTS, ICMP6_H,
+		"nd_opt_mtu", "nd_opt_mtu_mtu", "4", {"4"} },
+};
 
-#define FTCOUNT	(sizeof(ftab)/sizeof(ftab[0]))
+static void setup(void);
+static void cleanup(void);
+static void do_test(const struct ftent *);
 
-int TST_TOTAL = FTCOUNT;
+char *TCID = "asapi_02";
+int TST_TOTAL = ARRAY_SIZE(ftab);
 
 int main(int argc, char *argv[])
 {
 	int i, lc;
 	const char *msg;
 
-	/* Parse standard options given to run the test. */
 	msg = parse_opts(argc, argv, NULL, NULL);
-	if (msg != NULL) {
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-	}
 
 	setup();
 
 	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		for (i = 0; i < FTCOUNT; ++i) {
-			switch (ftab[i].ft_type) {
-			case EXISTS:
-				structcheck(ftab[i].ft_tname, ftab[i].ft_incl,
-					    ftab[i].ft_struct, ftab[i].ft_field,
-					    ftab[i].ft_offset,
-					    ftab[i].ft_value);
-				break;
-			case ALIAS:
-				aliascheck(ftab[i].ft_tname, ftab[i].ft_incl,
-					   ftab[i].ft_struct, ftab[i].ft_field,
-					   ftab[i].ft_dname);
-				break;
-			case VALUE:
-				valuecheck(ftab[i].ft_tname, ftab[i].ft_incl,
-					   ftab[i].ft_struct, ftab[i].ft_dname);
-				break;
-			default:
-				tst_resm(TBROK, "invalid type %d",
-					 ftab[i].ft_type);
-				break;
-			}
-		}
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; i++)
+			do_test(&ftab[i]);
 	}
 
 	cleanup();
-
 	tst_exit();
 }
 
 void setup(void)
 {
-	TEST_PAUSE;		/* if -P option specified */
+	TEST_PAUSE;
 }
 
 void cleanup(void)
 {
 	TEST_CLEANUP;
 }
+
+void do_test(const struct ftent *ftptr)
+{
+	switch (ftptr->ft_type) {
+	case EXISTS:
+		structcheck(ftptr->ft_tname, ftptr->ft_incl,
+			ftptr->ft_struct, ftptr->ft_field,
+			ftptr->ft_offset, ftptr->ft_value);
+		break;
+	case ALIAS:
+		aliascheck(ftptr->ft_tname, ftptr->ft_incl,
+			ftptr->ft_struct, ftptr->ft_field,
+			ftptr->ft_dname);
+		break;
+	case VALUE:
+		valuecheck(ftptr->ft_tname, ftptr->ft_incl,
+			ftptr->ft_struct, ftptr->ft_dname);
+		break;
+	default:
+		tst_resm(TBROK, "invalid type %d",
+			ftptr->ft_type);
+		break;
+	}
+}
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH 3/7] lib6/asapi_03.c: cleanup
  2015-01-23  9:36 [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup Xing Gu
  2015-01-23  9:36 ` [LTP] [PATCH 2/7] lib6/asapi_02.c: cleanup Xing Gu
@ 2015-01-23  9:36 ` Xing Gu
  2015-01-23  9:36 ` [LTP] [PATCH 4/7] lib6/asapi_07.c: cleanup Xing Gu
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Xing Gu @ 2015-01-23  9:36 UTC (permalink / raw)
  To: ltp-list

* Remove useless comments.

* Modify the format of ftab[].

* Move the test body from main() to do_test().

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
 testcases/network/lib6/asapi_03.c | 397 +++++++++++++++++---------------------
 1 file changed, 172 insertions(+), 225 deletions(-)

diff --git a/testcases/network/lib6/asapi_03.c b/testcases/network/lib6/asapi_03.c
index 5753d19..738a3f4 100644
--- a/testcases/network/lib6/asapi_03.c
+++ b/testcases/network/lib6/asapi_03.c
@@ -1,6 +1,7 @@
 /*
  *
  *   Copyright (c) International Business Machines  Corp., 2001
+ *   Author: David L Stevens
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -13,26 +14,13 @@
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *   along with this program;  if not, write to the Free Software Foundation,
+ *   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-
 /*
- * Test Name: asapi_03
- *
- * Test Description:
- *  These tests are for the "Advanced Sockets API" (RFC 3542)
- *  Verify that in6 and sockaddr fields are present.
- *
- * Usage:  <for command-line>
- *  asapi_03
- *
- * HISTORY
- *	03/2005 written by David L Stevens
- *
- * RESTRICTIONS:
- *  None.
- *
+ *   Description:
+ *     These tests are for the "Advanced Sockets API" (RFC 3542)
+ *     Verify that in6 and sockaddr fields are present.
  */
 
 #include <stdio.h>
@@ -47,10 +35,6 @@
 #include "usctest.h"
 #include "runcc.h"
 
-char *TCID = "asapi_03";	/* Test program identifier.    */
-
-void setup(void), cleanup(void);
-
 enum ttype { EXISTS, ALIAS, VALUE };
 
 struct ftent {
@@ -67,232 +51,195 @@ struct ftent {
 #define ft_value	ftun.fu_value
 #define ft_dname	ftun.fu_dname
 } ftab[] = {
-/* section 2.2.3, MLDv1 */
-	{
-		"MLD_LISTENER_QUERY", VALUE, ICMP6_H, "MLD_LISTENER_QUERY",
-		    NULL, NULL, {
-	"130"}}, {
-		"MLD_LISTENER_REPORT", VALUE, ICMP6_H, "MLD_LISTENER_REPORT",
-		    NULL, NULL, {
-	"131"}}, {
-		"MLD_LISTENER_REDUCTION", VALUE, ICMP6_H,
-		    "MLD_LISTENER_REDUCTION", NULL, NULL, {
-	"132"}}, {
-		"mld_hdr mld_icmp6_hdr", EXISTS, ICMP6_H, "mld_hdr",
-		    "mld_icmp6_hdr", "0", {
-	"sizeof(struct icmp6_hdr)"}}, {
-		"mld_hdr mld_addr", EXISTS, ICMP6_H, "mld_hdr", "mld_addr",
-		    "sizeof(struct icmp6_hdr)", {
-	"sizeof(struct in6_addr)"}}, {
-		"mld_hdr mld_type define", ALIAS, ICMP6_H, "mld_hdr",
-		    "mld_icmp6_hdr.icmp6_type", NULL, {
-	"mld_type"}}, {
-		"mld_hdr mld_code define", ALIAS, ICMP6_H, "mld_hdr",
-		    "mld_icmp6_hdr.icmp6_code", NULL, {
-	"mld_code"}}, {
-		"mld_hdr mld_cksum define", ALIAS, ICMP6_H, "mld_hdr",
-		    "mld_icmp6_hdr.icmp6_cksum", NULL, {
-	"mld_cksum"}}, {
-		"mld_hdr mld_maxdelay define", ALIAS, ICMP6_H, "mld_hdr",
-		    "mld_icmp6_hdr.icmp6_data16[0]", NULL, {
-	"mld_maxdelay"}}, {
-		"mld_hdr mld_reserved define", ALIAS, ICMP6_H, "mld_hdr",
-		    "mld_icmp6_hdr.icmp6_data16[1]", NULL, {
-	"mld_reserved"}},
-/* section 2.2.4, Router renumbering */
-	{
-		"ICMP6_ROUTER_RENUMBERING", VALUE, ICMP6_H,
-		    "ICMP6_ROUTER_RENUMBERING", NULL, NULL, {
-	"138"}}, {
-		"icmp6_router_renum rr_hdr", EXISTS, ICMP6_H,
-		    "icmp6_router_renum", "rr_hdr", "0", {
-	"sizeof(struct icmp6_hdr)"}}, {
-		"icmp6_router_renum rr_segnum", EXISTS, ICMP6_H,
-		    "icmp6_router_renum", "rr_segnum",
-		    "sizeof(struct icmp6_hdr)", {
-	"1"}}, {
-		"icmp6_router_renum rr_flags", EXISTS, ICMP6_H,
-		    "icmp6_router_renum", "rr_flags",
-		    "sizeof(struct icmp6_hdr)+1", {
-	"1"}}, {
-		"icmp6_router_renum rr_maxdelay", EXISTS, ICMP6_H,
-		    "icmp6_router_renum", "rr_maxdelay",
-		    "sizeof(struct icmp6_hdr)+2", {
-	"2"}}, {
-		"icmp6_router_renum rr_reserved", EXISTS, ICMP6_H,
-		    "icmp6_router_renum", "rr_reserved",
-		    "sizeof(struct icmp6_hdr)+4", {
-	"4"}}, {
-		"icmp6_router_renum rr_type define", ALIAS, ICMP6_H,
-		    "icmp6_router_renum", "rr_hdr.icmp6_type", NULL, {
-	"rr_type"}}, {
-		"icmp6_router_renum rr_code define", ALIAS, ICMP6_H,
-		    "icmp6_router_renum", "rr_hdr.icmp6_code", NULL, {
-	"rr_code"}}, {
-		"icmp6_router_renum rr_cksum define", ALIAS, ICMP6_H,
-		    "icmp6_router_renum", "rr_hdr.icmp6_cksum", NULL, {
-	"rr_cksum"}}, {
-		"icmp6_router_renum rr_seqnum define", ALIAS, ICMP6_H,
-		    "icmp6_router_renum", "rr_hdr.icmp6_data32[0]", NULL, {
-	"rr_seqnum"}}, {
-		"ICMP6_RR_FLAGS_TEST", VALUE, ICMP6_H, "ICMP6_RR_FLAGS_TEST",
-		    NULL, NULL, {
-	"0x80"}}, {
-		"ICMP6_RR_FLAGS_REQRESULT", VALUE, ICMP6_H,
-		    "ICMP6_RR_FLAGS_REQRESULT", NULL, NULL, {
-	"0x40"}}, {
-		"ICMP6_RR_FLAGS_FORCEAPPLY", VALUE, ICMP6_H,
-		    "ICMP6_RR_FLAGS_FORCEAPPLY", NULL, NULL, {
-	"0x20"}}, {
-		"ICMP6_RR_FLAGS_SPECSITE", VALUE, ICMP6_H,
-		    "ICMP6_RR_FLAGS_SPECSITE", NULL, NULL, {
-	"0x10"}}, {
-		"ICMP6_RR_FLAGS_PREVDONE", VALUE, ICMP6_H,
-		    "ICMP6_RR_FLAGS_PREVDONE", NULL, NULL, {
-	"0x08"}}, {
-		"rr_pco_match rpm_code", EXISTS, ICMP6_H, "rr_pco_match",
-		    "rpm_code", "0", {
-	"1"}}, {
-		"rr_pco_match rpm_len", EXISTS, ICMP6_H, "rr_pco_match",
-		    "rpm_len", "1", {
-	"1"}}, {
-		"rr_pco_match rpm_ordinal", EXISTS, ICMP6_H, "rr_pco_match",
-		    "rpm_ordinal", "2", {
-	"1"}}, {
-		"rr_pco_match rpm_matchlen", EXISTS, ICMP6_H, "rr_pco_match",
-		    "rpm_matchlen", "3", {
-	"1"}}, {
-		"rr_pco_match rpm_minlen", EXISTS, ICMP6_H, "rr_pco_match",
-		    "rpm_minlen", "4", {
-	"1"}}, {
-		"rr_pco_match rpm_maxlen", EXISTS, ICMP6_H, "rr_pco_match",
-		    "rpm_maxlen", "5", {
-	"1"}}, {
-		"rr_pco_match rpm_reserved", EXISTS, ICMP6_H, "rr_pco_match",
-		    "rpm_reserved", "6", {
-	"2"}}, {
-		"rr_pco_match rpm_prefix", EXISTS, ICMP6_H, "rr_pco_match",
-		    "rpm_prefix", "8", {
-	"sizeof(struct in6_addr)"}}, {
-		"RPM_PCO_ADD", VALUE, ICMP6_H, "RPM_PCO_ADD", NULL, NULL, {
-	"1"}}, {
-		"RPM_PCO_CHANGE", VALUE, ICMP6_H, "RPM_PCO_CHANGE", NULL, NULL, {
-	"2"}}, {
-		"RPM_PCO_SETGLOBAL", VALUE, ICMP6_H, "RPM_PCO_SETGLOBAL", NULL,
-		    NULL, {
-	"3"}}, {
-		"rr_pco_use rpu_uselen", EXISTS, ICMP6_H, "rr_pco_use",
-		    "rpu_uselen", "0", {
-	"1"}}, {
-		"rr_pco_use rpu_keeplen", EXISTS, ICMP6_H, "rr_pco_use",
-		    "rpu_keeplen", "1", {
-	"1"}}, {
-		"rr_pco_use rpu_ramask", EXISTS, ICMP6_H, "rr_pco_use",
-		    "rpu_ramask", "2", {
-	"1"}}, {
-		"rr_pco_use rpu_raflags", EXISTS, ICMP6_H, "rr_pco_use",
-		    "rpu_raflags", "3", {
-	"1"}}, {
-		"rr_pco_use rpu_vltime", EXISTS, ICMP6_H, "rr_pco_use",
-		    "rpu_vltime", "4", {
-	"4"}}, {
-		"rr_pco_use rpu_pltime", EXISTS, ICMP6_H, "rr_pco_use",
-		    "rpu_pltime", "8", {
-	"4"}}, {
-		"rr_pco_use rpu_flags", EXISTS, ICMP6_H, "rr_pco_use",
-		    "rpu_flags", "12", {
-	"4"}}, {
-		"rr_pco_use rpu_prefix", EXISTS, ICMP6_H, "rr_pco_use",
-		    "rpu_prefix", "16", {
-	"sizeof(struct in6_addr)"}}, {
-		"ICMP6_RR_PCOUSE_RAFLAGS_ONLINK", VALUE, ICMP6_H,
-		    "ICMP6_RR_PCOUSE_RAFLAGS_ONLINK", NULL, NULL, {
-	"0x20"}}, {
-		"ICMP6_RR_PCOUSE_RAFLAGS_AUTO", VALUE, ICMP6_H,
-		    "ICMP6_RR_PCOUSE_RAFLAGS_AUTO", NULL, NULL, {
-	"0x10"}}, {
-		"ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME", VALUE, ICMP6_H,
-		    "ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME", NULL, NULL, {
-	"htonl(0x80000000)"}}, {
-		"ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME", VALUE, ICMP6_H,
-		    "ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME", NULL, NULL, {
-	"htonl(0x40000000)"}}, {
-		"rr_result rrr_flags", EXISTS, ICMP6_H, "rr_result",
-		    "rrr_flags", "0", {
-	"2"}}, {
-		"rr_result rrr_ordinal", EXISTS, ICMP6_H, "rr_result",
-		    "rrr_ordinal", "2", {
-	"1"}}, {
-		"rr_result rrr_matchedlen", EXISTS, ICMP6_H, "rr_result",
-		    "rrr_matchedlen", "3", {
-	"1"}}, {
-		"rr_result rrr_ifid", EXISTS, ICMP6_H, "rr_result",
-		    "rrr_ifid", "4", {
-	"4"}}, {
-		"rr_result rrr_prefix", EXISTS, ICMP6_H, "rr_result",
-		    "rrr_prefix", "8", {
-	"sizeof(struct in6_addr)"}}, {
-		"ICMP6_RR_RESULT_FLAGS_OOB", VALUE, ICMP6_H,
-		    "ICMP6_RR_RESULT_FLAGS_OOB", NULL, NULL, {
-	"htons(0x0002)"}}, {
-		"ICMP6_RR_RESULT_FLAGS_FORBIDDEN", VALUE, ICMP6_H,
-		    "ICMP6_RR_RESULT_FLAGS_FORBIDDEN", NULL, NULL, {
-"htons(0x0001)"}},};
-
-#define FTCOUNT	(sizeof(ftab)/sizeof(ftab[0]))
-
-int TST_TOTAL = FTCOUNT;
+	/* section 2.2.3, MLDv1 */
+	{ "MLD_LISTENER_QUERY", VALUE, ICMP6_H,
+		"MLD_LISTENER_QUERY", NULL, NULL, {"130"} },
+	{ "MLD_LISTENER_REPORT", VALUE, ICMP6_H,
+		"MLD_LISTENER_REPORT", NULL, NULL, {"131"} },
+	{ "MLD_LISTENER_REDUCTION", VALUE, ICMP6_H,
+		"MLD_LISTENER_REDUCTION", NULL, NULL, {"132"} },
+	{ "mld_hdr mld_icmp6_hdr", EXISTS, ICMP6_H,
+		"mld_hdr", "mld_icmp6_hdr", "0",
+		{"sizeof(struct icmp6_hdr)"} },
+	{ "mld_hdr mld_addr", EXISTS, ICMP6_H, "mld_hdr",
+		"mld_addr", "sizeof(struct icmp6_hdr)",
+		{"sizeof(struct in6_addr)"} },
+	{ "mld_hdr mld_type define", ALIAS, ICMP6_H, "mld_hdr",
+		"mld_icmp6_hdr.icmp6_type", NULL, {"mld_type"} },
+	{ "mld_hdr mld_code define", ALIAS, ICMP6_H, "mld_hdr",
+		"mld_icmp6_hdr.icmp6_code", NULL, {"mld_code"} },
+	{ "mld_hdr mld_cksum define", ALIAS, ICMP6_H, "mld_hdr",
+		"mld_icmp6_hdr.icmp6_cksum", NULL, {"mld_cksum"} },
+	{ "mld_hdr mld_maxdelay define", ALIAS, ICMP6_H, "mld_hdr",
+		"mld_icmp6_hdr.icmp6_data16[0]", NULL, {"mld_maxdelay"} },
+	{ "mld_hdr mld_reserved define", ALIAS, ICMP6_H, "mld_hdr",
+		"mld_icmp6_hdr.icmp6_data16[1]", NULL, {"mld_reserved"} },
+	/* section 2.2.4, Router renumbering */
+	{ "ICMP6_ROUTER_RENUMBERING", VALUE, ICMP6_H,
+		"ICMP6_ROUTER_RENUMBERING", NULL, NULL, {"138"} },
+	{ "icmp6_router_renum rr_hdr", EXISTS, ICMP6_H,
+		"icmp6_router_renum", "rr_hdr", "0",
+		{"sizeof(struct icmp6_hdr)"} },
+	{ "icmp6_router_renum rr_segnum", EXISTS, ICMP6_H,
+		"icmp6_router_renum", "rr_segnum",
+		"sizeof(struct icmp6_hdr)", {"1"} },
+	{ "icmp6_router_renum rr_flags", EXISTS, ICMP6_H,
+		"icmp6_router_renum", "rr_flags",
+		"sizeof(struct icmp6_hdr)+1", {"1"} },
+	{ "icmp6_router_renum rr_maxdelay", EXISTS, ICMP6_H,
+		"icmp6_router_renum", "rr_maxdelay",
+		"sizeof(struct icmp6_hdr)+2", {"2"} },
+	{ "icmp6_router_renum rr_reserved", EXISTS, ICMP6_H,
+		"icmp6_router_renum", "rr_reserved",
+		"sizeof(struct icmp6_hdr)+4", {"4"} },
+	{ "icmp6_router_renum rr_type define", ALIAS, ICMP6_H,
+		"icmp6_router_renum", "rr_hdr.icmp6_type",
+		NULL, {"rr_type"} },
+	{ "icmp6_router_renum rr_code define", ALIAS, ICMP6_H,
+		"icmp6_router_renum", "rr_hdr.icmp6_code",
+		NULL, {"rr_code"} },
+	{ "icmp6_router_renum rr_cksum define", ALIAS, ICMP6_H,
+		"icmp6_router_renum", "rr_hdr.icmp6_cksum",
+		NULL, {"rr_cksum"} },
+	{ "icmp6_router_renum rr_seqnum define", ALIAS, ICMP6_H,
+		"icmp6_router_renum", "rr_hdr.icmp6_data32[0]",
+		NULL, {"rr_seqnum"} },
+	{ "ICMP6_RR_FLAGS_TEST", VALUE, ICMP6_H,
+		"ICMP6_RR_FLAGS_TEST", NULL, NULL, {"0x80"} },
+	{ "ICMP6_RR_FLAGS_REQRESULT", VALUE, ICMP6_H,
+		"ICMP6_RR_FLAGS_REQRESULT", NULL, NULL, {"0x40"} },
+	{ "ICMP6_RR_FLAGS_FORCEAPPLY", VALUE, ICMP6_H,
+		"ICMP6_RR_FLAGS_FORCEAPPLY", NULL, NULL, {"0x20"} },
+	{ "ICMP6_RR_FLAGS_SPECSITE", VALUE, ICMP6_H,
+		"ICMP6_RR_FLAGS_SPECSITE", NULL, NULL, {"0x10"} },
+	{ "ICMP6_RR_FLAGS_PREVDONE", VALUE, ICMP6_H,
+		"ICMP6_RR_FLAGS_PREVDONE", NULL, NULL, {"0x08"} },
+	{ "rr_pco_match rpm_code", EXISTS, ICMP6_H,
+		"rr_pco_match", "rpm_code", "0", {"1"} },
+	{ "rr_pco_match rpm_len", EXISTS, ICMP6_H,
+		"rr_pco_match", "rpm_len", "1", {"1"} },
+	{ "rr_pco_match rpm_ordinal", EXISTS, ICMP6_H,
+		"rr_pco_match", "rpm_ordinal", "2", {"1"} },
+	{ "rr_pco_match rpm_matchlen", EXISTS, ICMP6_H,
+		"rr_pco_match", "rpm_matchlen", "3", {"1"} },
+	{ "rr_pco_match rpm_minlen", EXISTS, ICMP6_H,
+		"rr_pco_match", "rpm_minlen", "4", {"1"} },
+	{ "rr_pco_match rpm_maxlen", EXISTS, ICMP6_H,
+		"rr_pco_match", "rpm_maxlen", "5", {"1"} },
+	{ "rr_pco_match rpm_reserved", EXISTS, ICMP6_H,
+		"rr_pco_match", "rpm_reserved", "6", {"2"} },
+	{ "rr_pco_match rpm_prefix", EXISTS, ICMP6_H,
+		"rr_pco_match", "rpm_prefix", "8",
+		{"sizeof(struct in6_addr)"} },
+	{ "RPM_PCO_ADD", VALUE, ICMP6_H, "RPM_PCO_ADD",
+		NULL, NULL, {"1"} },
+	{ "RPM_PCO_CHANGE", VALUE, ICMP6_H, "RPM_PCO_CHANGE",
+		NULL, NULL, {"2"} },
+	{ "RPM_PCO_SETGLOBAL", VALUE, ICMP6_H, "RPM_PCO_SETGLOBAL",
+		NULL, NULL, {"3"} },
+	{ "rr_pco_use rpu_uselen", EXISTS, ICMP6_H, "rr_pco_use",
+		"rpu_uselen", "0", {"1"} },
+	{ "rr_pco_use rpu_keeplen", EXISTS, ICMP6_H, "rr_pco_use",
+		"rpu_keeplen", "1", {"1"} },
+	{ "rr_pco_use rpu_ramask", EXISTS, ICMP6_H, "rr_pco_use",
+		"rpu_ramask", "2", {"1"} },
+	{ "rr_pco_use rpu_raflags", EXISTS, ICMP6_H, "rr_pco_use",
+		"rpu_raflags", "3", {"1"} },
+	{ "rr_pco_use rpu_vltime", EXISTS, ICMP6_H, "rr_pco_use",
+		"rpu_vltime", "4", {"4"} },
+	{ "rr_pco_use rpu_pltime", EXISTS, ICMP6_H, "rr_pco_use",
+		"rpu_pltime", "8", {"4"} },
+	{ "rr_pco_use rpu_flags", EXISTS, ICMP6_H, "rr_pco_use",
+		"rpu_flags", "12", {"4"} },
+	{ "rr_pco_use rpu_prefix", EXISTS, ICMP6_H, "rr_pco_use",
+		"rpu_prefix", "16", {"sizeof(struct in6_addr)"} },
+	{ "ICMP6_RR_PCOUSE_RAFLAGS_ONLINK", VALUE, ICMP6_H,
+		"ICMP6_RR_PCOUSE_RAFLAGS_ONLINK", NULL, NULL, {"0x20"} },
+	{ "ICMP6_RR_PCOUSE_RAFLAGS_AUTO", VALUE, ICMP6_H,
+		"ICMP6_RR_PCOUSE_RAFLAGS_AUTO", NULL, NULL, {"0x10"} },
+	{ "ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME", VALUE, ICMP6_H,
+		"ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME", NULL, NULL,
+		{"htonl(0x80000000)"} },
+	{ "ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME", VALUE, ICMP6_H,
+		"ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME", NULL, NULL,
+		{"htonl(0x40000000)"} },
+	{ "rr_result rrr_flags", EXISTS, ICMP6_H, "rr_result",
+		"rrr_flags", "0", {"2"} },
+	{ "rr_result rrr_ordinal", EXISTS, ICMP6_H, "rr_result",
+		"rrr_ordinal", "2", {"1"} },
+	{ "rr_result rrr_matchedlen", EXISTS, ICMP6_H, "rr_result",
+		"rrr_matchedlen", "3", {"1"} },
+	{ "rr_result rrr_ifid", EXISTS, ICMP6_H, "rr_result",
+		"rrr_ifid", "4", {"4"} },
+	{ "rr_result rrr_prefix", EXISTS, ICMP6_H, "rr_result",
+		"rrr_prefix", "8", {"sizeof(struct in6_addr)"} },
+	{ "ICMP6_RR_RESULT_FLAGS_OOB", VALUE, ICMP6_H,
+		"ICMP6_RR_RESULT_FLAGS_OOB", NULL, NULL,
+		{"htons(0x0002)"} },
+	{ "ICMP6_RR_RESULT_FLAGS_FORBIDDEN", VALUE, ICMP6_H,
+		"ICMP6_RR_RESULT_FLAGS_FORBIDDEN", NULL, NULL,
+		{"htons(0x0001)"} },
+};
+
+static void setup(void);
+static void cleanup(void);
+static void do_test(const struct ftent *);
+
+char *TCID = "asapi_03";
+int TST_TOTAL = ARRAY_SIZE(ftab);
 
 int main(int argc, char *argv[])
 {
 	int i, lc;
 	const char *msg;
 
-	/* Parse standard options given to run the test. */
 	msg = parse_opts(argc, argv, NULL, NULL);
-	if (msg != NULL) {
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-	}
 
 	setup();
 
 	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		for (i = 0; i < FTCOUNT; ++i) {
-			switch (ftab[i].ft_type) {
-			case EXISTS:
-				structcheck(ftab[i].ft_tname, ftab[i].ft_incl,
-					    ftab[i].ft_struct, ftab[i].ft_field,
-					    ftab[i].ft_offset,
-					    ftab[i].ft_value);
-				break;
-			case ALIAS:
-				aliascheck(ftab[i].ft_tname, ftab[i].ft_incl,
-					   ftab[i].ft_struct, ftab[i].ft_field,
-					   ftab[i].ft_dname);
-				break;
-			case VALUE:
-				valuecheck(ftab[i].ft_tname, ftab[i].ft_incl,
-					   ftab[i].ft_struct, ftab[i].ft_dname);
-				break;
-			default:
-				tst_resm(TBROK, "invalid type %d",
-					 ftab[i].ft_type);
-				break;
-			}
-		}
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; i++)
+			do_test(&ftab[i]);
 	}
 
 	cleanup();
-
 	tst_exit();
 }
 
 void setup(void)
 {
-	TEST_PAUSE;		/* if -P option specified */
+	TEST_PAUSE;
 }
 
 void cleanup(void)
 {
 	TEST_CLEANUP;
 }
+
+void do_test(const struct ftent *ftptr)
+{
+	switch (ftptr->ft_type) {
+	case EXISTS:
+		structcheck(ftptr->ft_tname, ftptr->ft_incl,
+			ftptr->ft_struct, ftptr->ft_field,
+			ftptr->ft_offset, ftptr->ft_value);
+		break;
+	case ALIAS:
+		aliascheck(ftptr->ft_tname, ftptr->ft_incl,
+			ftptr->ft_struct, ftptr->ft_field,
+			ftptr->ft_dname);
+		break;
+	case VALUE:
+		valuecheck(ftptr->ft_tname, ftptr->ft_incl,
+			ftptr->ft_struct, ftptr->ft_dname);
+		break;
+	default:
+		tst_resm(TBROK, "invalid type %d",
+			ftptr->ft_type);
+		break;
+	}
+}
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH 4/7] lib6/asapi_07.c: cleanup
  2015-01-23  9:36 [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup Xing Gu
  2015-01-23  9:36 ` [LTP] [PATCH 2/7] lib6/asapi_02.c: cleanup Xing Gu
  2015-01-23  9:36 ` [LTP] [PATCH 3/7] lib6/asapi_03.c: cleanup Xing Gu
@ 2015-01-23  9:36 ` Xing Gu
  2015-01-23  9:36 ` [LTP] [PATCH 5/7] lib6/in6_01.c: cleanup Xing Gu
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Xing Gu @ 2015-01-23  9:36 UTC (permalink / raw)
  To: ltp-list

* Remove useless comments.

* Modify the format of etab[].

* Modify adatet() as the test body.

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
 testcases/network/lib6/asapi_07.c | 213 +++++++++++++++++---------------------
 1 file changed, 94 insertions(+), 119 deletions(-)

diff --git a/testcases/network/lib6/asapi_07.c b/testcases/network/lib6/asapi_07.c
index 4571320..213754b 100644
--- a/testcases/network/lib6/asapi_07.c
+++ b/testcases/network/lib6/asapi_07.c
@@ -1,6 +1,7 @@
 /*
  *
  *   Copyright (c) International Business Machines  Corp., 2001
+ *   Author: David L Stevens
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -13,26 +14,13 @@
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *   along with this program;  if not, write to the Free Software Foundation,
+ *   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-
 /*
- * Test Name: asapi_07
- *
- * Test Description:
- *  These tests are for the "Advanced Sockets API" (RFC 3542)
- *  Section 20, ancillary data macros and structure definitions
- *
- * Usage:  <for command-line>
- *  asapi_07
- *
- * HISTORY
- *	04/2005 written by David L Stevens
- *
- * RESTRICTIONS:
- *  None.
- *
+ *   Description:
+ *     These tests are for the "Advanced Sockets API" (RFC 3542)
+ *     Section 20, ancillary data macros and structure definitions
  */
 
 #include <stdio.h>
@@ -49,37 +37,9 @@
 #include "usctest.h"
 #include "runcc.h"
 
-char *TCID = "asapi_07";	/* Test program identifier.    */
-
-void setup(void);
-void cleanup(void);
-
-void adatet(void);
-void adatft(void);
-
-int main(int argc, char *argv[])
-{
-	int lc;
-	const char *msg;
-
-	/* Parse standard options given to run the test. */
-	if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
-		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		adatet();
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
 enum ttype { EXISTS, ALIAS, VALUE, DEFINED };
 
-struct etent {
+static struct etent {
 	char *et_tname;		/* test name */
 	int et_type;		/* test type */
 	char *et_incl;		/* include file list */
@@ -93,84 +53,72 @@ struct etent {
 #define et_value	ftun.fu_value
 #define et_dname	ftun.fu_dname
 } etab[] = {
-/* existence checks, RFC 3542 sections 5, 20 */
-	{
-		"msghdr msg_name", EXISTS, SOCKET_H, "msghdr", "msg_name", NULL, {
-	"sizeof(void *)"}}, {
-		"msghdr msg_namelen", EXISTS, SOCKET_H, "msghdr",
-		    "msg_namelen", NULL, {
-	"sizeof(socklen_t)"}}, {
-		"msghdr msg_iov", EXISTS, SOCKET_H, "msghdr", "msg_iov", NULL, {
-	"sizeof(struct iovec *)"}}, {
-		"msghdr msg_iovlen", EXISTS, SOCKET_H, "msghdr",
-		    "msg_iovlen", NULL, {
-	"sizeof(size_t)"}}, {
-		"msghdr msg_control", EXISTS, SOCKET_H, "msghdr",
-		    "msg_control", NULL, {
-	"sizeof(void *)"}}, {
-		"msghdr msg_controllen", EXISTS, SOCKET_H, "msghdr",
-		    "msg_controllen", NULL, {
-	"sizeof(size_t)"}}, {
-		"msghdr msg_flags", EXISTS, SOCKET_H, "msghdr",
-		    "msg_flags", NULL, {
-	"sizeof(int)"}}, {
-		"cmsghdr cmsg_len", EXISTS, SOCKET_H, "cmsghdr",
-		    "cmsg_len", NULL, {
-	"sizeof(size_t)"}}, {
-		"cmsghdr cmsg_level", EXISTS, SOCKET_H, "cmsghdr",
-		    "cmsg_level", NULL, {
-	"sizeof(int)"}}, {
-		"cmsghdr cmsg_type", EXISTS, SOCKET_H, "cmsghdr",
-		    "cmsg_type", NULL, {
-	"sizeof(int)"}}, {
-		"CMSG_DATA", DEFINED, SOCKET_H, "CMSG_DATA", NULL, NULL, {
-	0}}, {
-		"CMSG_NXTHDR", DEFINED, SOCKET_H, "CMSG_NXTHDR", NULL, NULL, {
-	0}}, {
-		"CMSG_FIRSTHDR", DEFINED, SOCKET_H, "CMSG_FIRSTHDR", NULL, NULL, {
-	0}}, {
-		"CMSG_SPACE", DEFINED, SOCKET_H, "CMSG_SPACE", NULL, NULL, {
-	0}}, {
-		"CMSG_LEN", DEFINED, SOCKET_H, "CMSG_LEN", NULL, NULL, {
-0}},};
-
-#define ETCOUNT	(sizeof(etab)/sizeof(etab[0]))
+	/* existence checks, RFC 3542 sections 5, 20 */
+	{ "msghdr msg_name", EXISTS, SOCKET_H, "msghdr",
+		"msg_name", NULL, {"sizeof(void *)"} },
+	{ "msghdr msg_namelen", EXISTS, SOCKET_H, "msghdr",
+		"msg_namelen", NULL, {"sizeof(socklen_t)"} },
+	{ "msghdr msg_iov", EXISTS, SOCKET_H, "msghdr",
+		"msg_iov", NULL, {"sizeof(struct iovec *)"} },
+	{ "msghdr msg_iovlen", EXISTS, SOCKET_H, "msghdr",
+		"msg_iovlen", NULL, {"sizeof(size_t)"} },
+	{ "msghdr msg_control", EXISTS, SOCKET_H, "msghdr",
+		"msg_control", NULL, {"sizeof(void *)"} },
+	{ "msghdr msg_controllen", EXISTS, SOCKET_H, "msghdr",
+		"msg_controllen", NULL, {"sizeof(size_t)"} },
+	{ "msghdr msg_flags", EXISTS, SOCKET_H, "msghdr",
+		"msg_flags", NULL, {"sizeof(int)"} },
+	{ "cmsghdr cmsg_len", EXISTS, SOCKET_H, "cmsghdr",
+		"cmsg_len", NULL, {"sizeof(size_t)"} },
+	{ "cmsghdr cmsg_level", EXISTS, SOCKET_H, "cmsghdr",
+		"cmsg_level", NULL, {"sizeof(int)"} },
+	{ "cmsghdr cmsg_type", EXISTS, SOCKET_H, "cmsghdr",
+		"cmsg_type", NULL, {"sizeof(int)"} },
+	{ "CMSG_DATA", DEFINED, SOCKET_H, "CMSG_DATA",
+		NULL, NULL, {0} },
+	{ "CMSG_NXTHDR", DEFINED, SOCKET_H, "CMSG_NXTHDR",
+		NULL, NULL, {0} },
+	{ "CMSG_FIRSTHDR", DEFINED, SOCKET_H, "CMSG_FIRSTHDR",
+		NULL, NULL, {0} },
+	{ "CMSG_SPACE", DEFINED, SOCKET_H, "CMSG_SPACE",
+		NULL, NULL, {0} },
+	{ "CMSG_LEN", DEFINED, SOCKET_H, "CMSG_LEN",
+		NULL, NULL, {0} },
+};
+
+static void setup(void);
+static void cleanup(void);
+static void adatet(const struct etent *etptr);
+
+char *TCID = "asapi_07";
+int TST_TOTAL = ARRAY_SIZE(etab);
 
-/*  existence tests */
-void adatet(void)
+int main(int argc, char *argv[])
 {
-	int i;
-
-	for (i = 0; i < ETCOUNT; ++i) {
-		switch (etab[i].et_type) {
-		case EXISTS:
-			structcheck(etab[i].et_tname, etab[i].et_incl,
-				    etab[i].et_struct, etab[i].et_field,
-				    etab[i].et_offset, etab[i].et_value);
-			break;
-		case ALIAS:
-			aliascheck(etab[i].et_tname, etab[i].et_incl,
-				   etab[i].et_struct, etab[i].et_field,
-				   etab[i].et_dname);
-			break;
-		case VALUE:
-			valuecheck(etab[i].et_tname, etab[i].et_incl,
-				   etab[i].et_struct, etab[i].et_dname);
-			break;
-		case DEFINED:
-			funccheck(etab[i].et_tname, etab[i].et_incl,
-				  etab[i].et_struct);
-			break;
-		default:
-			tst_resm(TBROK, "invalid type %d", etab[i].et_type);
-			break;
-		}
+	int i, lc;
+	const char *msg;
+
+	msg = parse_opts(argc, argv, NULL, NULL);
+	if (msg != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); ++lc) {
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; i++)
+			adatet(&etab[i]);
 	}
+
+	cleanup();
+
+	tst_exit();
 }
 
 void setup(void)
 {
-	TEST_PAUSE;		/* if -P option specified */
+	TEST_PAUSE;
 }
 
 void cleanup(void)
@@ -178,4 +126,31 @@ void cleanup(void)
 	TEST_CLEANUP;
 }
 
-int TST_TOTAL = ETCOUNT;
+/*  existence tests */
+void adatet(const struct etent *etptr)
+{
+	switch (etptr->et_type) {
+	case EXISTS:
+		structcheck(etptr->et_tname, etptr->et_incl,
+			etptr->et_struct, etptr->et_field,
+			etptr->et_offset, etptr->et_value);
+		break;
+	case ALIAS:
+		aliascheck(etptr->et_tname, etptr->et_incl,
+			etptr->et_struct, etptr->et_field,
+			etptr->et_dname);
+		break;
+	case VALUE:
+		valuecheck(etptr->et_tname, etptr->et_incl,
+			etptr->et_struct, etptr->et_dname);
+		break;
+	case DEFINED:
+		funccheck(etptr->et_tname, etptr->et_incl,
+			etptr->et_struct);
+		break;
+	default:
+		tst_resm(TBROK, "invalid type %d",
+			etptr->et_type);
+		break;
+	}
+}
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH 5/7] lib6/in6_01.c: cleanup
  2015-01-23  9:36 [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup Xing Gu
                   ` (2 preceding siblings ...)
  2015-01-23  9:36 ` [LTP] [PATCH 4/7] lib6/asapi_07.c: cleanup Xing Gu
@ 2015-01-23  9:36 ` Xing Gu
  2015-01-23  9:36 ` [LTP] [PATCH 6/7] lib6/in6_02.c: cleanup Xing Gu
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Xing Gu @ 2015-01-23  9:36 UTC (permalink / raw)
  To: ltp-list

* Remove useless comments.

* Move the test body from main() to (*testfunc[])().

* In every test function, using TINFO instead of TPASS
  marks the success of each inner test.

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
 testcases/network/lib6/in6_01.c | 242 +++++++++++++++++++++++-----------------
 1 file changed, 141 insertions(+), 101 deletions(-)

diff --git a/testcases/network/lib6/in6_01.c b/testcases/network/lib6/in6_01.c
index ef2ff88..4b3c549 100644
--- a/testcases/network/lib6/in6_01.c
+++ b/testcases/network/lib6/in6_01.c
@@ -1,6 +1,7 @@
 /*
  *
  *   Copyright (c) International Business Machines  Corp., 2001
+ *   Author: David L Stevens
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -13,26 +14,13 @@
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *   along with this program;  if not, write to the Free Software Foundation,
+ *   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-
 /*
- * Test Name: in6_01
- *
- * Test Description:
- *  Verify that in6 and sockaddr fields are present. Most of these are
- *  "PASS" if they just compile.
- *
- * Usage:  <for command-line>
- *  in6_01
- *
- * HISTORY
- *	05/2004 written by David L Stevens
- *
- * RESTRICTIONS:
- *  None.
- *
+ *   Description:
+ *     Verify that in6 and sockaddr fields are present. Most of these are
+ *     "PASS" if they just compile.
  */
 
 #include <stdio.h>
@@ -45,52 +33,53 @@
 #include "test.h"
 #include "usctest.h"
 
-char *TCID = "in6_01";		/* Test program identifier.    */
-
-void setup(void), cleanup(void);
-
-struct {
+static struct {
 	char *addr;
 	int ismap;
 } maptab[] = {
-	{
-	"2002::1", 0}, {
-	"::ffff:10.0.0.1", 1}, {
-	"::fffe:10.0.0.1", 0}, {
-	"::7fff:10.0.0.1", 0}, {
-	"0:0:0:0:0:0:ffff:0a001", 1}, {
-"0:0:1:0:0:0:ffff:0a001", 0},};
+	{ "2002::1", 0 },
+	{ "::ffff:10.0.0.1", 1 },
+	{ "::fffe:10.0.0.1", 0 },
+	{ "::7fff:10.0.0.1", 0 },
+	{ "0:0:0:0:0:0:ffff:0a001", 0 },
+	{ "0:0:1:0:0:0:ffff:0a001", 0 },
+};
 
 #define MAPSIZE (sizeof(maptab)/sizeof(maptab[0]))
 
-struct {
+static struct {
 	char *addr;
 } sstab[] = {
-	{
-	"2002::1"}, {
-	"10.0.0.1"}, {
-	"::ffff:10.0.0.1"}, {
-	"::1"}, {
-"::"},};
+	{ "2002::1" },
+	{ "10.0.0.1" },
+	{ "::ffff:10.0.0.1" },
+	{ "::1" },
+	{ "::" },
+};
 
 #define SSSIZE (sizeof(sstab)/sizeof(sstab[0]))
 
-int TST_TOTAL = 9 + MAPSIZE + SSSIZE;
+static void setup(void);
+static void cleanup(void);
+static void test_in6_addr(void);
+static void test_sockaddr_in6(void);
+static void test_global_in6_def(void);
+static void test_in6_is_addr_v4mapped(void);
+static void test_sockaddr_storage(void);
+
+static void (*testfunc[])(void) = { test_in6_addr,
+	test_sockaddr_in6, test_global_in6_def,
+	test_in6_is_addr_v4mapped, test_sockaddr_storage };
+
+char *TCID = "in6_01";
+int TST_TOTAL = ARRAY_SIZE(testfunc);
 
 int main(int argc, char *argv[])
 {
-	uint8_t ui8 = 1;
-	uint32_t ui16 = 2;
-	uint32_t ui32 = 3;
-	struct in6_addr in6;
-	struct in6_addr ina6 = IN6ADDR_ANY_INIT;
-	struct in6_addr inl6 = IN6ADDR_LOOPBACK_INIT;
-	struct sockaddr_in6 sin6;
-	struct sockaddr_storage ss;
+	int lc;
 	int i;
 	const char *msg;
 
-	/* Parse standard options given to run the test. */
 	msg = parse_opts(argc, argv, NULL, NULL);
 	if (msg != NULL) {
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
@@ -98,62 +87,128 @@ int main(int argc, char *argv[])
 
 	setup();
 
-	/* struct in6_addr tests */
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; i++)
+			(*testfunc[i])();
+	}
+
+	cleanup();
+	tst_exit();
+}
+
+static void setup(void)
+{
+	TEST_PAUSE;
+}
+
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+}
+
+/* struct in6_addr tests */
+static void test_in6_addr(void)
+{
+	uint8_t ui8 = 1;
+	struct in6_addr in6;
+
 	in6.s6_addr[0] = ui8;
-	tst_resm(TPASS, "type of in6.s6_addr[0] is uint8_t");
+	tst_resm(TINFO, "type of in6.s6_addr[0] is uint8_t");
 	if (sizeof(in6.s6_addr) != 16)
 		tst_resm(TFAIL, "sizeof(in6.s6_addr) != 16");
 	else
 		tst_resm(TPASS, "sizeof(in6.s6_addr) == 16");
+}
 
-	/* struct sockaddr_in6 tests */
+/* struct sockaddr_in6 tests */
+static void test_sockaddr_in6(void)
+{
+	uint8_t ui8 = 1;
+	uint32_t ui16 = 2;
+	uint32_t ui32 = 3;
+	struct in6_addr in6;
+	struct sockaddr_in6 sin6;
+
+	in6.s6_addr[0] = ui8;
 	sin6.sin6_family = AF_INET6;
 	sin6.sin6_port = ui16;
 	sin6.sin6_flowinfo = ui32;
 	sin6.sin6_addr = in6;
 	sin6.sin6_scope_id = ui32;
 	tst_resm(TPASS, "all sockaddr_in6 fields present and correct");
+}
 
-	/* initializers and global in6 definitions tests */
-	tst_resm(TPASS, "IN6ADDR_ANY_INIT present");
-	if (memcmp(&ina6, &in6addr_any, sizeof(ina6)) == 0)
-		tst_resm(TPASS, "in6addr_any present and correct");
-	else
+/* initializers and global in6 definitions tests */
+static void test_global_in6_def(void)
+{
+	struct in6_addr ina6 = IN6ADDR_ANY_INIT;
+	struct in6_addr inl6 = IN6ADDR_LOOPBACK_INIT;
+
+	tst_resm(TINFO, "IN6ADDR_ANY_INIT present");
+	if (memcmp(&ina6, &in6addr_any, sizeof(ina6)) == 0) {
+		tst_resm(TINFO, "in6addr_any present and correct");
+	} else {
 		tst_resm(TFAIL, "in6addr_any incorrect value");
-	tst_resm(TPASS, "IN6ADDR_LOOPBACK_INIT present");
-	if (memcmp(&inl6, &in6addr_loopback, sizeof(inl6)) == 0)
-		tst_resm(TPASS, "in6addr_loopback present and correct");
-	else
+		return;
+	}
+
+	tst_resm(TINFO, "IN6ADDR_LOOPBACK_INIT present");
+	if (memcmp(&inl6, &in6addr_loopback, sizeof(inl6)) == 0) {
+		tst_resm(TINFO, "in6addr_loopback present and correct");
+	} else {
 		tst_resm(TFAIL, "in6addr_loopback incorrect value");
+		return;
+	}
 	if (inet_pton(AF_INET6, "::1", &inl6) <= 0)
-		tst_resm(TBROK, "inet_pton(\"::1\")");
-	else if (memcmp(&inl6, &in6addr_loopback, sizeof(inl6)) == 0)
-		tst_resm(TPASS, "in6addr_loopback in network byte order");
-	else
+		tst_brkm(TBROK | TERRNO, cleanup, "inet_pton(\"::1\")");
+	if (memcmp(&inl6, &in6addr_loopback, sizeof(inl6)) == 0) {
+		tst_resm(TINFO, "in6addr_loopback in network byte order");
+	} else {
 		tst_resm(TFAIL, "in6addr_loopback has wrong byte order");
+		return;
+	}
+
+	tst_resm(TPASS, "global in6 definitions tests succeed");
+}
 
-	/* IN6_IS_ADDR_V4MAPPED tests */
+/* IN6_IS_ADDR_V4MAPPED tests */
+static void test_in6_is_addr_v4mapped(void)
+{
+	unsigned int i;
+	struct in6_addr in6;
 
 	for (i = 0; i < MAPSIZE; ++i) {
 		if (inet_pton(AF_INET6, maptab[i].addr, &in6) <= 0) {
-			tst_resm(TBROK, "\"%s\" is not a valid IPv6 address",
-				 maptab[i].addr);
-			continue;
+			tst_brkm(TBROK | TERRNO, cleanup,
+				"\"%s\" is not a valid IPv6 address",
+				maptab[i].addr);
 		}
 		TEST(IN6_IS_ADDR_V4MAPPED(in6.s6_addr));
-		if (TEST_RETURN == maptab[i].ismap)
-			tst_resm(TEST_RETURN == maptab[i].ismap ? TPASS : TFAIL,
-				 "IN6_IS_ADDR_V4MAPPED(\"%s\") %ld",
-				 maptab[i].addr, TEST_RETURN);
+		if (TEST_RETURN == maptab[i].ismap) {
+			tst_resm(TINFO, "IN6_IS_ADDR_V4MAPPED(\"%s\") %ld",
+				maptab[i].addr, TEST_RETURN);
+		} else {
+			tst_resm(TFAIL, "IN6_IS_ADDR_V4MAPPED(\"%s\") %ld",
+				maptab[i].addr, TEST_RETURN);
+			return;
+		}
 	}
 
-	/* sockaddr_storage tests */
+	tst_resm(TPASS, "IN6_IS_ADDR_V4MAPPED tests succeed");
+}
+
+/* sockaddr_storage tests */
+static void test_sockaddr_storage(void)
+{
+	unsigned int i;
+	struct sockaddr_storage ss;
 
 	if (sizeof(ss) <= sizeof(struct sockaddr_in) ||
-	    sizeof(ss) <= sizeof(struct sockaddr_in6))
-		tst_resm(TFAIL, "sockaddr_storage too small");
-	else
-		tst_resm(TPASS, "sockaddr_storage size ok");
+		sizeof(ss) <= sizeof(struct sockaddr_in6))
+		tst_brkm(TBROK, cleanup, "sockaddr_storage too small");
+
 	for (i = 0; i < SSSIZE; ++i) {
 		struct sockaddr_in *psin = (struct sockaddr_in *)&ss;
 		struct sockaddr_in6 *psin6 = (struct sockaddr_in6 *)&ss;
@@ -165,35 +220,20 @@ int main(int argc, char *argv[])
 		if (rv == 0) {
 			af = psin6->sin6_family = AF_INET6;
 			rv = inet_pton(AF_INET6, sstab[i].addr,
-				       &psin6->sin6_addr);
+				&psin6->sin6_addr);
 		}
 		if (rv <= 0) {
-			tst_resm(TBROK, "\"%s\" is not a valid address",
-				 sstab[i].addr);
-			continue;
+			tst_brkm(TBROK, cleanup,
+				"\"%s\" is not a valid address", sstab[i].addr);
 		}
-		if (ss.ss_family == af)
-			tst_resm(TPASS, "\"%s\" is AF_INET%s",
-				 sstab[i].addr, af == AF_INET ? "" : "6");
-		else
+		if (ss.ss_family == af) {
+			tst_resm(TINFO, "\"%s\" is AF_INET%s",
+				sstab[i].addr, af == AF_INET ? "" : "6");
+		} else {
 			tst_resm(TFAIL, "\"%s\" ss_family (%d) != AF_INET%s",
-				 sstab[i].addr, af, af == AF_INET ? "" : "6");
+				sstab[i].addr, af, af == AF_INET ? "" : "6");
+		}
 	}
 
-	cleanup();
-
-	return (0);
-}
-
-pid_t pid;
-
-void setup(void)
-{
-	TEST_PAUSE;		/* if -P option specified */
-}
-
-void cleanup(void)
-{
-	TEST_CLEANUP;
-
+	tst_resm(TPASS, "sockaddr_storage tests succeed");
 }
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH 6/7] lib6/in6_02.c: cleanup
  2015-01-23  9:36 [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup Xing Gu
                   ` (3 preceding siblings ...)
  2015-01-23  9:36 ` [LTP] [PATCH 5/7] lib6/in6_01.c: cleanup Xing Gu
@ 2015-01-23  9:36 ` Xing Gu
  2015-01-23  9:36 ` [LTP] [PATCH 7/7] ipv6_lib: add it into default Xing Gu
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Xing Gu @ 2015-01-23  9:36 UTC (permalink / raw)
  To: ltp-list

* Remove useless comments.

* Move the test body from main() to (*testfunc[])().

* In every test function, using TINFO instead of TPASS
  marks the success of each inner test.

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
 testcases/network/lib6/in6_02.c | 180 ++++++++++++++++++----------------------
 1 file changed, 81 insertions(+), 99 deletions(-)

diff --git a/testcases/network/lib6/in6_02.c b/testcases/network/lib6/in6_02.c
index 664c74f..0988c37 100644
--- a/testcases/network/lib6/in6_02.c
+++ b/testcases/network/lib6/in6_02.c
@@ -1,6 +1,7 @@
 /*
  *
  *   Copyright (c) International Business Machines  Corp., 2001
+ *   Author: David L Stevens
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -13,73 +14,54 @@
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *   along with this program;  if not, write to the Free Software Foundation,
+ *   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-
 /*
- * Test Name: in6_02
- *
- * Test Description:
- *  Tests for name to index and index to name functions in IPv6
- *
- * Usage:  <for command-line>
- *  in6_02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	05/2004 written by David L Stevens
- *
- * RESTRICTIONS:
- *  None.
- *
+ *   Description:
+ *     Tests for name to index and index to name functions in IPv6
  */
 
 #include <unistd.h>
 #include <errno.h>
-
 #include <sys/socket.h>
-
 #include <net/if.h>
 
 #include "test.h"
 #include "usctest.h"
 
-char *TCID = "in6_02";		/* Test program identifier.    */
-int testno;
-
-void setup(void), cleanup(void);
-
-struct {
+static struct {
 	char *name;
 	int nonzero;
 } n2i[] = {
-	{
-	"lo", 1}, {
-	"eth0", 1}, {
-	"hoser75", 0}, {
-"6", 0},};
+	{ "lo", 1 },
+	{ "eth0", 1 },
+	{ "hoser75", 0 },
+	{ "6", 0 },
+};
 
 #define N2I_COUNT (sizeof(n2i)/sizeof(n2i[0]))
-
 #define I2N_RNDCOUNT	10	/* random ints */
 #define I2N_LOWCOUNT	10	/* sequential from 0 */
 
-int TST_TOTAL = N2I_COUNT;
+static void setup(void);
+static void cleanup(void);
+static void n2itest(void);
+static void i2ntest(void);
+static void initest(void);
+
+static void (*testfunc[])(void) = { n2itest,
+	i2ntest, initest };
 
-void n2itest(void), i2ntest(void), initest(void);
+char *TCID = "in6_02";
+int TST_TOTAL = ARRAY_SIZE(testfunc);
 
 int main(int argc, char *argv[])
 {
 	int lc;
+	int i;
 	const char *msg;
 
-	/* Parse standard options given to run the test. */
 	msg = parse_opts(argc, argv, NULL, NULL);
 	if (msg != NULL) {
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
@@ -88,53 +70,48 @@ int main(int argc, char *argv[])
 	setup();
 
 	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		n2itest();
-		i2ntest();
-		initest();
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; i++)
+			(*testfunc[i])();
 	}
-	cleanup();
 
-	return (0);
+	cleanup();
+	tst_exit();
 }
 
 /* if_nametoindex tests */
-
-void n2itest()
+void n2itest(void)
 {
-	int i;
+	unsigned int i;
+	char ifname[IF_NAMESIZE], *pifn;
 
 	for (i = 0; i < N2I_COUNT; ++i) {
-		char ifname[IF_NAMESIZE], *pifn;
-		int fail;
-
 		TEST(if_nametoindex(n2i[i].name));
-		fail = !TEST_RETURN != !n2i[i].nonzero;
-		if (fail) {
+		if (!TEST_RETURN != !n2i[i].nonzero) {
 			tst_resm(TFAIL, "if_nametoindex(\"%s\") %ld "
-				 "[should be %szero]", n2i[i].name,
-				 TEST_RETURN, n2i[i].nonzero ? "non" : "");
-			continue;
+				"[should be %szero]", n2i[i].name, TEST_RETURN,
+				n2i[i].nonzero ? "non" : "");
+			return;
 		}
-		if (!TEST_RETURN) {
-			tst_resm(TPASS, "if_nametoindex(\"%s\") %ld",
-				 n2i[i].name, TEST_RETURN);
-			continue;
+		if (TEST_RETURN) {
+			pifn = if_indextoname(TEST_RETURN, ifname);
+			if (!pifn || strcmp(n2i[i].name, pifn)) {
+				tst_resm(TFAIL, "if_nametoindex(\"%s\") %ld "
+					"doesn't match if_indextoname(%ld) "
+					"\"%s\"", n2i[i].name, TEST_RETURN,
+					TEST_RETURN, pifn ? pifn : "");
+				return;
+			}
 		}
-
-		pifn = if_indextoname(TEST_RETURN, ifname);
-		if (!pifn || strcmp(n2i[i].name, pifn)) {
-			tst_resm(TFAIL, "if_nametoindex(\"%s\") %ld doesn't "
-				 "match if_indextoname(%ld) \"%s\"",
-				 n2i[i].name, TEST_RETURN, TEST_RETURN,
-				 pifn ? pifn : "");
-			continue;
-		}
-		tst_resm(TPASS, "if_nametoindex(\"%s\") %ld", n2i[i].name,
-			 TEST_RETURN);
+		tst_resm(TINFO, "if_nametoindex(\"%s\") %ld",
+			n2i[i].name, TEST_RETURN);
 	}
+
+	tst_resm(TPASS, "if_nametoindex() tests succeed");
 }
 
-int i2ntest1(unsigned int if_index)
+int sub_i2ntest(unsigned int if_index)
 {
 	char ifname[IF_NAMESIZE];
 	unsigned int idx;
@@ -147,7 +124,7 @@ int i2ntest1(unsigned int if_index)
 				 TEST_ERRNO);
 			return 0;
 		}
-		tst_resm(TPASS, "if_indextoname(%d) returns NULL", if_index);
+		tst_resm(TINFO, "if_indextoname(%d) returns NULL", if_index);
 		return 1;
 	}
 	/* else, a valid interface-- double check name */
@@ -158,29 +135,32 @@ int i2ntest1(unsigned int if_index)
 			 if_index, ifname, ifname, idx);
 		return 0;
 	}
-	tst_resm(TPASS, "if_indextoname(%d) returns \"%s\"", if_index, ifname);
+	tst_resm(TINFO, "if_indextoname(%d) returns \"%s\"", if_index, ifname);
 	return 1;
 }
 
+/* if_indextoname tests */
 void i2ntest(void)
 {
 	unsigned int i;
 
 	/* some low-numbered indexes-- likely to get valid interfaces here */
 	for (i = 0; i < I2N_LOWCOUNT; ++i)
-		if (!i2ntest1(i))
+		if (!sub_i2ntest(i))
 			return;	/* skip the rest, if broken */
 	/* some random ints; should mostly fail */
 	for (i = 0; i < I2N_RNDCOUNT; ++i)
-		if (!i2ntest1(rand()))
+		if (!sub_i2ntest(rand()))
 			return;	/* skip the rest, if broken */
+
+	tst_resm(TPASS, "if_indextoname() tests succeed");
 }
 
 /*
  * This is an ugly, linux-only solution. getrusage() doesn't support the
  * current data segment size, so we get it out of /proc
  */
-static int getdatasize(void)
+int getdatasize(void)
 {
 	char line[128], *p;
 	int dsize = -1;
@@ -203,29 +183,30 @@ static int getdatasize(void)
 	return dsize;
 }
 
+/* if_nameindex tests */
 void initest(void)
 {
-	int freenicount;
 	struct if_nameindex *pini;
-	int i, dsize_before, dsize_after;
+	int i;
+	char buf[IF_NAMESIZE], *p;
+	unsigned int idx;
+	int freenicount;
+	int dsize_before, dsize_after;
 
 	pini = if_nameindex();
-	if (pini == 0) {
+	if (pini == NULL) {
 		tst_resm(TFAIL, "if_nameindex() returns NULL, errno %d (%s)",
 			 TEST_ERRNO, strerror(TEST_ERRNO));
 		return;
 	}
 	for (i = 0; pini[i].if_index; ++i) {
-		char buf[IF_NAMESIZE], *p;
-		int idx;
-
 		p = if_indextoname(pini[i].if_index, buf);
 		if (!p || strcmp(p, pini[i].if_name)) {
 			tst_resm(TFAIL, "if_nameindex idx %d name \"%s\" but "
 				 "if_indextoname(%d) is \"%s\"",
 				 pini[i].if_index, pini[i].if_name,
 				 pini[i].if_index, p ? p : "");
-			continue;
+			return;
 		}
 		idx = if_nametoindex(pini[i].if_name);
 		if (idx != pini[i].if_index) {
@@ -233,9 +214,9 @@ void initest(void)
 				 "if_indextoname(\"%s\") is %d",
 				 pini[i].if_index, pini[i].if_name,
 				 pini[i].if_name, idx);
-			continue;
+			return;
 		}
-		tst_resm(TPASS, "if_nameindex idx %d name \"%s\"",
+		tst_resm(TINFO, "if_nameindex idx %d name \"%s\"",
 			 pini[i].if_index, pini[i].if_name);
 	}
 	if_freenameindex(pini);
@@ -245,9 +226,8 @@ void initest(void)
 	 */
 	dsize_before = getdatasize();
 	if (dsize_before < 0) {
-		tst_resm(TBROK, "getdatasize failed: errno %d (%s)", errno,
-			 strerror(errno));
-		return;
+		tst_brkm(TBROK, cleanup, "getdatasize failed: errno %d (%s)",
+			errno, strerror(errno));
 	}
 	/* we need to leak at least a page to detect a leak; 1 byte per call
 	 * will be detected with getpagesize() calls.
@@ -255,8 +235,8 @@ void initest(void)
 	freenicount = getpagesize();
 	for (i = 0; i < freenicount; ++i) {
 		pini = if_nameindex();
-		if (!pini) {
-			tst_resm(TFAIL, "if_freenameindex test failed "
+		if (pini == NULL) {
+			tst_resm(TINFO, "if_freenameindex test failed "
 				 "if_nameindex() iteration %d", i);
 			break;
 		}
@@ -264,25 +244,27 @@ void initest(void)
 	}
 	dsize_after = getdatasize();
 	if (dsize_after < 0) {
-		tst_resm(TBROK, "getdatasize failed: errno %d (%s)", errno,
-			 strerror(errno));
-		return;
+		tst_brkm(TBROK, cleanup, "getdatasize failed: errno %d (%s)",
+			errno, strerror(errno));
 	}
-	if (dsize_after > dsize_before + getpagesize())
+	if (dsize_after > dsize_before + getpagesize()) {
 		tst_resm(TFAIL, "if_freenameindex leaking memory "
 			 "(%d iterations) dsize before %d dsize after %d", i,
 			 dsize_before, dsize_after);
-	else
-		tst_resm(TPASS, "if_freenameindex passed %d iterations", i);
+		return;
+	} else {
+		tst_resm(TINFO, "if_freenameindex passed %d iterations", i);
+	}
+
+	tst_resm(TPASS, "if_nameindex() tests succeed");
 }
 
 void setup(void)
 {
-	TEST_PAUSE;		/* if -P option specified */
+	TEST_PAUSE;
 }
 
 void cleanup(void)
 {
 	TEST_CLEANUP;
-
 }
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH 7/7] ipv6_lib: add it into default
  2015-01-23  9:36 [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup Xing Gu
                   ` (4 preceding siblings ...)
  2015-01-23  9:36 ` [LTP] [PATCH 6/7] lib6/in6_02.c: cleanup Xing Gu
@ 2015-01-23  9:36 ` Xing Gu
  2015-02-27  8:16 ` [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup gux.fnst
  2015-03-05 10:42 ` Cyril Hrubis
  7 siblings, 0 replies; 9+ messages in thread
From: Xing Gu @ 2015-01-23  9:36 UTC (permalink / raw)
  To: ltp-list

* Add ipv6_lib tests to scenario_groups/default.

* Currently I'm not very clear about some test
  cases eg. asapi_04.c, so disable them. Later
  I will add it subsequently.

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
 runtest/ipv6_lib        | 8 ++++----
 scenario_groups/default | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/runtest/ipv6_lib b/runtest/ipv6_lib
index 75614fb..4b49cb5 100644
--- a/runtest/ipv6_lib
+++ b/runtest/ipv6_lib
@@ -1,11 +1,11 @@
 #DESCRIPTION:IPV6 related tests
 in6_01 in6_01
 in6_02 in6_02
-getaddrinfo_01 getaddrinfo_01
+#getaddrinfo_01 getaddrinfo_01
 asapi_01 asapi_01
 asapi_02 asapi_02
 asapi_03 asapi_03
-asapi_04 asapi_04
-asapi_05 asapi_05
-asapi_06 asapi_06
+#asapi_04 asapi_04
+#asapi_05 asapi_05
+#asapi_06 asapi_06
 asapi_07 asapi_07
diff --git a/scenario_groups/default b/scenario_groups/default
index 3a55702..60b1b27 100644
--- a/scenario_groups/default
+++ b/scenario_groups/default
@@ -32,3 +32,4 @@ dma_thread_diotest
 cpuacct
 can
 cpuhotplug
+ipv6_lib
-- 
1.9.3


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup
  2015-01-23  9:36 [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup Xing Gu
                   ` (5 preceding siblings ...)
  2015-01-23  9:36 ` [LTP] [PATCH 7/7] ipv6_lib: add it into default Xing Gu
@ 2015-02-27  8:16 ` gux.fnst
  2015-03-05 10:42 ` Cyril Hrubis
  7 siblings, 0 replies; 9+ messages in thread
From: gux.fnst @ 2015-02-27  8:16 UTC (permalink / raw)
  To: ltp-list

Ping. Thanks!

Regards,
Xing Gu

On 01/23/2015 05:36 PM, Xing Gu wrote:
> * Remove useless comments.
>
> * Modify the format of ftab[].
>
> * Move the test body from main() to do_test().
>
> Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
> ---
>   testcases/network/lib6/asapi_01.c | 438 ++++++++++++++++----------------------
>   1 file changed, 188 insertions(+), 250 deletions(-)
>
> diff --git a/testcases/network/lib6/asapi_01.c b/testcases/network/lib6/asapi_01.c
> index 8d1fed8..1de4c78 100644
> --- a/testcases/network/lib6/asapi_01.c
> +++ b/testcases/network/lib6/asapi_01.c
> @@ -1,6 +1,7 @@
>   /*
>    *
>    *   Copyright (c) International Business Machines  Corp., 2001
> + *   Author: David L Stevens
>    *
>    *   This program is free software;  you can redistribute it and/or modify
>    *   it under the terms of the GNU General Public License as published by
> @@ -13,26 +14,13 @@
>    *   the GNU General Public License for more details.
>    *
>    *   You should have received a copy of the GNU General Public License
> - *   along with this program;  if not, write to the Free Software
> - *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + *   along with this program;  if not, write to the Free Software Foundation,
> + *   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>    */
> -
>   /*
> - * Test Name: asapi_01
> - *
> - * Test Description:
> - *  These tests are for the "Advanced Sockets API" (RFC 3542)
> - *  Verify that in6 and sockaddr fields are present.
> - *
> - * Usage:  <for command-line>
> - *  asapi_01
> - *
> - * HISTORY
> - *	01/2005 written by David L Stevens
> - *
> - * RESTRICTIONS:
> - *  None.
> - *
> + *   Description:
> + *     These tests are for the "Advanced Sockets API" (RFC 3542)
> + *     Verify that in6 and sockaddr fields are present.
>    */
>
>   #include <stdio.h>
> @@ -47,13 +35,9 @@
>   #include "usctest.h"
>   #include "runcc.h"
>
> -char *TCID = "asapi_01";	/* Test program identifier.    */
> -
> -void setup(void), cleanup(void);
> -
>   enum ttype { EXISTS, ALIAS, VALUE };
>
> -struct ftent {
> +static struct ftent {
>   	char *ft_tname;		/* test name */
>   	int ft_type;		/* test type */
>   	char *ft_incl;		/* include file list */
> @@ -67,258 +51,212 @@ struct ftent {
>   #define ft_value	ftun.fu_value
>   #define ft_dname	ftun.fu_dname
>   } ftab[] = {
> -/* section 2.1 structure & field definitions */
> -	{
> -		"ip6_hdr un1_flow", EXISTS, IP6_H, "ip6_hdr",
> -		    "ip6_ctlun.ip6_un1.ip6_un1_flow", "0", {
> -	"4"}}, {
> -		"ip6_hdr ip6_flow", ALIAS, IP6_H, "ip6_hdr",
> -		    "ip6_ctlun.ip6_un1.ip6_un1_flow", NULL, {
> -	"ip6_flow"}}, {
> -		"ip6_hdr un1_plen", EXISTS, IP6_H, "ip6_hdr",
> -		    "ip6_ctlun.ip6_un1.ip6_un1_plen", "4", {
> -	"2"}}, {
> -		"ip6_hdr ip6_plen", ALIAS, IP6_H, "ip6_hdr",
> -		    "ip6_ctlun.ip6_un1.ip6_un1_plen", "4", {
> -	"ip6_plen"}}, {
> -		"ip6_hdr un1_nxt", EXISTS, IP6_H, "ip6_hdr",
> -		    "ip6_ctlun.ip6_un1.ip6_un1_nxt", "6", {
> -	"1"}}, {
> -		"ip6_hdr ip6_nxt", ALIAS, IP6_H, "ip6_hdr",
> -		    "ip6_ctlun.ip6_un1.ip6_un1_nxt", NULL, {
> -	"ip6_nxt"}}, {
> -		"ip6_hdr un1_hlim", EXISTS, IP6_H, "ip6_hdr",
> -		    "ip6_ctlun.ip6_un1.ip6_un1_hlim", "7", {
> -	"1"}}, {
> -		"ip6_hdr ip6_hlim", ALIAS, IP6_H, "ip6_hdr",
> -		    "ip6_ctlun.ip6_un1.ip6_un1_hlim", NULL, {
> -	"ip6_hlim"}}, {
> -		"ip6_hdr un1_vfc", EXISTS, IP6_H, "ip6_hdr",
> -		    "ip6_ctlun.ip6_un2_vfc", "0", {
> -	"1"}}, {
> -		"ip6_hdr ip6_src", EXISTS, IP6_H, "ip6_hdr", "ip6_src",
> -		    "sizeof(struct ip6_hdrctl)", {
> -	"sizeof(struct in6_addr)"}}, {
> -		"ip6_hdr ip6_dst", EXISTS, IP6_H, "ip6_hdr", "ip6_dst",
> -		    "(sizeof(struct ip6_hdrctl)+sizeof(struct in6_addr))", {
> -	"sizeof(struct in6_addr)"}},
> -/* section 2.2 structure and field definitions */
> -	{
> -		"IPPROTO_HOPOPTS", VALUE, IN_H, "IPPROTO_HOPOPTS", NULL, NULL, {
> -	"0"}}, {
> -		"IPPROTO_IPV6", VALUE, IN_H, "IPPROTO_IPV6", NULL, NULL, {
> -	"41"}}, {
> -		"IPPROTO_ROUTING", VALUE, IN_H, "IPPROTO_ROUTING", NULL, NULL, {
> -	"43"}}, {
> -		"IPPROTO_FRAGMENT", VALUE, IN_H, "IPPROTO_FRAGMENT", NULL, NULL, {
> -	"44"}}, {
> -		"IPPROTO_ESP", VALUE, IN_H, "IPPROTO_ESP", NULL, NULL, {
> -	"50"}}, {
> -		"IPPROTO_AH", VALUE, IN_H, "IPPROTO_AH", NULL, NULL, {
> -	"51"}}, {
> -		"IPPROTO_ICMPV6", VALUE, IN_H, "IPPROTO_ICMPV6", NULL, NULL, {
> -	"58"}}, {
> -		"IPPROTO_NONE", VALUE, IN_H, "IPPROTO_NONE", NULL, NULL, {
> -	"59"}}, {
> -		"IPPROTO_DSTOPTS", VALUE, IN_H, "IPPROTO_DSTOPTS", NULL, NULL, {
> -	"60"}},
> -/* ip6_hbh */
> -	{
> -		"ip6_hbh ip6h_nxt", EXISTS, IP6_H, "ip6_hbh", "ip6h_nxt", "0", {
> -	"1"}}, {
> -		"ip6_hbh ip6h_nxt", EXISTS, IP6_H, "ip6_hbh", "ip6h_len", "1", {
> -	"1"}},
> -/* ip6_dest */
> -	{
> -		"ip6_dest ip6d_nxt", EXISTS, IP6_H, "ip6_dest", "ip6d_nxt", "0", {
> -	"1"}}, {
> -		"ip6_dest ip6d_nxt", EXISTS, IP6_H, "ip6_dest", "ip6d_len", "1", {
> -	"1"}},
> -/* ip6_rthdr0 */
> -	{
> -		"ip6_rthdr0 ip6r0_nxt", EXISTS, IP6_H, "ip6_rthdr0",
> -		    "ip6r0_nxt", "0", {
> -	"1"}}, {
> -		"ip6_rthdr0 ip6r0_len", EXISTS, IP6_H, "ip6_rthdr0",
> -		    "ip6r0_len", "1", {
> -	"1"}}, {
> -		"ip6_rthdr0 ip6r0_type", EXISTS, IP6_H, "ip6_rthdr0",
> -		    "ip6r0_type", "2", {
> -	"1"}}, {
> -		"ip6_rthdr0 ip6r0_segleft", EXISTS, IP6_H, "ip6_rthdr0",
> -		    "ip6r0_segleft", "3", {
> -	"1"}}, {
> -		"ip6_rthdr0 ip6r0_reserved", EXISTS, IP6_H, "ip6_rthdr0",
> -		    "ip6r0_reserved", "4", {
> -	"1"}},
> -/* ip6_frag */
> -	{
> -		"ip6_frag ip6f_nxt", EXISTS, IP6_H, "ip6_frag", "ip6f_nxt", "0", {
> -	"1"}}, {
> -		"ip6_frag ip6f_reserved", EXISTS, IP6_H, "ip6_frag",
> -		    "ip6f_reserved", "1", {
> -	"1"}}, {
> -		"ip6_frag ip6f_offlg", EXISTS, IP6_H, "ip6_frag",
> -		    "ip6f_offlg", "2", {
> -	"2"}}, {
> -		"ip6_frag ip6f_ident", EXISTS, IP6_H, "ip6_frag",
> -		    "ip6f_ident", "4", {
> -	"4"}}, {
> -		"IP6F_OFF_MASK", VALUE, IP6_H, "IP6F_OFF_MASK", NULL, NULL, {
> -	"htons(0xfff8)"}}, {
> -		"IP6F_RESERVED_MASK", VALUE, IP6_H, "IP6F_RESERVED_MASK",
> -		    NULL, NULL, {
> -	"htons(0x0006)"}}, {
> -		"IP6F_MORE_FRAG", VALUE, IP6_H, "IP6F_MORE_FRAG", NULL, NULL, {
> -	"htons(0x0001)"}}, {
> -		"IP6OPT_TYPE", VALUE, IP6_H, "IP6OPT_TYPE(0xff)", NULL, NULL, {
> -	"0xc0"}}, {
> -		"IP6OPT_TYPE_SKIP", VALUE, IP6_H, "IP6OPT_TYPE_SKIP",
> -		    NULL, NULL, {
> -	"0x00"}}, {
> -		"IP6OPT_TYPE_DISCARD", VALUE, IP6_H, "IP6OPT_TYPE_DISCARD",
> -		    NULL, NULL, {
> -	"0x40"}}, {
> -		"IP6OPT_TYPE_FORCEICMP", VALUE, IP6_H, "IP6OPT_TYPE_FORCEICMP",
> -		    NULL, NULL, {
> -	"0x80"}}, {
> -		"IP6OPT_TYPE_ICMP", VALUE, IP6_H, "IP6OPT_TYPE_ICMP",
> -		    NULL, NULL, {
> -	"0xc0"}}, {
> -		"IP6OPT_TYPE_MUTABLE", VALUE, IP6_H, "IP6OPT_TYPE_MUTABLE",
> -		    NULL, NULL, {
> -	"0x20"}}, {
> -		"IP6OPT_PAD1", VALUE, IP6_H, "IP6OPT_PAD1", NULL, NULL, {
> -	"0x00"}}, {
> -		"IP6OPT_PADN", VALUE, IP6_H, "IP6OPT_PADN", NULL, NULL, {
> -	"0x01"}}, {
> -		"IP6OPT_JUMBO", VALUE, IP6_H, "IP6OPT_JUMBO", NULL, NULL, {
> -	"0xc2"}}, {
> -		"IP6OPT_NSAP_ADDR", VALUE, IP6_H, "IP6OPT_NSAP_ADDR",
> -		    NULL, NULL, {
> -	"0xc3"}}, {
> -		"IP6OPT_TUNNEL_LIMIT", VALUE, IP6_H, "IP6OPT_TUNNEL_LIMIT",
> -		    NULL, NULL, {
> -	"0x04"}}, {
> -		"IP6OPT_ROUTER_ALERT", VALUE, IP6_H, "IP6OPT_ROUTER_ALERT",
> -		    NULL, NULL, {
> -	"0x05"}},
> -/* ip6_opt_jumbo */
> -	{
> -		"ip6_opt_jumbo ip6oj_type", EXISTS, IP6_H, "ip6_opt_jumbo",
> -		    "ip6oj_type", "0", {
> -	"1"}}, {
> -		"ip6_opt_jumbo ip6oj_len", EXISTS, IP6_H, "ip6_opt_jumbo",
> -		    "ip6oj_len", "1", {
> -	"1"}}, {
> -		"ip6_opt_jumbo ip6oj_jumbo_len element", EXISTS, IP6_H,
> -		    "ip6_opt_jumbo", "ip6oj_jumbo_len[0]", "2", {
> -	"1"}}, {
> -		"ip6_opt_jumbo ip6oj_jumbo_len array", EXISTS, IP6_H,
> -		    "ip6_opt_jumbo", "ip6oj_jumbo_len", "2", {
> -	"4"}},
> -/* ip6_opt_nsap */
> -	{
> -		"ip6_opt_nsap ip6on_type", EXISTS, IP6_H, "ip6_opt_nsap",
> -		    "ip6on_type", "0", {
> -	"1"}}, {
> -		"ip6_opt_nsap ip6on_len", EXISTS, IP6_H, "ip6_opt_nsap",
> -		    "ip6on_len", "1", {
> -	"1"}}, {
> -		"ip6_opt_nsap ip6on_src_nsap_len", EXISTS, IP6_H,
> -		    "ip6_opt_nsap", "ip6on_src_nsap_len", "2", {
> -	"1"}}, {
> -		"ip6_opt_nsap ip6on_dst_nsap_len", EXISTS, IP6_H,
> -		    "ip6_opt_nsap", "ip6on_dst_nsap_len", "3", {
> -	"1"}},
> -/* ip6_opt_tunnel */
> -	{
> -		"ip6_opt_tunnel ip6ot_type", EXISTS, IP6_H, "ip6_opt_tunnel",
> -		    "ip6ot_type", "0", {
> -	"1"}}, {
> -		"ip6_opt_tunnel ip6ot_len", EXISTS, IP6_H, "ip6_opt_tunnel",
> -		    "ip6ot_len", "1", {
> -	"1"}}, {
> -		"ip6_opt_tunnel ip6ot_encap_limit", EXISTS, IP6_H,
> -		    "ip6_opt_tunnel", "ip6ot_encap_limit", "2", {
> -	"1"}},
> -/* ip6_opt_router */
> -	{
> -		"ip6_opt_router ip6or_type", EXISTS, IP6_H, "ip6_opt_router",
> -		    "ip6or_type", "0", {
> -	"1"}}, {
> -		"ip6_opt_router ip6or_len", EXISTS, IP6_H, "ip6_opt_router",
> -		    "ip6or_len", "1", {
> -	"1"}}, {
> -		"ip6_opt_router ip6or_value element", EXISTS, IP6_H,
> -		    "ip6_opt_router", "ip6or_value[0]", "2", {
> -	"1"}}, {
> -		"ip6_opt_router ip6or_value array", EXISTS, IP6_H,
> -		    "ip6_opt_router", "ip6or_value", "2", {
> -	"2"}},
> -/* IP6_ALERT_* definitions */
> -	{
> -		"IP6_ALERT_MLD", VALUE, IP6_H, "IP6_ALERT_MLD", NULL, NULL, {
> -	"0"}}, {
> -		"IP6_ALERT_RSVP", VALUE, IP6_H, "IP6_ALERT_RSVP", NULL, NULL, {
> -	"htons(1)"}}, {
> -		"IP6_ALERT_AN", VALUE, IP6_H, "IP6_ALERT_AN", NULL, NULL, {
> -"htons(2)"}},};
> +	/* section 2.1 structure & field definitions */
> +	{ "ip6_hdr un1_flow", EXISTS, IP6_H, "ip6_hdr",
> +		"ip6_ctlun.ip6_un1.ip6_un1_flow", "0", {"4"} },
> +	{ "ip6_hdr ip6_flow", ALIAS, IP6_H, "ip6_hdr",
> +		"ip6_ctlun.ip6_un1.ip6_un1_flow", NULL, {"ip6_flow"} },
> +	{ "ip6_hdr un1_plen", EXISTS, IP6_H, "ip6_hdr",
> +		"ip6_ctlun.ip6_un1.ip6_un1_plen", "4", {"2"} },
> +	{ "ip6_hdr ip6_plen", ALIAS, IP6_H, "ip6_hdr",
> +		"ip6_ctlun.ip6_un1.ip6_un1_plen", "4", {"ip6_plen"} },
> +	{ "ip6_hdr un1_nxt", EXISTS, IP6_H, "ip6_hdr",
> +		"ip6_ctlun.ip6_un1.ip6_un1_nxt", "6", {"1"} },
> +	{ "ip6_hdr ip6_nxt", ALIAS, IP6_H, "ip6_hdr",
> +		"ip6_ctlun.ip6_un1.ip6_un1_nxt", NULL, {"ip6_nxt"} },
> +	{ "ip6_hdr un1_hlim", EXISTS, IP6_H, "ip6_hdr",
> +		"ip6_ctlun.ip6_un1.ip6_un1_hlim", "7", {"1"} },
> +	{ "ip6_hdr ip6_hlim", ALIAS, IP6_H, "ip6_hdr",
> +		"ip6_ctlun.ip6_un1.ip6_un1_hlim", NULL, {"ip6_hlim"} },
> +	{ "ip6_hdr un1_vfc", EXISTS, IP6_H, "ip6_hdr",
> +		"ip6_ctlun.ip6_un2_vfc", "0", {"1"} },
> +	{ "ip6_hdr ip6_src", EXISTS, IP6_H, "ip6_hdr",
> +		"ip6_src", "sizeof(struct ip6_hdrctl)",
> +		{"sizeof(struct in6_addr)"} },
> +	{ "ip6_hdr ip6_dst", EXISTS, IP6_H, "ip6_hdr", "ip6_dst",
> +		"(sizeof(struct ip6_hdrctl)+sizeof(struct in6_addr))",
> +		{"sizeof(struct in6_addr)"} },
> +	/* section 2.2 structure and field definitions */
> +	{ "IPPROTO_HOPOPTS", VALUE, IN_H, "IPPROTO_HOPOPTS",
> +		NULL, NULL, {"0"} },
> +	{ "IPPROTO_IPV6", VALUE, IN_H, "IPPROTO_IPV6",
> +		NULL, NULL, {"41"} },
> +	{ "IPPROTO_ROUTING", VALUE, IN_H, "IPPROTO_ROUTING",
> +		NULL, NULL, {"43"} },
> +	{ "IPPROTO_FRAGMENT", VALUE, IN_H, "IPPROTO_FRAGMENT",
> +		NULL, NULL, {"44"} },
> +	{ "IPPROTO_ESP", VALUE, IN_H, "IPPROTO_ESP",
> +		NULL, NULL, {"50"} },
> +	{ "IPPROTO_AH", VALUE, IN_H, "IPPROTO_AH",
> +		NULL, NULL, {"51"} },
> +	{ "IPPROTO_ICMPV6", VALUE, IN_H, "IPPROTO_ICMPV6",
> +		NULL, NULL, {"58"} },
> +	{ "IPPROTO_NONE", VALUE, IN_H, "IPPROTO_NONE",
> +		NULL, NULL, {"59"} },
> +	{ "IPPROTO_DSTOPTS", VALUE, IN_H, "IPPROTO_DSTOPTS",
> +		NULL, NULL, {"60"} },
> +	/* ip6_hbh */
> +	{ "ip6_hbh ip6h_nxt", EXISTS, IP6_H, "ip6_hbh",
> +		"ip6h_nxt", "0", {"1"} },
> +	{ "ip6_hbh ip6h_nxt", EXISTS, IP6_H, "ip6_hbh",
> +		"ip6h_len", "1", {"1"} },
> +	/* ip6_dest */
> +	{ "ip6_dest ip6d_nxt", EXISTS, IP6_H, "ip6_dest",
> +		"ip6d_nxt", "0", {"1"} },
> +	{ "ip6_dest ip6d_nxt", EXISTS, IP6_H, "ip6_dest",
> +		"ip6d_len", "1", {"1"} },
> +	/* ip6_rthdr0 */
> +	{ "ip6_rthdr0 ip6r0_nxt", EXISTS, IP6_H, "ip6_rthdr0",
> +		"ip6r0_nxt", "0", {"1"} },
> +	{ "ip6_rthdr0 ip6r0_len", EXISTS, IP6_H, "ip6_rthdr0",
> +		"ip6r0_len", "1", {"1"} },
> +	{ "ip6_rthdr0 ip6r0_type", EXISTS, IP6_H, "ip6_rthdr0",
> +		"ip6r0_type", "2", {"1"} },
> +	{ "ip6_rthdr0 ip6r0_segleft", EXISTS, IP6_H, "ip6_rthdr0",
> +		"ip6r0_segleft", "3", {"1"} },
> +	{ "ip6_rthdr0 ip6r0_reserved", EXISTS, IP6_H, "ip6_rthdr0",
> +		"ip6r0_reserved", "4", {"1"} },
> +	/* ip6_frag */
> +	{ "ip6_frag ip6f_nxt", EXISTS, IP6_H, "ip6_frag",
> +		"ip6f_nxt", "0", {"1"} },
> +	{ "ip6_frag ip6f_reserved", EXISTS, IP6_H, "ip6_frag",
> +		"ip6f_reserved", "1", {"1"} },
> +	{ "ip6_frag ip6f_offlg", EXISTS, IP6_H, "ip6_frag",
> +		"ip6f_offlg", "2", {"2"} },
> +	{ "ip6_frag ip6f_ident", EXISTS, IP6_H, "ip6_frag",
> +		"ip6f_ident", "4", {"4"} },
> +	{ "IP6F_OFF_MASK", VALUE, IP6_H, "IP6F_OFF_MASK",
> +		NULL, NULL, {"htons(0xfff8)"} },
> +	{ "IP6F_RESERVED_MASK", VALUE, IP6_H, "IP6F_RESERVED_MASK",
> +		NULL, NULL, {"htons(0x0006)"} },
> +	{ "IP6F_MORE_FRAG", VALUE, IP6_H, "IP6F_MORE_FRAG",
> +		NULL, NULL, {"htons(0x0001)"} },
> +	{ "IP6OPT_TYPE", VALUE, IP6_H, "IP6OPT_TYPE(0xff)",
> +		NULL, NULL, {"0xc0"} },
> +	{ "IP6OPT_TYPE_SKIP", VALUE, IP6_H, "IP6OPT_TYPE_SKIP",
> +		NULL, NULL, {"0x00"} },
> +	{ "IP6OPT_TYPE_DISCARD", VALUE, IP6_H, "IP6OPT_TYPE_DISCARD",
> +		NULL, NULL, {"0x40"} },
> +	{ "IP6OPT_TYPE_FORCEICMP", VALUE, IP6_H, "IP6OPT_TYPE_FORCEICMP",
> +		NULL, NULL, {"0x80"} },
> +	{ "IP6OPT_TYPE_ICMP", VALUE, IP6_H, "IP6OPT_TYPE_ICMP",
> +		NULL, NULL, {"0xc0"} },
> +	{ "IP6OPT_TYPE_MUTABLE", VALUE, IP6_H, "IP6OPT_TYPE_MUTABLE",
> +		NULL, NULL, {"0x20"} },
> +	{ "IP6OPT_PAD1", VALUE, IP6_H, "IP6OPT_PAD1",
> +		NULL, NULL, {"0x00"} },
> +	{ "IP6OPT_PADN", VALUE, IP6_H, "IP6OPT_PADN",
> +		NULL, NULL, {"0x01"} },
> +	{ "IP6OPT_JUMBO", VALUE, IP6_H, "IP6OPT_JUMBO",
> +		NULL, NULL, {"0xc2"} },
> +	{ "IP6OPT_NSAP_ADDR", VALUE, IP6_H, "IP6OPT_NSAP_ADDR",
> +		NULL, NULL, {"0xc3"} },
> +	{ "IP6OPT_TUNNEL_LIMIT", VALUE, IP6_H, "IP6OPT_TUNNEL_LIMIT",
> +		NULL, NULL, {"0x04"} },
> +	{ "IP6OPT_ROUTER_ALERT", VALUE, IP6_H, "IP6OPT_ROUTER_ALERT",
> +		NULL, NULL, {"0x05"} },
> +	/* ip6_opt_jumbo */
> +	{ "ip6_opt_jumbo ip6oj_type", EXISTS, IP6_H, "ip6_opt_jumbo",
> +		"ip6oj_type", "0", {"1"} },
> +	{ "ip6_opt_jumbo ip6oj_len", EXISTS, IP6_H, "ip6_opt_jumbo",
> +		"ip6oj_len", "1", {"1"} },
> +	{ "ip6_opt_jumbo ip6oj_jumbo_len element", EXISTS, IP6_H,
> +		"ip6_opt_jumbo", "ip6oj_jumbo_len[0]", "2", {"1"} },
> +	{ "ip6_opt_jumbo ip6oj_jumbo_len array", EXISTS, IP6_H,
> +		"ip6_opt_jumbo", "ip6oj_jumbo_len", "2", {"4"} },
> +	/* ip6_opt_nsap */
> +	{ "ip6_opt_nsap ip6on_type", EXISTS, IP6_H, "ip6_opt_nsap",
> +		"ip6on_type", "0", {"1"} },
> +	{ "ip6_opt_nsap ip6on_len", EXISTS, IP6_H, "ip6_opt_nsap",
> +		"ip6on_len", "1", {"1"} },
> +	{ "ip6_opt_nsap ip6on_src_nsap_len", EXISTS, IP6_H,
> +		"ip6_opt_nsap", "ip6on_src_nsap_len", "2", {"1"} },
> +	{ "ip6_opt_nsap ip6on_dst_nsap_len", EXISTS, IP6_H,
> +		"ip6_opt_nsap", "ip6on_dst_nsap_len", "3", {"1"} },
> +	/* ip6_opt_tunnel */
> +	{ "ip6_opt_tunnel ip6ot_type", EXISTS, IP6_H,
> +		"ip6_opt_tunnel", "ip6ot_type", "0", {"1"} },
> +	{ "ip6_opt_tunnel ip6ot_len", EXISTS, IP6_H,
> +		"ip6_opt_tunnel", "ip6ot_len", "1", {"1"} },
> +	{ "ip6_opt_tunnel ip6ot_encap_limit", EXISTS, IP6_H,
> +		"ip6_opt_tunnel", "ip6ot_encap_limit", "2", {"1"} },
> +	/* ip6_opt_router */
> +	{ "ip6_opt_router ip6or_type", EXISTS, IP6_H,
> +		"ip6_opt_router", "ip6or_type", "0", {"1"} },
> +	{ "ip6_opt_router ip6or_len", EXISTS, IP6_H,
> +		"ip6_opt_router", "ip6or_len", "1", {"1"} },
> +	{ "ip6_opt_router ip6or_value element", EXISTS, IP6_H,
> +		"ip6_opt_router", "ip6or_value[0]", "2", {"1"} },
> +	{ "ip6_opt_router ip6or_value array", EXISTS, IP6_H,
> +		"ip6_opt_router", "ip6or_value", "2", {"2"} },
> +	/* IP6_ALERT_* definitions */
> +	{ "IP6_ALERT_MLD", VALUE, IP6_H, "IP6_ALERT_MLD",
> +		NULL, NULL, {"0"} },
> +	{ "IP6_ALERT_RSVP", VALUE, IP6_H, "IP6_ALERT_RSVP",
> +		NULL, NULL, {"htons(1)"} },
> +	{ "IP6_ALERT_AN", VALUE, IP6_H, "IP6_ALERT_AN",
> +		NULL, NULL, {"htons(2)"} },
> +};
>
> -#define FTCOUNT	(sizeof(ftab)/sizeof(ftab[0]))
> +static void setup(void);
> +static void cleanup(void);
> +static void do_test(const struct ftent *);
>
> -int TST_TOTAL = FTCOUNT;
> +char *TCID = "asapi_01";
> +int TST_TOTAL = ARRAY_SIZE(ftab);
>
>   int main(int argc, char *argv[])
>   {
>   	int i, lc;
>   	const char *msg;
>
> -	/* Parse standard options given to run the test. */
>   	msg = parse_opts(argc, argv, NULL, NULL);
> -	if (msg != NULL) {
> +	if (msg != NULL)
>   		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
> -	}
>
>   	setup();
>
>   	for (lc = 0; TEST_LOOPING(lc); ++lc) {
> -		for (i = 0; i < FTCOUNT; ++i) {
> -			switch (ftab[i].ft_type) {
> -			case EXISTS:
> -				structcheck(ftab[i].ft_tname, ftab[i].ft_incl,
> -					    ftab[i].ft_struct, ftab[i].ft_field,
> -					    ftab[i].ft_offset,
> -					    ftab[i].ft_value);
> -				break;
> -			case ALIAS:
> -				aliascheck(ftab[i].ft_tname, ftab[i].ft_incl,
> -					   ftab[i].ft_struct, ftab[i].ft_field,
> -					   ftab[i].ft_dname);
> -				break;
> -			case VALUE:
> -				valuecheck(ftab[i].ft_tname, ftab[i].ft_incl,
> -					   ftab[i].ft_struct, ftab[i].ft_dname);
> -				break;
> -			default:
> -				tst_resm(TBROK, "invalid type %d",
> -					 ftab[i].ft_type);
> -				break;
> -			}
> -		}
> +		tst_count = 0;
> +
> +		for (i = 0; i < TST_TOTAL; i++)
> +			do_test(&ftab[i]);
>   	}
>
>   	cleanup();
> -
>   	tst_exit();
>   }
>
>   void setup(void)
>   {
> -	TEST_PAUSE;		/* if -P option specified */
> +	TEST_PAUSE;
>   }
>
>   void cleanup(void)
>   {
>   	TEST_CLEANUP;
>   }
> +
> +void do_test(const struct ftent *ftptr)
> +{
> +	switch (ftptr->ft_type) {
> +	case EXISTS:
> +		structcheck(ftptr->ft_tname, ftptr->ft_incl,
> +			ftptr->ft_struct, ftptr->ft_field,
> +			ftptr->ft_offset, ftptr->ft_value);
> +		break;
> +	case ALIAS:
> +		aliascheck(ftptr->ft_tname, ftptr->ft_incl,
> +			ftptr->ft_struct, ftptr->ft_field,
> +			ftptr->ft_dname);
> +		break;
> +	case VALUE:
> +		valuecheck(ftptr->ft_tname, ftptr->ft_incl,
> +			ftptr->ft_struct, ftptr->ft_dname);
> +		break;
> +	default:
> +		tst_resm(TBROK, "invalid type %d",
> +			ftptr->ft_type);
> +		break;
> +	}
> +}
>

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup
  2015-01-23  9:36 [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup Xing Gu
                   ` (6 preceding siblings ...)
  2015-02-27  8:16 ` [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup gux.fnst
@ 2015-03-05 10:42 ` Cyril Hrubis
  7 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2015-03-05 10:42 UTC (permalink / raw)
  To: Xing Gu; +Cc: ltp-list

Hi!
>  void cleanup(void)
>  {
>  	TEST_CLEANUP;
>  }

The TEST_CLEANUP has been removed from LTP. In case the only thing that
cleanp() did was TEST_CLEANUP the cleanup() function should be removed
as well. Can you plase update the patches and resend?

Otherwise it looks fine.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-03-05 10:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-23  9:36 [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup Xing Gu
2015-01-23  9:36 ` [LTP] [PATCH 2/7] lib6/asapi_02.c: cleanup Xing Gu
2015-01-23  9:36 ` [LTP] [PATCH 3/7] lib6/asapi_03.c: cleanup Xing Gu
2015-01-23  9:36 ` [LTP] [PATCH 4/7] lib6/asapi_07.c: cleanup Xing Gu
2015-01-23  9:36 ` [LTP] [PATCH 5/7] lib6/in6_01.c: cleanup Xing Gu
2015-01-23  9:36 ` [LTP] [PATCH 6/7] lib6/in6_02.c: cleanup Xing Gu
2015-01-23  9:36 ` [LTP] [PATCH 7/7] ipv6_lib: add it into default Xing Gu
2015-02-27  8:16 ` [LTP] [PATCH 1/7] lib6/asapi_01.c: cleanup gux.fnst
2015-03-05 10:42 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.