* [LTP] [PATCH v2] acct01: add a check routine for acct implementation
@ 2013-11-06 1:55 Honggyu Kim
2013-11-06 2:29 ` Wanlong Gao
0 siblings, 1 reply; 2+ messages in thread
From: Honggyu Kim @ 2013-11-06 1:55 UTC (permalink / raw)
To: ltp-list
A check routine for acct implementation is added at the beginning of the test.
check_acct_in_kernel function calls acct(NULL) and checks if errno is ENOSYS.
It means that acct system call is not implemented in kernel.
The other ENOSYS check routines in setup are removed.
This patch prevents from unintentional calling acct again in cleanup, which
makes TCONF to TBROK and helps configuration problems stay as TCONF.
Previous test output: (becomes TBROK in the end)
acct01 1 TCONF : BSD process accounting is not configured in this kernel
acct01 2 TCONF : Remaining cases not appropriate for configuration
acct01 3 TBROK : acct(NULL) failed: errno=ENOSYS(38): Function not implemented
Fixed test output: (stays as TCONF)
acct01 1 TCONF : BSD process accounting is not configured in this kernel
Signed-off-by: Honggyu Kim <hong.gyu.kim@lge.com>
---
testcases/kernel/syscalls/acct/acct01.c | 32 +++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/testcases/kernel/syscalls/acct/acct01.c b/testcases/kernel/syscalls/acct/acct01.c
index 8236042..4a34383 100644
--- a/testcases/kernel/syscalls/acct/acct01.c
+++ b/testcases/kernel/syscalls/acct/acct01.c
@@ -124,12 +124,28 @@ int main(int argc, char *argv[])
tst_exit();
}
+static void check_acct_in_kernel(void)
+{
+ /* check if acct is implemented in kernel */
+ if (acct(NULL) == -1) {
+ if (errno == ENOSYS) {
+ tst_resm(TCONF,
+ "BSD process accounting is not configured in "
+ "this kernel");
+
+ tst_exit();
+ }
+ }
+}
+
static void setup(void)
{
int fd;
tst_require_root(NULL);
+ check_acct_in_kernel();
+
tst_tmpdir();
ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
@@ -138,24 +154,12 @@ static void setup(void)
SAFE_CLOSE(cleanup, fd);
if (acct(TEST_FILE5) == -1) {
- if (errno == ENOSYS) {
- tst_brkm(TCONF, cleanup,
- "BSD process accounting is not configured in "
- "this kernel");
- } else {
- tst_brkm(TBROK | TERRNO, cleanup, "acct failed unexpectedly");
- }
+ tst_brkm(TBROK | TERRNO, cleanup, "acct failed unexpectedly");
}
/* turn off acct, so we are in a known state */
if (acct(NULL) == -1) {
- if (errno == ENOSYS) {
- tst_brkm(TCONF, cleanup,
- "BSD process accounting is not configured in "
- "this kernel");
- } else {
- tst_brkm(TBROK | TERRNO, cleanup, "acct(NULL) failed");
- }
+ tst_brkm(TBROK | TERRNO, cleanup, "acct(NULL) failed");
}
/* ELOOP SETTING */
--
1.7.9.5
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH v2] acct01: add a check routine for acct implementation
2013-11-06 1:55 [LTP] [PATCH v2] acct01: add a check routine for acct implementation Honggyu Kim
@ 2013-11-06 2:29 ` Wanlong Gao
0 siblings, 0 replies; 2+ messages in thread
From: Wanlong Gao @ 2013-11-06 2:29 UTC (permalink / raw)
To: Honggyu Kim; +Cc: ltp-list
On 11/06/2013 09:55 AM, Honggyu Kim wrote:
> A check routine for acct implementation is added at the beginning of the test.
> check_acct_in_kernel function calls acct(NULL) and checks if errno is ENOSYS.
> It means that acct system call is not implemented in kernel.
> The other ENOSYS check routines in setup are removed.
>
> This patch prevents from unintentional calling acct again in cleanup, which
> makes TCONF to TBROK and helps configuration problems stay as TCONF.
>
> Previous test output: (becomes TBROK in the end)
> acct01 1 TCONF : BSD process accounting is not configured in this kernel
> acct01 2 TCONF : Remaining cases not appropriate for configuration
> acct01 3 TBROK : acct(NULL) failed: errno=ENOSYS(38): Function not implemented
>
> Fixed test output: (stays as TCONF)
> acct01 1 TCONF : BSD process accounting is not configured in this kernel
>
> Signed-off-by: Honggyu Kim <hong.gyu.kim@lge.com>
> ---
> testcases/kernel/syscalls/acct/acct01.c | 32 +++++++++++++++++--------------
> 1 file changed, 18 insertions(+), 14 deletions(-)
Applied with removing the unnecessary braces, thank you.
Wanlong Gao
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-06 2:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-06 1:55 [LTP] [PATCH v2] acct01: add a check routine for acct implementation Honggyu Kim
2013-11-06 2:29 ` Wanlong Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox