From: Cyril Hrubis <chrubis@suse.cz>
To: Yang Xu <xuyang2018.jy@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] sysctl/sysctl03: Test whether return EINVAL when passing negative value
Date: Fri, 28 Jan 2022 11:31:42 +0100 [thread overview]
Message-ID: <YfPGDmF0UFFjeABu@yuki> (raw)
In-Reply-To: <1643349071-2164-1-git-send-email-xuyang2018.jy@fujitsu.com>
Hi!
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2022 FUJITSU LIMITED. All rights reserved.
> +# Author: Yang Xu <xuyang2018.jy@fujitsu.com>
> +#
> +# When we pass a negative value to the proc_doulongvec_minmax() function,
> +# the function should return EINVAL and the corresponding interface value
> +# does not change.
> +#
> +# It is also a regression test for
> +# commit 1622ed7d0743 ("sysctl: returns -EINVAL when a negative value is passed
> +# to proc_doulongvec_minmax").
> +#
> +# Use fs.epoll.max_user_watches interface to test this.
> +
> +TST_TESTFUNC=do_test
> +TST_SETUP=setup
> +TST_NEEDS_ROOT=1
> +TST_NEEDS_CMDS="sysctl"
> +TST_NEEDS_KCONFIGS="CONFIG_SYSCTL=y, CONFIG_PROC_FS=y, CONFIG_INOTIFY_USER=y"
> +sys_name="fs.epoll.max_user_watches"
> +sys_file="/proc/sys/fs/epoll/max_user_watches"
> +
> +. tst_test.sh
> +
> +setup()
> +{
> + orig_value=$(cat "$sys_file")
> +}
> +
> +do_test()
> +{
> + tst_res TINFO "trying to set $sys_name=-1"
> +
> + sysctl -w -q $sys_name=-1 2>&1 | grep -q "Invalid argument"
> +
> + if [ $? -eq 0 ]; then
> + tst_res TPASS "sysctl returns EINVAL when passing a negative value"
> + else
> + tst_res TFAIL "sysctl doesn't return EINVAL when passing a negative value"
> + fi
> +
> + new_value=$(cat "$sys_file")
> + if [ $orig_value -eq $new_value ]; then
> + tst_res TPASS "the interface value doesn't change when passing a negative value"
> + else
> + tst_res TFAIL "the interface value changes when passing a negative value"
> + sysctl -w -q $sys_name=$orig_value
> + fi
> +}
> +
> +tst_run
I'm just wondering if this wouldn't be actually easier as a C test. I
bet that simple write() to the sys_file would work exactly the same and
we wouldn't depend on sysctl being present on the system.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-01-28 10:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 5:51 [LTP] [PATCH] sysctl/sysctl03: Test whether return EINVAL when passing negative value Yang Xu
2022-01-28 10:31 ` Cyril Hrubis [this message]
2022-01-30 2:24 ` xuyang2018.jy
2022-02-16 12:59 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YfPGDmF0UFFjeABu@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=xuyang2018.jy@fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.