« Return to Thread: [LTP{PATCH][fs tests] modify tests to honor tmp directory passed into runltp, convert to LTP format

Re: [LTP{PATCH][fs tests] modify tests to honor tmp directory passed into runltp, convert to LTP format

by yaneurabeya :: Rate this Message:

Reply to Author | View in Thread

On Sun, Oct 18, 2009 at 11:21 AM, Subrata Modak
<subrata@...> wrote:

>
> On Fri, 2009-10-16 at 22:17 -0700, Garrett Cooper wrote:
>> On Fri, Oct 16, 2009 at 1:31 PM, Henry Yei <hyei@...> wrote:
>> > This is a set of patches for tests in the fs runtest file which make use of tst_tmpdir functions or alternatively, the base tmpdir set by the user. Some of the tests have been converted to LTP test format as well.
>> >
>> > Tests that are changed:
>> > fs_di
>> > fs_perms
>> > lftest
>> > linker01
>> > quota_remount_test01
>> > writetest
>>
>> Note: linker01 is a bourne shell script now.
>
> And as Garret said, and apart from that, the lftest.patch fails too:
>
> patching file testcases/kernel/fs/lftest/lftest.c
> patch: **** malformed patch at line 94:
>
> can't find file to patch at input line 3
> Perhaps you used the wrong -p or --strip option?
> The text leading up to this was:
> --------------------------
> |--- ltp-20090531/testcases/kernel/fs/linktest/linktest.pl
> 2008-07-30 06:18:22.000000000 -0700
> |+++ ltp-wdir/testcases/kernel/fs/linktest/linktest.pl  2009-07-27
> 20:59:55.370039414 -0700
> --------------------------
> File to patch:
>
> Regards--
> Subrata

Here's a version that improves upon the old version of linktest.sh (I
directly translated linktest.pl to linktest.sh, and I noticed several
items that were either not caught before, or where lost in
translation). I've just checked this into cvs.

1. Honor TMPDIR, as per Henry Yei's note, because linktest.sh doesn't
currently do that.
2. Add error checking for cd(1) failure.
3. Suffix the temporary directory with $$ to allow multiple copies to
execute on the directory at any given time.
4. Add trap(1)'s to delete the temporary files / directories generated
in the script.

gcooper@orangebox /scratch/ltp-dev2/ltp $
testcases/kernel/fs/linktest/linktest.sh 200 1000
linker01    1  TPASS  :  Symbolic Link Errors: 0
linker01    2  TPASS  :  Hard Link Errors: 0

Signed-off-by: Garrett Cooper <yanegomi@...>

Index: testcases/kernel/fs/linktest/linktest.sh
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/fs/linktest/linktest.sh,v
retrieving revision 1.1
diff -u -r1.1 linktest.sh
--- testcases/kernel/fs/linktest/linktest.sh    14 Oct 2009 19:32:12
-0000      1.1
+++ testcases/kernel/fs/linktest/linktest.sh    18 Oct 2009 23:39:24 -0000
@@ -25,19 +25,34 @@
 #  HISTORY     :
 #      A rewrite of testcases/kernel/fs/linktest.pl

-# XXX: Change to a temp dir via mktemp -d.
-cd "${0%/*}"
-
 export TCID=linker01
 export TST_TOTAL=2
 export TST_COUNT=1

 if [ $# -ne 2 ]; then
-       tst_res TBROK "" "Usage: $0 {softlink count} {hardlink count}"
-       exit -1
+       tst_res TBROK "" "usage: $0 {softlink count} {hardlink count}"
+       exit 1
 fi

-mkdir hlink slink && touch hlink/hfile slink/sfile
+# TMPDIR not specified.
+if [ "x$TMPDIR" = x -o ! -d "$TMPDIR" ] ; then
+
+       if ! TMPDIR=$(mktemp -d) ; then
+               tst_res TBROK "" 'Failed to create $TMPDIR'
+               exit 1
+       fi
+       # We created the directory, so we have the power to delete it as well.
+       trap "rm -Rf '$TMPDIR'" EXIT
+
+# Most likely runltp provided; don't delete $TMPDIR, but instead delete the
+# files under it belonging to this process.
+else
+       trap "rm -Rf '$TMPDIR/[hs]link.$$'" EXIT
+fi
+
+cd "$TMPDIR" || tst_res TBROK "" "Failed to cd to $TMPDIR"
+
+mkdir hlink.$$ slink.$$ && touch hlink.$$/hfile slink.$$/sfile

 do_link() {
        pfix=$1
@@ -49,7 +64,7 @@

        i=0

-       cd ${pfix}link
+       cd "${pfix}link.$$"
        while [ $i -lt $limit ]; do
                if ! ln ${ln_opts} "$PWD/${pfix}file" ${pfix}file${i}; then
                        : $(( lerrors += 1 ))
@@ -73,4 +88,4 @@
 do_link s "-s" ${1} "Symbolic"
 do_link h   "" ${2} "Hard"

-rm -Rf hlink slink
+rm -Rf hlink.$$ slink.$$

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
Ltp-list@...
https://lists.sourceforge.net/lists/listinfo/ltp-list

 « Return to Thread: [LTP{PATCH][fs tests] modify tests to honor tmp directory passed into runltp, convert to LTP format