Skip to contentSkip to conversation

syscalls/acct02: add functional testcase

PATCH Superseded Christian Amann 2 participants 7 messages Jun 4, 2019 – Jun 7, 2019 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 syscalls/acct02: add functional testcase

This patch adds a functional test to verify that the file contents of the process accounting file contains valid and correct data when triggered using the acct() syscall.

---
 configure.ac                                   |   1 +
 include/lapi/acct.h                            |  69 ++++++++++
 m4/ltp-acct.m4                                 |   7 +
 runtest/syscalls                               |   1 +
 testcases/kernel/syscalls/acct/.gitignore      |   2 +
 testcases/kernel/syscalls/acct/acct02.c        | 183 +++++++++++++++++++++++++
 testcases/kernel/syscalls/acct/acct02_helper.c |  16 +++
 7 files changed, 279 insertions(+)
 create mode 100644 include/lapi/acct.h
 create mode 100644 m4/ltp-acct.m4
 create mode 100644 testcases/kernel/syscalls/acct/acct02.c
 create mode 100644 testcases/kernel/syscalls/acct/acct02_helper.c
configure.ac +1 -0
index 5a3dc5b62..5ecc92781 100644
@@ -194,6 +194,7 @@ AC_CONFIG_SUBDIRS([utils/ffsb-6.0-rc2])
 AC_CONFIG_COMMANDS([syscalls.h], [cd ${ac_top_srcdir}/include/lapi/syscalls; ./regen.sh])
 
 # custom functions
+LTP_CHECK_ACCT
 LTP_CHECK_ACL_SUPPORT
 LTP_CHECK_ATOMIC_MEMORY_MODEL
 LTP_CHECK_BUILTIN_CLEAR_CACHE
include/lapi/acct.h new file +69 -0

69 lines not on this page · raw message

m4/ltp-acct.m4 new file +7 -0
new file mode 100644
index 000000000..61bc01947
@@ -0,0 +1,7 @@
+dnl SPDX-License-Identifier: GPL-2.0-or-later
+dnl Copyright (c) 2019 SUSE LLC
+dnl Author: Christian Amann <[email protected]>
+
+AC_DEFUN([LTP_CHECK_ACCT],[
+AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>])
+])
runtest/syscalls +1 -0
index 762b15b1f..e4d506033 100644
@@ -10,6 +10,7 @@ access03 access03
 access04 access04
 
 acct01 acct01
+acct02 acct02
 
 add_key01 add_key01
 add_key02 add_key02
testcases/kernel/syscalls/acct/.gitignore +2 -0
index c2fb15611..08a89756b 100644
@@ -1 +1,3 @@
 /acct01
+/acct02
+/acct02_helper
testcases/kernel/syscalls/acct/acct02.c new file +183 -0

183 lines not on this page · raw message

testcases/kernel/syscalls/acct/acct02_helper.c new file +16 -0
new file mode 100644
index 000000000..66017cb9b
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  Copyright (c) SUSE LLC, 2019
+ *  Author: Christian Amann <[email protected]>
+ */
+/*
+ * Dummy program used in acct02
+ */
+
+#include <unistd.h>
+
+int main(void)
+{
+	sleep(1);
+	return 128;
+}
Signature · 1 line
2.16.4
#1 lore raw

PATCH v2 1/1 syscalls/acct02: add functional testcase

Hi!
Have you tried the test on the !v3 case?

I do have:

CONFIG_BSD_PROCESS_ACCT=y
# CONFIG_BSD_PROCESS_ACCT_V3 is not set

And the test fails with:

tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' tst_test.c:1111: INFO: Timeout per run is 0h 05m 00s tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' acct02.c:159: INFO: Verifying using 'struct acct' acct02.c:137: INFO: Number of accounting file entries tested: 0 acct02.c:142: FAIL: acct() wrote incorrect file contents!

Looks like the file is empty for me...

Signature · 2 lines
Cyril Hrubis
[email protected]
#2 lore raw

PATCH v2 1/1 syscalls/acct02: add functional testcase

Hi,

yes, I have tested it on a system like you describe but I receive a positive output:

tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' tst_test.c:1111: INFO: Timeout per run is 0h 05m 00s tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' acct02.c:159: INFO: Verifying using 'struct acct' acct02.c:137: INFO: Number of accounting file entries tested: 1 acct02.c:140: PASS: acct() wrote correct file contents!

There seems to be something else going wrong. I will investigate this.

Kind regards,

Christian

Quoted 10 lines · Cyril Hrubis

