From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/2] removexattr/removexattr01.c: add new testcase
Date: Thu, 3 Mar 2016 19:08:09 +0100 [thread overview]
Message-ID: <20160303180809.GA14084@rei.lan> (raw)
In-Reply-To: <1455722442-7301-1-git-send-email-yangx.jy@cn.fujitsu.com>
Hi!
> +#ifdef HAVE_ATTR_XATTR_H
> +#define USER_KEY "user.test"
> +#define VALUE "test"
> +#define VALUE_SIZE 4
^
(sizeof(VALUE) - 1)
> +static void verify_removexattr(void);
> +static void setup(void);
> +static void cleanup(void);
> +
> +int TST_TOTAL = 1;
> +
> +int main(int ac, char **av)
> +{
> + int lc;
> +
> + tst_parse_opts(ac, av, NULL, NULL);
> +
> + setup();
> +
> + for (lc = 0; TEST_LOOPING(lc); lc++) {
> + tst_count = 0;
> +
> + verify_removexattr();
> + }
> +
> + cleanup();
> + tst_exit();
> +}
> +
> +static void verify_removexattr(void)
> +{
> + int n;
> + int size = 64;
> + char buf[size];
> +
> + n = setxattr("testfile", USER_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
> + if (n == -1) {
> + if (errno == ENOTSUP) {
> + tst_brkm(TCONF, cleanup, "no xattr support in fs or "
> + "mounted without user_xattr option");
> + } else {
> + tst_brkm(TFAIL | TERRNO, cleanup, "setxattr() failed");
> + }
> + }
> +
> + TEST(removexattr("testfile", USER_KEY));
> + if (TEST_RETURN != 0) {
> + tst_resm(TFAIL, "removexattr() failed");
^
TTERRNO
> + return;
> + }
> +
> + n = getxattr("testfile", USER_KEY, buf, size);
> + if (n != -1) {
> + tst_resm(TFAIL, "getxattr() succeeded unexpectedly");
This is a bit misleading, since we do not say that it succeded for
deleted key. It shoud say something as:
"getxattr() succeded for deleted key"
> + return;
> + }
> +
> + if (errno != ENOATTR)
> + tst_resm(TFAIL | TERRNO, "removexattr() failed");
This message is misleading as well. It was getxattr() what has failed
unexpectedly.
> + else
> + tst_resm(TPASS, "removexattr() succeeded");
> +}
> +
> +static void setup(void)
> +{
> + tst_sig(NOFORK, DEF_HANDLER, cleanup);
> +
> + TEST_PAUSE;
> +
> + tst_tmpdir();
> +
> + SAFE_TOUCH(cleanup, "testfile", 0644, NULL);
> +}
> +
> +static void cleanup(void)
> +{
> + tst_rmdir();
> +}
> +
> +#else /* HAVE_ATTR_XATTR_H */
> +int main(int ac, char **av)
> +{
> + tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
> +}
> +#endif
Otherwise it looks good.
--
Cyril Hrubis
chrubis@suse.cz
prev parent reply other threads:[~2016-03-03 18:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 15:20 [LTP] [PATCH v2 1/2] removexattr/removexattr01.c: add new testcase Xiao Yang
2016-02-17 15:20 ` [LTP] [PATCH v2 2/2] removexattr/removexattr02.c: " Xiao Yang
2016-03-03 18:12 ` Cyril Hrubis
2016-03-04 2:47 ` [LTP] [PATCH v3 1/2] removexattr/removexattr01.c: " Xiao Yang
2016-03-04 2:47 ` [LTP] [PATCH v3 2/2] removexattr/removexattr02.c: " Xiao Yang
2016-03-07 15:54 ` Cyril Hrubis
2016-03-03 18:08 ` Cyril Hrubis [this message]
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=20160303180809.GA14084@rei.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox