hugetop: Minor adjustments

manpage: Added note that its the number of pages displayed, not storage
size.

Added test for invalid input, used same test-hugetlb as ps fields
to check the tool displays one of the fields correctly.

References:
 !214

Signed-off-by: Craig Small <csmall@dropbear.xyz>
This commit is contained in:
Craig Small 2024-01-31 18:02:20 +11:00
parent 460f0b4010
commit 3aa2a49f0e
4 changed files with 53 additions and 1 deletions

1
.gitignore vendored
View File

@ -37,6 +37,7 @@ Makefile
Makefile.in
missing
mkinstalldirs
src/hugetop
src/pgrep
src/pidof
src/pkill

View File

@ -16,7 +16,10 @@ hugetop \- report huge page information
.SH DESCRIPTION
The
.B hugetop
command reports the huge page information of system and processes.
command reports the huge page information of system and processes. It displays
a summary of the system huge page status. For each process that has a
least one huge page, the number of private and shared pages, along with
the process PID and command name are displayed.
.SH OPTIONS
.TP
\fB\-d\fR, \fB\-\-delay\fR=\fIN\fR

View File

@ -35,6 +35,7 @@ endif
DEJATOOL += \
free \
hugetop \
lib \
pgrep \
pkill \
@ -47,6 +48,7 @@ endif
EXTRA_DIST = \
config/unix.exp \
free.test/free.exp \
hugetop.test/hugetop.exp \
kill.test/kill.exp \
lib.test/fileutils.exp \
lib.test/fileutils_badfd.sh \

View File

@ -0,0 +1,46 @@
#
# checks for hugetop
#
# You may have to enable huge tables for this to be supported
# sudo sh -c 'echo 2 > /proc/sys/vm/nr_hugepages'
#
set hugetop "${topdir}src/hugetop"
set hugetlb "${topdir}testsuite/test-hugetlb"
set kbytes 2048
set hugetop_header "^hugetop - \[A-Za-z0-9: \]+\\s+Size \\d+\[A-Z\], Total \\d+, Free \\d+\\s+PID\\s+SHARED\\s+PRIVATE\\s+COMMAND\\s*$"
set hugetop_row "^\\s+\(\\d+\)\\s+\\d+\\s+\\d+\\s+test-hugetlb\\s*$"
set test "hugetop zero delay"
spawn $hugetop -d 0
expect_pass $test "hugetop: delay must be positive integer"
set test "hugetop alpha delay"
spawn $hugetop -d a
expect_pass $test "hugetop: illegal delay: 'a'"
set meminfo {/proc/meminfo}
set test "hugetop once"
if { [ file readable $meminfo ] != 0 } {
set free_hugetlb 0
set fd [ open $meminfo r]
while {[gets $fd line] != -1} {
set fields [regexp -all -inline {\S+} $line]
if { [lindex $fields 0] eq {HugePages_Free:} } {
set free_hugetlb [lindex $fields 1]
}
}
if [ expr ${free_hugetlb} > 0 ] {
set testproc_pid [ spawn $hugetlb ${kbytes} ]
spawn $hugetop -o
expect_table_dsc $test $hugetop_header $hugetop_row
kill_process $testproc_pid
} else {
unsupported "$test (not enough free HugePages)"
}
} else {
unsupported "$test (meminfo not available)"
}