Skip to contentSkip to conversation

liblockdep: Fix unsupported 'basename -s' in run_tests.sh

PATCH New Sedat Dilek 2 participants 2 messages Mar 30, 2016 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 liblockdep: Fix unsupported 'basename -s' in run_tests.sh

Here on Ubuntu/precise I have GNU/coreutils v8.13 installed where 'basename -s' is not supported.

The result is that run_tests.sh is not done properly.

[ INSTRUCTIONS ]

$ cd $BUILD_DIR
$ LC_ALL=C make -C tools/ liblockdep
$ cd tools/lib/lockdep/
$ LC_ALL=C ./run_tests.sh
basename: invalid option -- 's'
Try `basename --help' for more information.
... timeout: failed to run command `./tests/': Permission denied
FAILED!
rm: cannot remove `tests/': Is a directory

Due to unsupported basename the tests programs are not generated and cannot be removed.

Fix this by doing a compatible basename invocation and check for the existence of generated tests programs.

For more details see the thread in [1] on LKML.

This patch is on top of Linux v4.6-rc1.

[1] http://marc.info/?t=145906667300001&r=1&w=2

Cc Sasha Levin <[email protected]> (maintainer:LIBLOCKDEP)
Cc Linus Torvalds <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Theodore Ts'o <[email protected]>
Cc Boqun Feng <[email protected]>
Cc linux-fsdevel <[email protected]>
---
 tools/lib/lockdep/run_tests.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
tools/lib/lockdep/run_tests.sh +8 -4
index 5334ad9d39b7..1069d96248c1 100755
@@ -3,7 +3,7 @@
 make &> /dev/null
 
 for i in `ls tests/*.c`; do
-	testname=$(basename -s .c "$i")
+	testname=$(basename "$i" .c)
 	gcc -o tests/$testname -pthread -lpthread $i liblockdep.a -Iinclude -D__USE_LIBLOCKDEP &> /dev/null
 	echo -ne "$testname... "
 	if [ $(timeout 1 ./tests/$testname | wc -l) -gt 0 ]; then
@@ -11,11 +11,13 @@ for i in `ls tests/*.c`; do
 	else
 		echo "FAILED!"
 	fi
-	rm tests/$testname
+	if [ -f "tests/$testname" ]; then
+		rm tests/$testname
+	fi
 done
 
 for i in `ls tests/*.c`; do
-	testname=$(basename -s .c "$i")
+	testname=$(basename "$i" .c)
 	gcc -o tests/$testname -pthread -lpthread -Iinclude $i &> /dev/null
 	echo -ne "(PRELOAD) $testname... "
 	if [ $(timeout 1 ./lockdep ./tests/$testname | wc -l) -gt 0 ]; then
@@ -23,5 +25,7 @@ for i in `ls tests/*.c`; do
 	else
 		echo "FAILED!"
 	fi
-	rm tests/$testname
+	if [ -f "tests/$testname" ]; then
+		rm tests/$testname
+	fi
 done
Signature · 1 line
2.8.0
#1 lore raw

[tip:core/urgent] tools/lib/lockdep: Fix unsupported 'basename -s' in run_tests.sh

tools/lib/lockdep: Fix unsupported 'basename -s' in run_tests.sh
Commit-ID:  a189c017ded0f13650793067fb7a1afbc2b98cd5
Gitweb:     http://git.kernel.org/tip/a189c017ded0f13650793067fb7a1afbc2b98cd5
Author:     Sedat Dilek <[email protected]>
AuthorDate: Wed, 30 Mar 2016 10:22:49 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 30 Mar 2016 12:45:56 +0200

tools/lib/lockdep: Fix unsupported 'basename -s' in run_tests.sh

Here on Ubuntu/precise I have GNU/coreutils v8.13 installed where 'basename -s' is not supported.

The result is that run_tests.sh is not done properly.

How to reproduce:

  $ cd $BUILD_DIR
  $ LC_ALL=C make -C tools/ liblockdep
  $ cd tools/lib/lockdep/
    $ LC_ALL=C ./run_tests.sh
  basename: invalid option -- 's'
  Try `basename --help' for more information.
  ... timeout: failed to run command `./tests/': Permission denied
  FAILED!
  rm: cannot remove `tests/': Is a directory

Due to unsupported basename the tests programs are not generated and cannot be removed.

Fix this by doing a compatible basename invocation and check for the existence of generated tests programs.

For more details see this LKML thread:

http://marc.info/?t=145906667300001&r=1&w=2

Cc Boqun Feng <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Sasha Levin <[email protected]> (maintainer:LIBLOCKDEP)
Cc Shuah Khan <[email protected]>
Cc Theodore Ts'o <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc linux-fsdevel <[email protected]>
---
 tools/lib/lockdep/run_tests.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
tools/lib/lockdep/run_tests.sh +8 -4
index 5334ad9..1069d96 100755
@@ -3,7 +3,7 @@
 make &> /dev/null
 
 for i in `ls tests/*.c`; do
-	testname=$(basename -s .c "$i")
+	testname=$(basename "$i" .c)
 	gcc -o tests/$testname -pthread -lpthread $i liblockdep.a -Iinclude -D__USE_LIBLOCKDEP &> /dev/null
 	echo -ne "$testname... "
 	if [ $(timeout 1 ./tests/$testname | wc -l) -gt 0 ]; then
@@ -11,11 +11,13 @@ for i in `ls tests/*.c`; do
 	else
 		echo "FAILED!"
 	fi
-	rm tests/$testname
+	if [ -f "tests/$testname" ]; then
+		rm tests/$testname
+	fi
 done
 
 for i in `ls tests/*.c`; do
-	testname=$(basename -s .c "$i")
+	testname=$(basename "$i" .c)
 	gcc -o tests/$testname -pthread -lpthread -Iinclude $i &> /dev/null
 	echo -ne "(PRELOAD) $testname... "
 	if [ $(timeout 1 ./lockdep ./tests/$testname | wc -l) -gt 0 ]; then
@@ -23,5 +25,7 @@ for i in `ls tests/*.c`; do
 	else
 		echo "FAILED!"
 	fi
-	rm tests/$testname
+	if [ -f "tests/$testname" ]; then
+		rm tests/$testname
+	fi
 done