All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] New ltp test case
@ 2011-01-17 20:21 Allison C Henderson
  2011-01-19  7:40 ` Garrett Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Allison C Henderson @ 2011-01-17 20:21 UTC (permalink / raw)
  To: ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 608 bytes --]

Hi All,

I am new to the ltc filesystem team at IBM and we have been working on a 
new ltp test case for ext4.  The test case exercises the new punch hole 
flag in the fallocate system call that we will be using to implement punch 
hole support for ext4.  Currently, there is no punch hole support for 
ext4, so the test just returns failed, but we wanted to add the test case 
to help verify that the new VFS changes to fallocate are working.   I have 
included a patch that adds the new ltp test case.  Let me know what you 
think.  Thanks!

Allison Henderson
eml: achender@us.ibm.com
ph:799-5761 (T/L 321)

[-- Attachment #1.2: Type: text/html, Size: 769 bytes --]

[-- Attachment #2: ltp_holepunch_patch --]
[-- Type: application/octet-stream, Size: 9757 bytes --]

diff -Nuar ltp_unpatched/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/ext4_hole_punch.c ltp_manualPatch/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/ext4_hole_punch.c
--- ltp_unpatched/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/ext4_hole_punch.c	1969-12-31 17:00:00.000000000 -0700
+++ ltp_manualPatch/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/ext4_hole_punch.c	2011-01-14 17:34:46.936194859 -0700
@@ -0,0 +1,98 @@
+/******************************************************************************/
+/*                                                                            */
+/* Copyright (c) International Business Machines  Corp., 2011                 */
+/*                                                                            */
+/* 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    */
+/*                                                                            */
+/* Author: Allison Henderson  <achender@us.ibm.com>                           */
+/*                                                                            */
+/******************************************************************************/
+
+#include <linux/falloc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+
+#define USAGE "USAGE: ext4-punch-hole -o offset -l length filename\n"
+
+int main(int argc, char *argv[])
+{
+        int length = -1;
+        int offset = -1;
+        int opt = 0;
+        int fd = 0;
+        int rc = 0;
+        int mode = 0;
+        char *filename = NULL;
+
+
+        if (argc != 6) {
+                fprintf(stderr, USAGE);
+                return 1;
+        }
+
+        /* Parse arguments */
+        while ((opt = getopt(argc, argv, "o:l:")) != EOF) {
+                switch (opt) {
+                case 'o':
+                        offset = atoi(optarg);
+                        break;
+                case 'l':
+                        length = atoi(optarg);
+                        break;
+                default:
+                        fprintf(stderr, USAGE);
+                        return 1;
+                }
+        }
+
+        filename = argv[5];
+
+        if(offset < 0 || length < 0 || filename == NULL){
+                fprintf(stderr, USAGE);
+                return 1;
+        }
+
+
+        /* Check for punch hole support */
+#ifndef FALLOC_FL_PUNCH_HOLE
+        fprintf(stderr, "Error: fallocate punch hole not supported\n");
+        return 1;
+#else
+
+        /* Open file */
+        fd = open(filename, O_WRONLY, 0755  );
+        if(fd <= 0){
+                perror("Error: Failed to open file");
+                return 1;
+        }
+
+        /* Punch hole */
+        mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
+        rc = fallocate(fd, mode, offset, length);
+        if(rc != 0){
+                perror("Error: Punch hole failed");
+        }
+
+        close(fd);
+#endif
+	return rc;
+}
+
diff -Nuar ltp_unpatched/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/ext4_hole_punch_test.sh ltp_manualPatch/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/ext4_hole_punch_test.sh
--- ltp_unpatched/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/ext4_hole_punch_test.sh	1969-12-31 17:00:00.000000000 -0700
+++ ltp_manualPatch/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/ext4_hole_punch_test.sh	2011-01-14 17:35:20.257197413 -0700
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+################################################################################
+##                                                                            ##
+## Copyright (c) International Business Machines  Corp., 2011                 ##
+##                                                                            ##
+## 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    ##
+##                                                                            ##
+## Author: Allison Henderson <ahender@us.ibm..com>                            ##
+##                                                                            ##
+################################################################################
+
+cd $LTPROOT/testcases/bin
+
+. ./ext4_funcs.sh
+
+export TCID="ext4-hole-punch"
+export TST_TOTAL=2
+export TST_COUNT=1
+
+# $1: the test config
+read_config $1
+
+TEST_DIR=$PWD
+
+# Test that file can be hole punched
+ext4_test_hole_punch()
+{
+	tst_resm TINFO "Test fallocate punch hole"
+
+	#create the file system
+	mkfs.ext4  $EXT4_DEV &> /dev/null
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "failed to create ext4 filesystem"
+		return 1
+	fi
+
+	#mount the file system
+	mount -t ext4 $EXT4_DEV mnt_point
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "failed to mount ext4 filesystem"
+		return 1
+	fi
+
+	#create test file
+	rm mnt_point/tmp_file
+	touch mnt_point/tmp_file
+	dd if=/dev/zero of=mnt_point/tmp_file bs=1024 count=50 &> /dev/null       
+
+	#punch hole in middle
+	./ext4_hole_punch -o  25600 -l 6144 mnt_point/tmp_file
+
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "Punch hole failed"
+		umount mnt_point
+		return 1
+	fi
+
+
+
+	#unmount filesytem
+	umount mnt_point
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "failed to umount ext4 filesystem"
+		return 1
+	fi
+
+	tst_resm TPASS "Ext4 punch hole pass"
+}
+
+# main
+ext4_setup
+
+RET=0
+
+ext4_test_hole_punch
+if [ $? -ne 0 ]; then
+	RET=1
+fi
+: $((TST_COUNT++))
+
+ext4_cleanup
+exit $RET
+
diff -Nuar ltp_unpatched/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/Makefile ltp_manualPatch/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/Makefile
--- ltp_unpatched/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/Makefile	1969-12-31 17:00:00.000000000 -0700
+++ ltp_manualPatch/ltp/testcases/kernel/fs/ext4-new-features/ext4-hole-punch/Makefile	2011-01-14 17:41:30.586195302 -0700
@@ -0,0 +1,25 @@
+#    Copyright (C) International Business Machines  Corp., 2011 
+#
+#    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.
+#
+
+top_srcdir              ?= ../../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+LDLIBS += -lm
+INSTALL_TARGETS		?= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff -Nuar ltp_unpatched/ltp/testcases/kernel/fs/ext4-new-features/run_ext4_test.sh ltp_manualPatch/ltp/testcases/kernel/fs/ext4-new-features/run_ext4_test.sh
--- ltp_unpatched/ltp/testcases/kernel/fs/ext4-new-features/run_ext4_test.sh	2009-10-26 04:25:55.000000000 -0700
+++ ltp_manualPatch/ltp/testcases/kernel/fs/ext4-new-features/run_ext4_test.sh	2011-01-14 14:00:53.310200712 -0700
@@ -176,4 +176,18 @@
 	RET=1
 fi
 
+
+echo " "
+echo "Ext4 fallocate hole punch test"
+if [ -f "ext4_hole_punch_test.sh" ];  then
+        ./ext4_hole_punch_test.sh ./ext4-test-config
+        if [ $? -ne 0 ]; then
+                RET=1
+        fi
+else
+        echo "Shell file is not installed..Please check Makefile..."
+        RET=1
+fi
+
+
 exit $RET

[-- Attachment #3: Type: text/plain, Size: 372 bytes --]

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] New ltp test case
  2011-01-17 20:21 [LTP] New ltp test case Allison C Henderson
@ 2011-01-19  7:40 ` Garrett Cooper
  2011-01-19 14:07   ` Serge Hallyn
  0 siblings, 1 reply; 3+ messages in thread
From: Garrett Cooper @ 2011-01-19  7:40 UTC (permalink / raw)
  To: Allison C Henderson; +Cc: ltp-list

On Mon, Jan 17, 2011 at 12:21 PM, Allison C Henderson
<achender@us.ibm.com> wrote:
>
> Hi All,
>
> I am new to the ltc filesystem team at IBM and we have been working on a new
> ltp test case for ext4.  The test case exercises the new punch hole flag in
> the fallocate system call that we will be using to implement punch hole
> support for ext4.  Currently, there is no punch hole support for ext4, so
> the test just returns failed, but we wanted to add the test case to help
> verify that the new VFS changes to fallocate are working.   I have included
> a patch that adds the new ltp test case.  Let me know what you think.

Hi Allison,
    Welcome! Would you please look at the style guide I recently wrote
please for how to contribute testcases to LTP?
Thanks!
-Garrett

1. http://ltp.git.sourceforge.net/git/gitweb.cgi?p=ltp/ltp.git;a=blob;f=doc/style-guide.txt;h=b6e3f6d70a85de64a621fa612046d7ad7bc12301;hb=452fed5

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] New ltp test case
  2011-01-19  7:40 ` Garrett Cooper
