Skip to contentSkip to conversation

selftests: Use real temporary working directory for archiving

PATCH In review Masami Hiramatsu 3 participants 4 messages Oct 4, 2019 – Oct 9, 2019 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: Use real temporary working directory for archiving

Use real temporary working directory for generating kselftest archive.

tools/testing/selftests/kselftest directory has been used for the temporary working directory for making a tar archive from gen_kselftest_tar.sh, and it removes the directory for cleanup.

However, since the kselftest directory became a part of the repository, it must not be used as a working dir.

Introduce mktemp to prepare a temporary working directory for archiving kselftests.

---
 tools/testing/selftests/gen_kselftest_tar.sh |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/gen_kselftest_tar.sh +4 -4
index a27e2eec3586..eba1e9987ffc 100755
@@ -38,16 +38,16 @@ main()
 	esac
 	fi
 
-	install_dir=./kselftest
+	tmpdir=`mktemp -d ./install-XXXXXX` || exit 1
 
 # Run install using INSTALL_KSFT_PATH override to generate install
 # directory
-./kselftest_install.sh
-tar $copts kselftest${ext} $install_dir
+./kselftest_install.sh $tmpdir
+tar $copts kselftest${ext} -C $tmpdir kselftest
 echo "Kselftest archive kselftest${ext} created!"
 
 # clean up install directory
-rm -rf kselftest
+rm -rf $tmpdir
 }
 
 main "$@"
#1 lore raw
Quoted 35 lines · Masami Hiramatsu

Use real temporary working directory for generating kselftest archive.

tools/testing/selftests/kselftest directory has been used for the temporary working directory for making a tar archive from gen_kselftest_tar.sh, and it removes the directory for cleanup.

However, since the kselftest directory became a part of the repository, it must not be used as a working dir.

Introduce mktemp to prepare a temporary working directory for archiving kselftests.

---
 tools/testing/selftests/gen_kselftest_tar.sh |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/gen_kselftest_tar.sh +1 -3
index a27e2eec3586..eba1e9987ffc 100755
@@ -38,16 +38,16 @@ main()
        esac
        fi
 
-       install_dir=./kselftest
+       tmpdir=`mktemp -d ./install-XXXXXX` || exit 1
 
 # Run install using INSTALL_KSFT_PATH override to generate install
 # directory
-./kselftest_install.sh
-tar $copts kselftest${ext} $install_dir

tools/testing/selftests/gen_kselftest_tar.sh main() · line 53

Quoted 10 lines
tools/testing/selftests/gen_kselftest_tar.sh +3 -1
+./kselftest_install.sh $tmpdir
+tar $copts kselftest${ext} -C $tmpdir kselftest
 echo "Kselftest archive kselftest${ext} created!"
 
 # clean up install directory
-rm -rf kselftest
+rm -rf $tmpdir
 }
 
 main "$@"

FWIW, Acked-by: Jassi Brar <[email protected]>

Signature · 3 lines
Linaro.org │ Open source software for ARM SoCs | Follow Linaro
http://facebook.com/pages/Linaro/155974581091106  -
http://twitter.com/#!/linaroorg - http://linaro.org/linaro-blog
#2 lore raw
In reply to Masami Hiramatsu
Quoted 8 lines

-----Original Message-----
From: Masami Hiramatsu on Thursday, October 03, 2019 7:13 PM

Use real temporary working directory for generating kselftest archive.

Quoted 6 lines

tools/testing/selftests/kselftest directory has been used for the temporary working directory for making a tar archive from gen_kselftest_tar.sh, and it removes the directory for cleanup.

However, since the kselftest directory became a part of the repository, it must not be used as a working dir.

I'm not objecting to the test, but I would like to understand this point better. Under normal circumstances (i.e. when not using O= or KBUILD_OUTPUT) the rest of the kernel directory structure holds generated files.
What is the issue with using kselftest to hold generated files?
-- Tim

Quoted 35 lines

Introduce mktemp to prepare a temporary working directory for archiving kselftests.

---
 tools/testing/selftests/gen_kselftest_tar.sh |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/gen_kselftest_tar.sh +4 -4
index a27e2eec3586..eba1e9987ffc 100755
@@ -38,16 +38,16 @@ main()
 	esac
 	fi
 
-	install_dir=./kselftest
+	tmpdir=`mktemp -d ./install-XXXXXX` || exit 1
 
 # Run install using INSTALL_KSFT_PATH override to generate install
 # directory
-./kselftest_install.sh
-tar $copts kselftest${ext} $install_dir
+./kselftest_install.sh $tmpdir
+tar $copts kselftest${ext} -C $tmpdir kselftest
 echo "Kselftest archive kselftest${ext} created!"
 
 # clean up install directory
-rm -rf kselftest
+rm -rf $tmpdir
 }
 
 main "$@"
#3 lore raw
Quoted 12 lines · On Tue, 8 Oct 2019 23:39:40 +0000 <[email protected]> wrote:
Quoted 12 lines

-----Original Message-----
From: Masami Hiramatsu on Thursday, October 03, 2019 7:13 PM

Use real temporary working directory for generating kselftest archive.

tools/testing/selftests/kselftest directory has been used for the temporary working directory for making a tar archive from gen_kselftest_tar.sh, and it removes the directory for cleanup.

Quoted 7 lines
Quoted 2 lines

However, since the kselftest directory became a part of the repository, it must not be used as a working dir.

I'm not objecting to the test, but I would like to understand this point better. Under normal circumstances (i.e. when not using O= or KBUILD_OUTPUT) the rest of the kernel directory structure holds generated files.
What is the issue with using kselftest to hold generated files?

OK, after running ./gen_kselftest_tar.sh in tools/testing/selftests, I found there is no tools/testing/selftests/kselftest was there. Actually, this was found when I searched "runner.sh" on the tree after building kselftest.tar.gz. I couldn't find it and realized that the gen_kselftest_tar.sh removed kselftest directory.

This is not happen if you run gen_kselftest_tar.sh.

Thank you,

Quoted 38 lines

-- Tim

Quoted 35 lines

Introduce mktemp to prepare a temporary working directory for archiving kselftests.

---
 tools/testing/selftests/gen_kselftest_tar.sh |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/gen_kselftest_tar.sh +4 -4
index a27e2eec3586..eba1e9987ffc 100755
@@ -38,16 +38,16 @@ main()
 	esac
 	fi
 
-	install_dir=./kselftest
+	tmpdir=`mktemp -d ./install-XXXXXX` || exit 1
 
 # Run install using INSTALL_KSFT_PATH override to generate install
 # directory
-./kselftest_install.sh
-tar $copts kselftest${ext} $install_dir
+./kselftest_install.sh $tmpdir
+tar $copts kselftest${ext} -C $tmpdir kselftest
 echo "Kselftest archive kselftest${ext} created!"
 
 # clean up install directory
-rm -rf kselftest
+rm -rf $tmpdir
 }
 
 main "$@"
Signature · 1 line
Masami Hiramatsu <[email protected]>