Re: [LTP] [PATCH] Fix some bashisms

Jiří Paleček
2009-10-30T11:51:17Z

[-- Attachment #1: Type: text/plain, Size: 4041 bytes --]

On Fri, 30 Oct 2009 12:37:48 +0100, Subrata Modak
<subrata@linux.vnet.ibm.com> wrote:

> On Thu, 2009-10-29 at 18:12 +0000, JiříPaleček wrote:
>> Hello,
>>
>> Subrata Modak <subrata@...> writes:
>>
>> >
>> > On Wed, 2009-10-21 at 02:19 +0200, Jiri Palecek wrote:
>> > > Hello,
>> > >
>> > > this is another patch fixing bashisms in LTP tests (the fixes are
>> more or
>> less the same as in the previous
>> > patches, except for a few exceptions). Note that the patch is not
>> complete,
>> in the sense that there may
>> > remain further bashisms in the source even after applying the patch
>> (like use
>> of arrays, which is visible
>> > even from this patch).
>> > >
>> > > Regards
>> > > Jiri Palecek
>> > >
>> > > Signed-off-by: Jiri Palecek <jpalecek@...>
>> >
>> > Hmm,. Some of them failed to apply. Can you please resend only the
>> error
>> > part(s):
>> >
>>
>> according to my git repository. these are the missing parts:
>>
>> Signed-off-by: Jiri Palecek <jpalecek@web.de>
>
> Then something wrong with my CVS:
>
> patching file testcases/kernel/fs/fs-bench/modaltr.sh
> Hunk #1 FAILED at 43.
> 1 out of 1 hunk FAILED -- saving rejects to file
> testcases/kernel/fs/fs-bench/modaltr.sh.rej
> patching file testcases/kernel/fs/mongo/test.sh
> Hunk #1 FAILED at 26.
> Hunk #2 FAILED at 52.
> Hunk #3 FAILED at 70.
> 3 out of 3 hunks FAILED -- saving rejects to file
> testcases/kernel/fs/mongo/test.sh.rej
> patching file testcases/network/tcp_cmds/netstat/netstat01
>
> Can you please verify ?

It works for me in CVS, so I guess it was just a linewrap, whitespace or
something issue. See attachment for the original (uncrippled) patch.

Regards
Jiri Palecek

>> ---
>> testcases/kernel/fs/fs-bench/modaltr.sh | 2 +-
>> testcases/kernel/fs/mongo/test.sh | 8 +++-----
>> testcases/network/tcp_cmds/netstat/netstat01 | 2 +-
>> 3 files changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/testcases/kernel/fs/fs-bench/modaltr.sh
>> b/testcases/kernel/fs/fs-
>> bench/modaltr.sh
>> index 85d2c30..36e6f0c 100755
>> --- a/testcases/kernel/fs/fs-bench/modaltr.sh
>> +++ b/testcases/kernel/fs/fs-bench/modaltr.sh
>> @@ -43,7 +43,7 @@ LOG_DIR1=/tmp/log1
>> HOME_DIR=/home
>> BLOCK_DIR=/dev/mtdblock
>> export PATH=$PATH:/sbin
>> - if [ $UID -ne 0 ];
>> + if [ $(id -ru) -ne 0 ];
>> then
>> echo "must be root to run this"
>> exit
>> diff --git a/testcases/kernel/fs/mongo/test.sh
>> b/testcases/kernel/fs/mongo/
>> test.sh
>> index fe75664..eccb079 100755
>> --- a/testcases/kernel/fs/mongo/test.sh
>> +++ b/testcases/kernel/fs/mongo/test.sh
>> @@ -26,7 +26,7 @@ TEST_DIR=testdir
>>
>>
>> #should be root to execute this script .
>> - if [ $UID -ne 0 ]; then
>> + if [ $(id -ru) -ne 0 ]; then
>> echo "This script must be run as root"
>> exit
>> fi
>> @@ -52,8 +52,7 @@ modprobe loop
>> fi
>>
>> #run the mongo test on reiserfs file system type
>> -function reiserfs
>> -
>> +reiserfs()
>> {
>> cat > fs.sh <<EOF
>> echo "performing mongo on reiserfs"
>> @@ -71,8 +70,7 @@ EOF
>>
>>
>> #To run on jfs file system type
>> -function JFS
>> -
>> +JFS()
>> {
>> cat >> fs.sh <<EOF
>> echo "performing mongo on jfs file system"
>> diff --git a/testcases/network/tcp_cmds/netstat/netstat01
>> b/testcases/network/
>> tcp_cmds/netstat/netstat01
>> index 6a197de..365c142 100755
>> --- a/testcases/network/tcp_cmds/netstat/netstat01
>> +++ b/testcases/network/tcp_cmds/netstat/netstat01
>> @@ -58,7 +58,7 @@ do_test() {
>> while [ $TST_COUNT -le $NUMLOOPS ]; do
>>
>> for flag in "-s" "-rn" "-i" "-gn" "-apn"; do
>> - if ! netstat $flag 2>&1 1>/dev/null; then
>> + if ! netstat $flag 1>/dev/null 2>&1; then
>> end_testcase "$COMMAND failed"
>> fi
>> done
>

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

[-- Attachment #2: 0001-Fix-some-bashisms.patch --]
[-- Type: application/octet-stream, Size: 2157 bytes --]

From 8ba003dbc80f0280f1d68bf512329ddbe1a07dd0 Mon Sep 17 00:00:00 2001
From: Jiri Palecek <jpalecek@web.de>
Date: Wed, 21 Oct 2009 02:19:58 +0200
Subject: [PATCH] Fix some bashisms

---
testcases/kernel/fs/fs-bench/modaltr.sh | 2 +-
testcases/kernel/fs/mongo/test.sh | 8 +++-----
testcases/network/tcp_cmds/netstat/netstat01 | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/fs/fs-bench/modaltr.sh b/testcases/kernel/fs/fs-bench/modaltr.sh
index 85d2c30..36e6f0c 100755
--- a/testcases/kernel/fs/fs-bench/modaltr.sh
+++ b/testcases/kernel/fs/fs-bench/modaltr.sh
@@ -43,7 +43,7 @@ LOG_DIR1=/tmp/log1
HOME_DIR=/home
BLOCK_DIR=/dev/mtdblock
export PATH=$PATH:/sbin
- if [ $UID -ne 0 ];
+ if [ $(id -ru) -ne 0 ];
then
echo "must be root to run this"
exit
diff --git a/testcases/kernel/fs/mongo/test.sh b/testcases/kernel/fs/mongo/test.sh
index fe75664..eccb079 100755
--- a/testcases/kernel/fs/mongo/test.sh
+++ b/testcases/kernel/fs/mongo/test.sh
@@ -26,7 +26,7 @@ TEST_DIR=testdir

#should be root to execute this script .
- if [ $UID -ne 0 ]; then
+ if [ $(id -ru) -ne 0 ]; then
echo "This script must be run as root"
exit
fi
@@ -52,8 +52,7 @@ modprobe loop
fi

#run the mongo test on reiserfs file system type
-function reiserfs
-
+reiserfs()
{
cat > fs.sh <<EOF
echo "performing mongo on reiserfs"
@@ -71,8 +70,7 @@ EOF

#To run on jfs file system type
-function JFS
-
+JFS()
{
cat >> fs.sh <<EOF
echo "performing mongo on jfs file system"
diff --git a/testcases/network/tcp_cmds/netstat/netstat01 b/testcases/network/tcp_cmds/netstat/netstat01
index 6a197de..365c142 100755
--- a/testcases/network/tcp_cmds/netstat/netstat01
+++ b/testcases/network/tcp_cmds/netstat/netstat01
@@ -58,7 +58,7 @@ do_test() {
while [ $TST_COUNT -le $NUMLOOPS ]; do

for flag in "-s" "-rn" "-i" "-gn" "-apn"; do
- if ! netstat $flag 2>&1 1>/dev/null; then
+ if ! netstat $flag 1>/dev/null 2>&1; then
end_testcase "$COMMAND failed"
fi
done
--
1.6.4.3

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

------------------------------------------------------------------------------
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

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