commit 84b4fca14e67517a14e936d261588b741d3e21d3
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Thu May 3 11:23:56 2012 +0200
multicast: Adding max_groups testcase
This commit introduces test case for testing/discovering the
maximum allowed multicast groups that host can join. The
test is single host, offline.
* test setup: max_groups.c
* cmd sequence: max_groups.xml
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
.../cmd_sequences/multicast/max_groups.xml | 25 +++++++++
test_tools/multicast/Makefile | 2 +-
test_tools/multicast/offline/max_groups.c | 58 ++++++++++++++++++++
3 files changed, 84 insertions(+), 1 deletions(-)
---
diff --git a/example_recipes/cmd_sequences/multicast/max_groups.xml
b/example_recipes/cmd_sequences/multicast/max_groups.xml
new file mode 100644
index 0000000..2141678
--- /dev/null
+++ b/example_recipes/cmd_sequences/multicast/max_groups.xml
@@ -0,0 +1,25 @@
+<!-- Offline maximum number of groups test -->
+<!-- Requires: 1 host with one interface -->
+
+<command_sequence>
+ <!-- With a specific interface -->
+ <command type="test" value="Multicast"
machine_id="1" timeout="30">
+ <options>
+ <option name="setup" value="max_groups" />
+ <option name="interface" value="{$host1if1}" />
+ <option name="condition" value="max_groups > 0"
/>
+ </options>
+ </command>
+
+ <!-- Change default max_memberhsips -->
+ <command type="exec" value="echo '5' >
/proc/sys/net/ipv4/igmp_max_memberships" machine_id="1" />
+ <command type="test" value="Multicast"
machine_id="1" timeout="30">
+ <options>
+ <option name="setup" value="max_groups" />
+ <option type="recipe_eval" name="interface"
value="['machines'][1]['netconfig'][1]['addresses'][0]"
/>
+ <option name="condition" value="max_groups == 5"
/>
+ </options>
+ </command>
+ <command type="exec" value="echo '20' >
/proc/sys/net/ipv4/igmp_max_memberships" machine_id="1" />
+
+</command_sequence>
diff --git a/test_tools/multicast/Makefile b/test_tools/multicast/Makefile
index 00fb179..e09746c 100644
--- a/test_tools/multicast/Makefile
+++ b/test_tools/multicast/Makefile
@@ -4,7 +4,7 @@ CFLAGS=-Wall -Wextra -I$(TOOLS_DIR)
SENDERS=send_simple
RECEIVERS=recv_simple recv_membership recv_source_membership recv_block_source
-OFFLINE=sockopt_loop sockopt_ttl sockopt_if sockopt_membership sockopt_source_membership
sockopt_block_source
+OFFLINE=sockopt_loop sockopt_ttl sockopt_if sockopt_membership sockopt_source_membership
sockopt_block_source max_groups
all: $(SENDERS) $(RECEIVERS) $(OFFLINE)
diff --git a/test_tools/multicast/offline/max_groups.c
b/test_tools/multicast/offline/max_groups.c
new file mode 100644
index 0000000..d7cbfc2
--- /dev/null
+++ b/test_tools/multicast/offline/max_groups.c
@@ -0,0 +1,58 @@
+/*
+ * max_groups.c - discover the limit of maximum allowed groups
+ * Copyright (C) 2012 Red Hat Inc.
+ *
+ * Author: Radek Pazdera (rpazdera(a)redhat.com)
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#define RECEIVE
+#include "multicast_utils.h"
+
+int main(int argc, char** argv)
+{
+ struct parameters params;
+ parse_args(argc, argv, ¶ms);
+
+ int sockfd = init_in_socket(params.multiaddr, params.port);
+
+ struct ip_mreq mreq;
+ struct in_addr multiaddr;
+ int groups = 0;
+ multiaddr.s_addr = 0xe1000001;
+ mreq.imr_interface = params.interface;
+
+ do {
+ mreq.imr_multiaddr.s_addr = htonl(multiaddr.s_addr);
+ if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
+ &(mreq), sizeof(mreq)) < 0) {
+ if (errno == ENOBUFS)
+ break;
+
+ perror("setsockopt");
+ return EXIT_FAILURE;
+ }
+
+ multiaddr.s_addr++;
+ groups++;
+ } while(1);
+
+
+ printf("max_groups=%d\n", groups);
+
+ return EXIT_SUCCESS;
+}
Show replies by date