[LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages

Li Wang liwang@redhat.com
Mon Nov 8 08:31:43 CET 2021


On Fri, Nov 5, 2021 at 12:45 AM Petr Vorel <pvorel@suse.cz> wrote:

> Fix running make test-c as non-root.
>
> Fixes: 057d6b046 ("lib/tst_hugepage: Fix .request_hugepages = 0 bug")
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Hi,
>
> maybe echo "128" would not have to be checked.
>

Agreed, If the system memory is too fragmental to keep
enough hpages, there won't be an error returned.

Reviewed-by: Li Wang <liwang@redhat.com>



>
> Kind regards,
> Petr
>
>  lib/newlib_tests/test_zero_hugepage.sh | 21 ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/lib/newlib_tests/test_zero_hugepage.sh
> b/lib/newlib_tests/test_zero_hugepage.sh
> index d270e686c..663bd2316 100755
> --- a/lib/newlib_tests/test_zero_hugepage.sh
> +++ b/lib/newlib_tests/test_zero_hugepage.sh
> @@ -3,16 +3,31 @@
>  # Copyright (c) 2021 Yang Xu <xuyang2018.jy@fujitsu.com>
>  # Copyright (c) 2021 Petr Vorel <pvorel@suse.cz>
>
> +tconf()
> +{
> +       echo "TCONF: $1"
> +       exit 32
> +}
> +
>  echo "Testing .request_hugepages = TST_NO_HUGEPAGES"
>
>  orig_value=`cat /proc/sys/vm/nr_hugepages`
>
>  if grep -q -E '^proc /proc(/sys)? proc ro' /proc/mounts; then
> -       echo "TCONF: /proc or /proc/sys mounted as read-only"
> -       exit 32
> +       tconf "/proc or /proc/sys mounted as read-only"
> +fi
> +
> +if [ ! -f /proc/sys/vm/nr_hugepages ]; then
> +       tconf "/proc/sys/vm/nr_hugepages does not exist"
> +fi
> +
> +if [ ! -w /proc/sys/vm/nr_hugepages ]; then
> +       tconf "no write permission to /proc/sys/vm/nr_hugepages (run as
> root)"
>  fi
>
> -echo "128" > /proc/sys/vm/nr_hugepages
> +if ! echo "128" > /proc/sys/vm/nr_hugepages; then
> +       tconf "Failed to write /proc/sys/vm/nr_hugepages"
> +fi
>
>  ./test_zero_hugepage
>
> --
> 2.33.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20211108/65642984/attachment-0001.htm>


More information about the ltp mailing list