@ 2011-01-19 14:07   ` Serge Hallyn
  0 siblings, 0 replies; 3+ messages in thread
From: Serge Hallyn @ 2011-01-19 14:07 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list, Allison C Henderson

Quoting Garrett Cooper (yanegomi@gmail.com):
> On Mon, Jan 17, 2011 at 12:21 PM, Allison C Henderson
> <achender@us.ibm.com> wrote:
> >
> > Hi All,
> >
> > I am new to the ltc filesystem team at IBM and we have been working on a new
> > ltp test case for ext4.  The test case exercises the new punch hole flag in
> > the fallocate system call that we will be using to implement punch hole
> > support for ext4.  Currently, there is no punch hole support for ext4, so
> > the test just returns failed, but we wanted to add the test case to help
> > verify that the new VFS changes to fallocate are working.   I have included
> > a patch that adds the new ltp test case.  Let me know what you think.
> 
> Hi Allison,
>     Welcome! Would you please look at the style guide I recently wrote
> please for how to contribute testcases to LTP?
> Thanks!
> -Garrett
> 
> 1. http://ltp.git.sourceforge.net/git/gitweb.cgi?p=ltp/ltp.git;a=blob;f=doc/style-guide.txt;h=b6e3f6d70a85de64a621fa612046d7ad7bc12301;hb=452fed5

Nice, thanks for writing that.

-serge

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2011-01-19 14:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-17 20:21 [LTP] New ltp test case Allison C Henderson
2011-01-19  7:40 ` Garrett Cooper
2011-01-19 14:07   ` Serge Hallyn

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.