@@ -113,6 +113,16 @@ use_siw=1 ./check nvmeof-mp/
use_siw=1 ./check srp/
```
+### Normal user
+
+To run test cases which require normal user privilege, prepare a user and
+specify it to the `NORMAL_USER` variable. The test cases are skipped unless a
+valid user is specified.
+
+```sh
+NORMAL_USER=blktests_user
+```
+
### Custom Setup
The `config` file is really just a bash file that is sourced at the beginning
@@ -799,6 +799,7 @@ fi
: "${LOGGER_PROG:="$(type -P logger || echo true)"}"
: "${RUN_ZONED_TESTS:=0}"
+: "${NORMAL_USER:=''}"
# Sanity check options.
if [[ $QUICK_RUN -ne 0 && ! "${TIMEOUT:-}" ]]; then
@@ -381,6 +381,14 @@ _require_test_dev_is_partition() {
return 0
}
+_require_normal_user() {
+ if ! id "$NORMAL_USER" >/dev/null 2>&1; then
+ SKIP_REASONS+=("valid NORMAL_USER is not specfied")
+ return 1
+ fi
+ return 0
+}
+
# Prints a space-separated list with the names of all I/O schedulers supported
# by block device $1.
_io_schedulers() {
@@ -409,3 +417,8 @@ _have_writeable_kmsg() {
fi
return 0
}
+
+# Run the given command as NORMAL_USER
+_run_user() {
+ su "$NORMAL_USER" -c "$1"
+}
To run commands with normal user privilege, add a new config variable NORMAL_USER and two helper functions _run_user and _require_normal_user. The user name specified to NORMAL_USER is used to run the commands specified to _run_user. The test cases which require NORMAL_USER shall call _require_normal_user to ensure the NORMAL_USER is valid. Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> --- Documentation/running-tests.md | 10 ++++++++++ check | 1 + common/rc | 13 +++++++++++++ 3 files changed, 24 insertions(+)