Hi!
Have you tried the test on the !v3 case?

I do have:

CONFIG_BSD_PROCESS_ACCT=y
# CONFIG_BSD_PROCESS_ACCT_V3 is not set

And the test fails with:

Quoted 9 lines

tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' tst_test.c:1111: INFO: Timeout per run is 0h 05m 00s tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' acct02.c:159: INFO: Verifying using 'struct acct' acct02.c:137: INFO: Number of accounting file entries tested: 0 acct02.c:142: FAIL: acct() wrote incorrect file contents!

Looks like the file is empty for me...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190607/b890e306/attachment.html>

#3 lore raw

PATCH v2 1/1 syscalls/acct02: add functional testcase

Hi!

Quoted 11 lines

yes, I have tested it on a system like you describe but I receive a positive output:

tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' tst_test.c:1111: INFO: Timeout per run is 0h 05m 00s tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' acct02.c:159: INFO: Verifying using 'struct acct' acct02.c:137: INFO: Number of accounting file entries tested: 1 acct02.c:140: PASS: acct() wrote correct file contents!

There seems to be something else going wrong. I will investigate this.

May be something wrong at my end as well, what kernel versions have you tested? At my end I tested 4.20.

Signature · 2 lines
Cyril Hrubis
[email protected]
#4 lore raw

PATCH v2 1/1 syscalls/acct02: add functional testcase

Quoted 11 lines · Cyril Hrubis

Hi!

Quoted 10 lines

yes, I have tested it on a system like you describe but I receive a positive output:

tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' tst_test.c:1111: INFO: Timeout per run is 0h 05m 00s tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' acct02.c:159: INFO: Verifying using 'struct acct' acct02.c:137: INFO: Number of accounting file entries tested: 1 acct02.c:140: PASS: acct() wrote correct file contents!

Quoted 4 lines
Quoted 1 line

There seems to be something else going wrong. I will investigate this.

May be something wrong at my end as well, what kernel versions have you tested? At my end I tested 4.20.

I have a 4.19 kernel x86_64 machine running and I double checked that I have the same configs as you have provided.

Still, I have a hard time reproducing the error.

#5 lore raw

PATCH v2 1/1 syscalls/acct02: add functional testcase

Hi!

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

yes, I have tested it on a system like you describe but I receive a positive output:

tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' tst_test.c:1111: INFO: Timeout per run is 0h 05m 00s tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' acct02.c:159: INFO: Verifying using 'struct acct' acct02.c:137: INFO: Number of accounting file entries tested: 1 acct02.c:140: PASS: acct() wrote correct file contents!

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

There seems to be something else going wrong. I will investigate this.

May be something wrong at my end as well, what kernel versions have you tested? At my end I tested 4.20.

I have a 4.19 kernel x86_64 machine running and I double checked that I have the same configs as you have provided.

Still, I have a hard time reproducing the error.

Looks like this is very specific error that happens for me since I have /mnt on my rootfs, it works for any other filesystem I've tried though.

I guess that we can go ahead and push the test then.

Signature · 2 lines
Cyril Hrubis
[email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

PATCH v2 1/1 syscalls/acct02: add functional testcase

Quoted 34 lines · Cyril Hrubis
Quoted 15 lines

Hi!

Quoted 14 lines
Quoted 14 lines
Quoted 11 lines

yes, I have tested it on a system like you describe but I receive a positive output:

tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' tst_test.c:1111: INFO: Timeout per run is 0h 05m 00s tst_kconfig.c:62: INFO: Parsing kernel config '/proc/config.gz' acct02.c:159: INFO: Verifying using 'struct acct' acct02.c:137: INFO: Number of accounting file entries tested: 1 acct02.c:140: PASS: acct() wrote correct file contents!

There seems to be something else going wrong. I will investigate this.

May be something wrong at my end as well, what kernel versions have you tested? At my end I tested 4.20.

Quoted 8 lines
Quoted 4 lines

I have a 4.19 kernel x86_64 machine running and I double checked that I have the same configs as you have provided.

Still, I have a hard time reproducing the error.

Looks like this is very specific error that happens for me since I have /mnt on my rootfs, it works for any other filesystem I've tried though.

I guess that we can go ahead and push the test then.

Maybe we should investigate this a little more, first. I have managed to reproduce the error on two of my systems. Both of them have CONFIG_BSD_PROCESS_ACCT_V3 enabled and no rootfs mounts.

Kernel is 4.2 in both cases.

One of them is x86, the other x86_64

Really strange...