Hi Rusty,
I found that you wrote a test program to verify whether all the valid
IFF flags are implemented by TUNGETFEATURES ioctl (recently in 2.6.27:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=07240fd0902c872f044f523893364a1a24c9f278).
I ported the same into LTP format and created the first draft version.
Yet to test it on the latest kernel, but the first draft works fine. If
you do not have any issue(s), can we add this code to LTP with your
permission ??
Signed-Off-By: Subrata Modak <[EMAIL PROTECTED]>,
Signed-Off-By: Rusty Russell <[EMAIL PROTECTED]>,
--
diff -uprN
ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl.orig/ioctl03.c
ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl/ioctl03.c
---
ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl.orig/ioctl03.c
1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl/ioctl03.c
2008-11-28 15:23:58.000000000 +0530
@@ -0,0 +1,157 @@
+/******************************************************************************/
+/*
*/
+/* Copyright (c) Rusty Russell <[EMAIL PROTECTED]>
*/
+/* Copyright (c) International Business Machines Corp., 2008
*/
+/*
*/
+/* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA */
+/*
*/
+/******************************************************************************/
+/******************************************************************************/
+/*
*/
+/* File: ioctl03.c
*/
+/*
*/
+/* Description: This program tests whether all the valid IFF flags are
*/
+/* returned properly by implementation of TUNGETFEATURES
ioctl */
+/* on kernel 2.6.27
*/
+/*
*/
+/* Total Tests: 1
*/
+/*
*/
+/* Test Name: ioctl03
*/
+/*
*/
+/* Author: Rusty Russell <[EMAIL PROTECTED]>
*/
+/*
*/
+/* History: Created - Nov 28 2008 - Rusty Russell
<[EMAIL PROTECTED]> */
+/* Ported to LTP
*/
+/* - Nov 28 2008 - Subrata
<[EMAIL PROTECTED]> */
+/******************************************************************************/
+
+#include <linux/if_tun.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+
+#ifndef TUNGETFEATURES
+#define TUNGETFEATURES _IOR('T', 207, unsigned int)
+#endif
+
+/* Extern Global Variables */
+extern int Tst_count; /* counter for tst_xxx routines.
*/
+extern char *TESTDIR; /* temporary dir created by
tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "ioctl03"; /* test program identifier. */
+int TST_TOTAL = 1; /* total number of tests in this
file. */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*
*/
+/* Function: cleanup
*/
+/*
*/
+/* Description: Performs all one time clean up for this test on
successful */
+/* completion, premature exit or failure. Closes all
temporary */
+/* files, removes all temporary directories exits the test
with */
+/* appropriate return code by calling tst_exit() function.
*/
+/*
*/
+/* Input: None.
*/
+/*
*/
+/* Output: None.
*/
+/*
*/
+/* Return: On failure - Exits calling tst_exit(). Non '0' return
code. */
+/* On success - Exits calling tst_exit(). With '0' return
code. */
+/*
*/
+/******************************************************************************/
+extern void cleanup() {
+ /* Remove tmp dir and all files in it */
+ TEST_CLEANUP;
+ tst_rmdir();
+
+ /* Exit with appropriate return code. */
+ tst_exit();
+}
+
+
+/* Local Functions */
+/******************************************************************************/
+/*
*/
+/* Function: setup
*/
+/*
*/
+/* Description: Performs all one time setup for this test. This
function is */
+/* typically used to capture signals, create temporary
dirs */
+/* and temporary files that may be used in the course of
this */
+/* test.
*/
+/*
*/
+/* Input: None.
*/
+/*
*/
+/* Output: None.
*/
+/*
*/
+/* Return: On failure - Exits by calling cleanup().
*/
+/* On success - returns 0.
*/
+/*
*/
+/******************************************************************************/
+void setup() {
+ /* Capture signals if any */
+ /* Create temporary directories */
+ TEST_PAUSE;
+ tst_tmpdir();
+}
+
+
+static struct {
+ unsigned int flag;
+ const char *name;
+} known_flags[] = {
+ { IFF_TUN, "TUN" },
+ { IFF_TAP, "TAP" },
+ { IFF_NO_PI, "NO_PI" },
+ { IFF_ONE_QUEUE, "ONE_QUEUE" },
+ };
+
+int main() {
+ unsigned int features, i;
+
+ setup();
+ if (geteuid()!=0) {
+ tst_brkm(TBROK, cleanup, "You need to be ROOT to run this test
case");
+ tst_exit();
+ }
+ int netfd = open("/dev/net/tun", O_RDWR);
+ if (netfd < 0)
+ tst_brkm(TBROK, cleanup, "Error Opening /dev/net/tun: %s",
strerror(errno));
+
+ if (ioctl(netfd, TUNGETFEATURES, &features) != 0) {
+ tst_resm(TCONF, "Kernel does not support TUNGETFEATURES");
+ features = (IFF_TUN|IFF_TAP|IFF_NO_PI|IFF_ONE_QUEUE);
+ cleanup();
+ tst_exit();
+ }
+ tst_resm(TINFO,"Available features are: ");
+ for (i = 0; i < sizeof(known_flags)/sizeof(known_flags[0]); i++) {
+ if (features & known_flags[i].flag) {
+ features &= ~known_flags[i].flag;
+ tst_resm(TCONF, "%s ", known_flags[i].name);
+ }
+ }
+ if (features)
+ tst_resm(TFAIL, "(UNKNOWN %#x)", features);
+ cleanup();
+ tst_exit();
+}
diff -uprN
ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl.orig/test_ioctl
ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl/test_ioctl
---
ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl.orig/test_ioctl
2008-11-28 14:01:11.000000000 +0530
+++ ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl/test_ioctl
2008-11-28 15:18:26.000000000 +0530
@@ -19,7 +19,7 @@
##
##
################################################################################
-export TCID=ioctl
+export TCID=ioctl01_02
export TST_TOTAL=2
export TST_COUNT=0
--- ltp-intermediate-20081127/runtest/syscalls.orig 2008-11-28
15:17:20.000000000 +0530
+++ ltp-intermediate-20081127/runtest/syscalls 2008-11-28
15:18:33.000000000 +0530
@@ -406,7 +406,8 @@ getuid03_16 getuid03_16
#ioctl02 ioctl02 -D /dev/tty0
# Introducing ioctl tests for all /dev/tty* devices
-ioctl test_ioctl
+ioctl01_02 test_ioctl
+ioctl03 ioctl03
inotify01 inotify01
inotify02 inotify02
Regards--
Subrata
diff -uprN ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl.orig/ioctl03.c ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl/ioctl03.c
--- ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl.orig/ioctl03.c 1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl/ioctl03.c 2008-11-28 15:23:58.000000000 +0530
@@ -0,0 +1,157 @@
+/******************************************************************************/
+/* */
+/* Copyright (c) Rusty Russell <[EMAIL PROTECTED]> */
+/* Copyright (c) International Business Machines Corp., 2008 */
+/* */
+/* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* */
+/******************************************************************************/
+/******************************************************************************/
+/* */
+/* File: ioctl03.c */
+/* */
+/* Description: This program tests whether all the valid IFF flags are */
+/* returned properly by implementation of TUNGETFEATURES ioctl */
+/* on kernel 2.6.27 */
+/* */
+/* Total Tests: 1 */
+/* */
+/* Test Name: ioctl03 */
+/* */
+/* Author: Rusty Russell <[EMAIL PROTECTED]> */
+/* */
+/* History: Created - Nov 28 2008 - Rusty Russell <[EMAIL PROTECTED]> */
+/* Ported to LTP */
+/* - Nov 28 2008 - Subrata <[EMAIL PROTECTED]> */
+/******************************************************************************/
+
+#include <linux/if_tun.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+
+#ifndef TUNGETFEATURES
+#define TUNGETFEATURES _IOR('T', 207, unsigned int)
+#endif
+
+/* Extern Global Variables */
+extern int Tst_count; /* counter for tst_xxx routines. */
+extern char *TESTDIR; /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "ioctl03"; /* test program identifier. */
+int TST_TOTAL = 1; /* total number of tests in this file. */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/* */
+/* Function: cleanup */
+/* */
+/* Description: Performs all one time clean up for this test on successful */
+/* completion, premature exit or failure. Closes all temporary */
+/* files, removes all temporary directories exits the test with */
+/* appropriate return code by calling tst_exit() function. */
+/* */
+/* Input: None. */
+/* */
+/* Output: None. */
+/* */
+/* Return: On failure - Exits calling tst_exit(). Non '0' return code. */
+/* On success - Exits calling tst_exit(). With '0' return code. */
+/* */
+/******************************************************************************/
+extern void cleanup() {
+ /* Remove tmp dir and all files in it */
+ TEST_CLEANUP;
+ tst_rmdir();
+
+ /* Exit with appropriate return code. */
+ tst_exit();
+}
+
+
+/* Local Functions */
+/******************************************************************************/
+/* */
+/* Function: setup */
+/* */
+/* Description: Performs all one time setup for this test. This function is */
+/* typically used to capture signals, create temporary dirs */
+/* and temporary files that may be used in the course of this */
+/* test. */
+/* */
+/* Input: None. */
+/* */
+/* Output: None. */
+/* */
+/* Return: On failure - Exits by calling cleanup(). */
+/* On success - returns 0. */
+/* */
+/******************************************************************************/
+void setup() {
+ /* Capture signals if any */
+ /* Create temporary directories */
+ TEST_PAUSE;
+ tst_tmpdir();
+}
+
+
+static struct {
+ unsigned int flag;
+ const char *name;
+} known_flags[] = {
+ { IFF_TUN, "TUN" },
+ { IFF_TAP, "TAP" },
+ { IFF_NO_PI, "NO_PI" },
+ { IFF_ONE_QUEUE, "ONE_QUEUE" },
+ };
+
+int main() {
+ unsigned int features, i;
+
+ setup();
+ if (geteuid()!=0) {
+ tst_brkm(TBROK, cleanup, "You need to be ROOT to run this test case");
+ tst_exit();
+ }
+ int netfd = open("/dev/net/tun", O_RDWR);
+ if (netfd < 0)
+ tst_brkm(TBROK, cleanup, "Error Opening /dev/net/tun: %s", strerror(errno));
+
+ if (ioctl(netfd, TUNGETFEATURES, &features) != 0) {
+ tst_resm(TCONF, "Kernel does not support TUNGETFEATURES");
+ features = (IFF_TUN|IFF_TAP|IFF_NO_PI|IFF_ONE_QUEUE);
+ cleanup();
+ tst_exit();
+ }
+ tst_resm(TINFO,"Available features are: ");
+ for (i = 0; i < sizeof(known_flags)/sizeof(known_flags[0]); i++) {
+ if (features & known_flags[i].flag) {
+ features &= ~known_flags[i].flag;
+ tst_resm(TCONF, "%s ", known_flags[i].name);
+ }
+ }
+ if (features)
+ tst_resm(TFAIL, "(UNKNOWN %#x)", features);
+ cleanup();
+ tst_exit();
+}
diff -uprN ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl.orig/test_ioctl ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl/test_ioctl
--- ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl.orig/test_ioctl 2008-11-28 14:01:11.000000000 +0530
+++ ltp-intermediate-20081127/testcases/kernel/syscalls/ioctl/test_ioctl 2008-11-28 15:18:26.000000000 +0530
@@ -19,7 +19,7 @@
## ##
################################################################################
-export TCID=ioctl
+export TCID=ioctl01_02
export TST_TOTAL=2
export TST_COUNT=0
--- ltp-intermediate-20081127/runtest/syscalls.orig 2008-11-28 15:17:20.000000000 +0530
+++ ltp-intermediate-20081127/runtest/syscalls 2008-11-28 15:18:33.000000000 +0530
@@ -406,7 +406,8 @@ getuid03_16 getuid03_16
#ioctl02 ioctl02 -D /dev/tty0
# Introducing ioctl tests for all /dev/tty* devices
-ioctl test_ioctl
+ioctl01_02 test_ioctl
+ioctl03 ioctl03
inotify01 inotify01
inotify02 inotify02
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list