* [to-be-updated] selftests-proc-add-proc-pid-statm-output-validation.patch removed from -mm tree
@ 2023-10-02 15:32 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2023-10-02 15:32 UTC (permalink / raw)
To: mm-commits, shuah, hughd, adobriyan, swarupkotikalapudi, akpm
The quilt patch titled
Subject: selftests: proc: add /proc/$(pid)/statm output validation
has been removed from the -mm tree. Its filename was
selftests-proc-add-proc-pid-statm-output-validation.patch
This patch was dropped because an updated version will be merged
------------------------------------------------------
From: Swarup Laxman Kotiaklapudi <swarupkotikalapudi@gmail.com>
Subject: selftests: proc: add /proc/$(pid)/statm output validation
Date: Sun, 1 Oct 2023 22:38:16 +0530
Add /proc/${pid}/statm validation
/proc/$(pid)/statm output is expected to be:
"0 0 0 * 0 0 0\n"
Here * can be any value
Read output of /proc/$(pid)/statm
and compare length of output is
equal or greater than expected output
Link: https://lkml.kernel.org/r/20231001170816.28241-1-swarupkotikalapudi@gmail.com
Signed-off-by: Swarup Laxman Kotiaklapudi <swarupkotikalapudi@gmail.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
tools/testing/selftests/proc/proc-empty-vm.c | 38 ++++++++++++++---
1 file changed, 33 insertions(+), 5 deletions(-)
--- a/tools/testing/selftests/proc/proc-empty-vm.c~selftests-proc-add-proc-pid-statm-output-validation
+++ a/tools/testing/selftests/proc/proc-empty-vm.c
@@ -302,6 +302,37 @@ static int test_proc_pid_smaps_rollup(pi
}
}
+static const char g_statm[] = "0 0 0 * 0 0 0\n";
+
+static int test_proc_pid_statm(pid_t pid)
+{
+ char buf[4096];
+
+ snprintf(buf, sizeof(buf), "/proc/%u/statm", pid);
+
+ int fd = open(buf, O_RDONLY);
+
+ if (fd == -1) {
+ if (errno == ENOENT) {
+ /*
+ * /proc/${pid}/statm is under CONFIG_PROC_PAGE_MONITOR,
+ * it doesn't necessarily exist.
+ */
+ return EXIT_SUCCESS;
+ }
+ perror("open /proc/${pid}/statm");
+ return EXIT_FAILURE;
+ } else {
+ ssize_t rv = read(fd, buf, sizeof(buf));
+
+ close(fd);
+ size_t len = strlen(g_statm);
+
+ assert(rv >= len);
+ return EXIT_SUCCESS;
+ }
+}
+
int main(void)
{
int rv = EXIT_SUCCESS;
@@ -388,11 +419,8 @@ int main(void)
if (rv == EXIT_SUCCESS) {
rv = test_proc_pid_smaps_rollup(pid);
}
- /*
- * TODO test /proc/${pid}/statm, task_statm()
- * ->start_code, ->end_code aren't updated by munmap().
- * Output can be "0 0 0 2 0 0 0\n" where "2" can be anything.
- */
+ if (rv == EXIT_SUCCESS)
+ rv = test_proc_pid_statm(pid);
/* Cut the rope. */
int wstatus;
_
Patches currently in -mm which might be from swarupkotikalapudi@gmail.com are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-02 15:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-02 15:32 [to-be-updated] selftests-proc-add-proc-pid-statm-output-validation.patch removed from -mm tree Andrew Morton
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.