* [LTP] [PATCH] syscalls/getdtablesize01: Add abnormal handling
@ 2021-04-07 8:21 zhaogongyi
0 siblings, 0 replies; 3+ messages in thread
From: zhaogongyi @ 2021-04-07 8:21 UTC (permalink / raw)
To: ltp
Hi Petr,
Thanks for your review!
I have resubmit the patch and rewrite the getdtablesize01.c with new api.
See https://patchwork.ozlabs.org/project/ltp/patch/20210407081415.8353-1-zhaogongyi@huawei.com/
Thanks!
Best Regards,
Gongyi
>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [LTP] [PATCH] syscalls/getdtablesize01: Add abnormal handling
2021-03-30 12:20 Zhao Gongyi
@ 2021-04-06 13:30 ` Petr Vorel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2021-04-06 13:30 UTC (permalink / raw)
To: ltp
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [LTP] [PATCH] syscalls/getdtablesize01: Add abnormal handling
@ 2021-03-30 12:20 Zhao Gongyi
2021-04-06 13:30 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Zhao Gongyi @ 2021-03-30 12:20 UTC (permalink / raw)
To: ltp
When /etc/hosts is not exist, test would fail, actually, we chould skip the
the problem to improve maintainability.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
testcases/kernel/syscalls/getdtablesize/getdtablesize01.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/testcases/kernel/syscalls/getdtablesize/getdtablesize01.c b/testcases/kernel/syscalls/getdtablesize/getdtablesize01.c
index d25cac261..25d10d5fb 100644
--- a/testcases/kernel/syscalls/getdtablesize/getdtablesize01.c
+++ 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));
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-07 8:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 8:21 [LTP] [PATCH] syscalls/getdtablesize01: Add abnormal handling zhaogongyi
-- strict thread matches above, loose matches on Subject: below --
2021-03-30 12:20 Zhao Gongyi
2021-04-06 13:30 ` Petr Vorel
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.