Subrata Modak wrote:
On Mon, 2008-08-11 at 15:14 +0530, B. N. Poornima wrote:
Subrata Modak wrote:
Poornima,
Please resend it as a patch containing the source code/directories,
Makefile(s), scripts(if any) and entry inside runtest/syscalls, all
together integrated. I can test then.
Regards--
Subrata
On Thu, 2008-07-31 at 18:30 +0530, B. N. Poornima wrote:
Hi,
I have developed test cases for sync_file_range() system call which will
do the basic sanity (error) checking for the system call. These tests
have to be run on 2.6.17 kernel and above.
The test cases have been currently tested only on x86 and x86_64
architecture.
Also, I have hard coded the system call number in the test case for
review purposes and will be later on moving it to
linux_syscall_numbers.h file in the LTP framework.
Please review the test cases and provide your comments so that I can
improve the same.
Thanks,
Poornima.
Subrata,
Re-sending the test cases as a patch. Please test and provide your
feedback. Thanks!
Thanks Poornima for resending the Patch once again. I have tested it and
please see the results i obtained:
1) # uname -a
Linux 2.6.18-91.el5 #1 SMP Tue Apr 22 17:43:57 EDT 2008 x86_64 x86_64
x86_64 GNU/Linux
BUILD=Pass, INSTALL=Pass, RUN=Pass,
# testcases/bin/sync_file_range01
sync_file_range01 1 PASS : expected failure - errno = 9 : Bad file
descriptor
sync_file_range01 2 PASS : expected failure - errno = 29 : Illegal
seek
sync_file_range01 3 PASS : expected failure - errno = 22 : Invalid
argument
sync_file_range01 4 PASS : expected failure - errno = 22 : Invalid
argument
sync_file_range01 5 PASS : expected failure - errno = 22 : Invalid
argument
2) # uname -a
Linux 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:56:44 EST 2007 x86_64 x86_64
x86_64 GNU/Linux
BUILD=Pass, INSTALL=Pass, RUN=Pass,
# testcases/bin/sync_file_range01
sync_file_range01 0 WARN : System doesn't support execution of
the test
2) # uname -a
Linux 2.6.9-22.EL #1 SMP Mon Sep 19 17:52:20 EDT 2005 ppc64 ppc64 ppc64
GNU/Linux
BUILD=Pass, INSTALL=Pass, RUN=Pass,
# testcases/bin/sync_file_range01
sync_file_range01 0 WARN : System doesn't support execution of
the test
3) # uname -a
Linux 2.6.18-91.el5 #1 SMP Tue Apr 22 17:48:59 EDT 2008 ppc64 ppc64
ppc64 GNU/Linux
BUILD=Pass, INSTALL=Pass, RUN=Pass,
# ./testcases/bin/sync_file_range01
sync_file_range01 0 WARN : System doesn't support execution of
the test
4) # uname -a
Linux 2.6.23.13 #1 SMP Wed Jan 9 18:14:28 PST 2008 ia64 GNU/Linux
BUILD=Pass, INSTALL=Pass, RUN=Pass,
# ./testcases/bin/sync_file_range01
sync_file_range01 1 PASS : expected failure - errno = 9 : Bad file
descriptor
sync_file_range01 2 PASS : expected failure - errno = 29 : Illegal
seek
sync_file_range01 3 PASS : expected failure - errno = 22 : Invalid
argument
sync_file_range01 4 PASS : expected failure - errno = 22 : Invalid
argument
sync_file_range01 5 PASS : expected failure - errno = 22 : Invalid
argument
5) # uname -a
Linux 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386
GNU/Linux
BUILD=Pass, INSTALL=Pass, RUN=Pass,
# ./testcases/bin/sync_file_range01
sync_file_range01 0 WARN : System doesn't support execution of
the test
6) # uname -a
Linux 2.6.18-91.el5PAE #1 SMP Tue Apr 22 17:58:37 EDT 2008 i686 i686
i386 GNU/Linux
BUILD=Pass, INSTALL=Pass, RUN=Pass,
# ./testcases/bin/sync_file_range01
sync_file_range01 1 PASS : expected failure - errno = 9 : Bad file
descriptor
sync_file_range01 2 PASS : expected failure - errno = 29 : Illegal
seek
sync_file_range01 3 PASS : expected failure - errno = 22 : Invalid
argument
sync_file_range01 4 PASS : expected failure - errno = 22 : Invalid
argument
sync_file_range01 5 PASS : expected failure - errno = 22 : Invalid
argument
MY OBSERVATIONS:
=======================================================
1) The Build/Install issues on various architectures and under varying
kernel versions has been taken care of properly,
2) The running of test cases are also pretty fine.
However there are issues which needs to be addressed:
1) As you mentioned that the test will run with kernel >= 2.6.17. This
seems satisfied with all combinations i tried, except item no. 3 above,
where the kernel is 2.6.18-91.el5 for ppc64. Is it that the support for
this system call has to be explicitly done during kernel build, or it
will automatically take care ?
2) When running below kernel 2.6.17, it should throw the following
message:
sync_file_range01 0 CONF : System doesn't support execution of
the test
instead of:
sync_file_range01 0 WARN : System doesn't support execution of
the test,
And the test should return PASS/0 in this case (which will be taken care
of by the tst_* functions in such a case). Please see Paul Larson“s
article on this:
http://ltp.sourceforge.net/documentation/technical_papers/ltp.pdf
(Pages 4-6)
If this issue is addressed, i can include this new test with immediate
effect. Thanks for putting effort for writing this test.
Regards--
Subrata
Regards,
Poornima.
Subrata,
1) As you mentioned that the test will run with kernel >= 2.6.17. This
seems satisfied with all combinations i tried, except item no. 3 above,
where the kernel is 2.6.18-91.el5 for ppc64. Is it that the support for
this system call has to be explicitly done during kernel build, or it
will automatically take care ?
The support for PowerPC was provided from 2.6.22 kernel onwards. I had
not taken care of it in my previous patch. Now this is addressed.
2) When running below kernel 2.6.17, it should throw the following
message:
sync_file_range01 0 CONF : System doesn't support execution of
the test
Have addressed this too.
I am re sending the patch with the above modifications. Please test
and let me know. Thanks!
Regards,
Poornima.
--- ltp-full-20080731.original/include/linux_syscall_numbers.h 2008-07-21 16:08:43.000000000 +0530
+++ ltp-full-20080731/include/linux_syscall_numbers.h 2008-08-18 12:42:06.000000000 +0530
@@ -381,6 +381,9 @@
# ifndef __NR_faccessat
# define __NR_faccessat (__NR_openat + 12)
# endif
+# ifndef __NR_sync_file_range2
+# define __NR_sync_file_range2 308
+# endif
# ifndef __NR_fallocate
# define __NR_fallocate 309
# endif
@@ -454,6 +457,9 @@
# ifndef __NR_faccessat
# define __NR_faccessat (__NR_openat + 12)
# endif
+# ifndef __NR_sync_file_range2
+# define __NR_sync_file_range2 308
+# endif
# ifndef __NR_fallocate
# define __NR_fallocate 309
# endif
--- ltp-full-20080731.original/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c 1970-01-01 05:30:00.000000000 +0530
+++ ltp-full-20080731/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c 2008-08-18 15:05:04.000000000 +0530
@@ -0,0 +1,345 @@
+/******************************************************************************
+ * sync_file_range01.c
+ * Copyright (c) International Business Machines Corp., 2008
+ * Email: [EMAIL PROTECTED]
+ *****************************************************************************/
+
+/******************************************************************************/
+/* */
+/* 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 */
+/* */
+/******************************************************************************/
+
+
+/*****************************************************************************
+ * TEST IDENTIFIER : sync_file_range01
+ *
+ * EXECUTED BY : anyone
+ *
+ * TEST TITLE : Checks for Errors from sync_file_range()
+ *
+ * TEST CASE TOTAL : 5
+ *
+ * CPU ARCHITECTURES : All
+ *
+ * AUTHOR : B N Poornima
+ *
+ * DATE STARTED : 21/07/2008
+ *
+ * TEST CASES
+ * (Tests sync_file_range() for different test cases as reported in the man
+ * page)
+ *
+ * INPUT SPECIFICATIONS
+ * No input needs to be specified
+ * sync_file_data() in-puts are specified through test_data
+ *
+ * OUTPUT SPECIFICATIONS
+ * sync_file_data() error message matches with the expected error
+ * message.
+ *
+ * ENVIRONMENTAL NEEDS
+ * Kernel version 2.6.17 and above
+ * Kernel version 2.6.22 and above in case of PPC and PPC64
+ *
+ * SPECIAL PROCEDURAL REQUIREMENTS
+ * None
+ *
+ * DETAILED DESCRIPTION
+ * This is a test case for sync_file_range() system call.
+ * This test suite tests various error messages from the system call
+ * If the error message received matches with the expected
+ * test is considered passed else test fails
+ *
+ * Total 5 Test Cases :-
+ * Various error messages from the man page
+ *
+ * Setup:
+ * Setup files on which sync_file_range is to be called
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Execute system call
+ * Check return code.
+ * If error obtained matches with the expected error
+ * PASS the test, otherwise TEST FAILS
+ *
+ * Cleanup:
+ * Cleanup the temporary folder
+ *
+ ******************************************************************************/
+#define _GNU_SOURCE
+
+/* Standard Include Files */
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/utsname.h>
+#include <unistd.h>
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+
+#if defined(__powerpc__) || defined(__powerpc64__)
+ #ifndef __NR_sync_file_range2
+ #define __NR_sync_file_range2 -1 //DUMMY VALUE
+ int arch_support = 0; //Architecure is not supported
+ #else
+ int arch_support = 1; //Architecture is supported
+ #endif
+#else
+ #ifndef __NR_sync_file_range
+ #define __NR_sync_file_range -1 //DUMMY Value
+ int arch_support = 0;
+ #else
+ int arch_support = 1;
+ #endif
+#endif
+
+
+#ifndef SYNC_FILE_RANGE_WAIT_BEFORE
+#define SYNC_FILE_RANGE_WAIT_BEFORE 1
+#define SYNC_FILE_RANGE_WRITE 2 //DUMMY VALUES
+#define SYNC_FILE_RANGE_WAIT_AFTER 4
+#endif
+
+#define SYNC_FILE_RANGE_INVALID 8
+
+/* 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 = "sync_file_range01"; /* test program identifier. */
+char filename[255]; /* file used for testing */
+char spl_file[] = "/dev/null";
+int filed, sfd; /* normal and special fds */
+int bfd = -1; /* Bad file descriptor */
+
+struct test_data_t
+{
+ int *fd;
+ off64_t offset;
+ off64_t nbytes;
+ unsigned int flags;
+ int error;
+} test_data[] = {
+ {&bfd, 0, 1, SYNC_FILE_RANGE_WRITE, EBADF},
+ {&sfd, 0, 1, SYNC_FILE_RANGE_WAIT_AFTER, ESPIPE},
+ {&filed, -1, 1, SYNC_FILE_RANGE_WAIT_BEFORE, EINVAL},
+ {&filed, 0, -1, SYNC_FILE_RANGE_WRITE, EINVAL},
+ {&filed, 0, 1, SYNC_FILE_RANGE_INVALID, EINVAL}
+ };
+
+int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]);
+
+
+
+
+/* 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()
+{
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* close the file we have open */
+ if (close(filed) == -1) {
+ tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", filename, errno, strerror(errno));
+ }
+
+ /* Remove tmp dir and all files in it */
+ tst_rmdir();
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+
+ 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 */
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+
+ /* make a temp directory and cd to it */
+ tst_tmpdir();
+
+ sprintf(filename,"tmpfile_%d",getpid());
+ if ((filed = open(filename,O_RDWR|O_CREAT,0700)) == -1) {
+ tst_brkm(TBROK, cleanup,
+ "open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
+ filename, errno, strerror(errno));
+
+ sfd = open(spl_file, O_RDWR|O_CREAT, 0700);
+
+ }
+
+return;
+}
+
+/*****************************************************************************
+ * Wraper function to call sync_file_range system call
+ ******************************************************************************/
+static inline long syncfilerange(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
+{
+
+ #if defined(__powerpc64__) && (__WORDSIZE==32)
+
+ return syscall(__NR_sync_file_range2, fd, flags, (int)(offset >>32), \
+ (int)offset, (int)(nbytes >>32), (int)nbytes);
+
+ #elif defined(__powerpc64__) && (__WORDSIZE==64)
+
+ return syscall(__NR_sync_file_range2, fd, flags, offset, nbytes);
+ #else
+
+ return syscall(__NR_sync_file_range, fd, offset, nbytes, flags);
+ #endif
+
+ return 0;
+}
+
+
+
+
+
+/******************************************************************************/
+/* */
+/* Function: main */
+/* */
+/* Description: Entry point to this test-case. It parses all the command line */
+/* inputs, calls the global setup and executes the test. It logs */
+/* the test status and results appropriately using the LTP API's */
+/* On successful completion or premature failure, cleanup() func */
+/* is called and test exits with an appropriate return code. */
+/* */
+/* Input: Describe input arguments to this test-case */
+/* -l - Number of iteration */
+/* -v - Prints verbose output */
+/* -V - Prints the version number */
+/* */
+/* Exit: On failure - Exits by calling cleanup(). */
+/* On success - exits with 0 exit value. */
+/* */
+/******************************************************************************/
+int
+main(int ac, /* number of command line parameters */
+ char **av) /* pointer to the array of the command line parameters. */
+{
+
+ int test_index = 0;
+ int lc;
+ char *msg;
+
+ /***************************************************************
+ parse standard options
+ ********************************************************************/
+ if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
+ tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+
+ /* This test needs kernel version > 2.6.16 */
+
+ if ( !arch_support || (tst_kvercmp(2,6,17) < 0)) {
+ tst_resm(TCONF, "System doesn't support execution of the test");
+ tst_exit();
+ }
+
+
+/* perform global test setup, call setup() function. */
+setup();
+
+for (lc=0; TEST_LOOPING(lc); lc++) {
+ /* reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ for(test_index = 0 ; test_index < TST_TOTAL; test_index ++)
+ {
+ TEST(syncfilerange(*(test_data[test_index].fd), test_data[test_index].offset, \
+ test_data[test_index].nbytes, test_data[test_index].flags));
+
+
+ if (TEST_RETURN != -1) {
+ tst_resm(TFAIL, "call succeeded unexpectedly");
+ continue;
+ }
+
+ TEST_ERROR_LOG(TEST_ERRNO);
+
+ if (TEST_ERRNO == test_data[test_index].error) {
+ tst_resm(TPASS, "expected failure - "
+ "errno = %d : %s", TEST_ERRNO,
+ strerror(TEST_ERRNO));
+ } else {
+ tst_resm(TFAIL, "unexpected error - %d : %s - "
+ "expected %d", TEST_ERRNO,
+ strerror(TEST_ERRNO), test_data[test_index].error);
+ }
+ }
+
+ }
+
+cleanup();
+return(0);
+}
--- ltp-full-20080731.original/testcases/kernel/syscalls/sync_file_range/Makefile 1970-01-01 05:30:00.000000000 +0530
+++ ltp-full-20080731/testcases/kernel/syscalls/sync_file_range/Makefile 2008-08-08 17:34:28.000000000 +0530
@@ -0,0 +1,31 @@
+#
+# Copyright (c) International Business Machines Corp., 2001
+#
+# 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+CFLAGS += -I../../../../include -Wall
+LDLIBS += -L../../../../lib -lltp
+
+SRCS = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+ @set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+ rm -f $(TARGETS)
--- ltp-full-20080731.original/runtest/syscalls 2008-07-26 09:45:36.000000000 +0530
+++ ltp-full-20080731/runtest/syscalls 2008-08-11 14:49:56.000000000 +0530
@@ -906,6 +906,9 @@ symlinkat01 symlinkat01
sync01 sync01
sync02 sync02
+#testcases for sync_file_range
+sync_file_range01 sync_file_range01
+
syscall01 syscall01
sysconf01 sysconf01
-------------------------------------------------------------------------
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