public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/getdtablesize01: Add abnormal handling
Date: Tue, 6 Apr 2021 15:30:57 +0200	[thread overview]
Message-ID: <YGxikZJsqr7Knlc8@pevik> (raw)
In-Reply-To: <20210330122041.19700-1-zhaogongyi@huawei.com>

Hi,

> When /etc/hosts is not exist, test would fail, actually, we chould skip the
> the problem to improve maintainability.

...
> +++ b/testcases/kernel/syscalls/getdtablesize/getdtablesize01.c
> @@ -100,6 +100,8 @@ int main(void)
>  		tst_resm(TPASS, "%d = %d", count, (max_val_opfiles - 1));
>  	else if (fd < 0 && errno == ENFILE)
>  		tst_brkm(TCONF, cleanup, "Reached maximum number of open files for the system");
> +	else if (fd == 0)
> +		tst_brkm(TCONF, cleanup, "Maybe /etc/hosts is not exist");
>  	else
>  		tst_resm(TFAIL, "%d != %d", count, (max_val_opfiles - 1));

Why not to test for existence of the file in main(), where is file being opened?

	fd = open("/etc/hosts", O_RDONLY);

Also current patch does not work when I test on system without /etc/hosts:

./getdtablesize01
getdtablesize01    0  TINFO  :  Maximum number of files a process can have opened is 1024
getdtablesize01    0  TINFO  :  Checking with the value returned by getrlimit...RLIMIT_NOFILE
getdtablesize01    1  TPASS  :  got correct dtablesize, value is 1024
getdtablesize01    0  TINFO  :  Checking Max num of files that can be opened by a process.Should be: RLIMIT_NOFILE - 1
getdtablesize01    2  TFAIL  :  getdtablesize01.c:106: 0 != 1023

Besides, it'd help to also rewrite the test to the new API.

Kind regards,
Petr

  reply	other threads:[~2021-04-06 13:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30 12:20 [LTP] [PATCH] syscalls/getdtablesize01: Add abnormal handling Zhao Gongyi
2021-04-06 13:30 ` Petr Vorel [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-04-07  8:21 zhaogongyi

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=YGxikZJsqr7Knlc8@pevik \
    --to=pvorel@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