Commit Graph

94 Commits

Author SHA1 Message Date
Craig Small
a7aaeaef65 sysctl: print dotted keys again
When the globbing update was put into sysctl, you could no longer
simply use the keys because one key could potentially be
multiple paths once the glob expansion occured.  Using the path
instead gave a unique output.

Except certain programs, such as salt, expected the output to use
the dotted path "kernel.hostname" and not "kernel/hostname".

We can no longer use the original key, so now for each path:
  Copy the path
  strip off /proc/
  convert all / to .

The sysctl testsuite was also updated to check for a few different
types of conversion failures.

References:
 commit 6389deca5b
 https://www.freelists.org/post/procps/some-procpsn4400-fixes,4
 https://repo.saltproject.io/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-04-09 14:33:34 +10:00
Craig Small
474847ed35 sysctl: Support systemd glob patterns
systemd-sysctl handles glob patterns along with overrides and
exceptions. Now the procps sysctl does it too.

The return value for sysctl is consistently either 0 or 1.

Added tests to check sysctl functions.

References:
 procps-ng/procps#191

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-09-13 22:07:37 +10:00
Craig Small
3dcaf97773 ps: Add NEWS and test for exe output
Only need this for master, as Jim took care of exe
handling for newlib in the ad4269 change.

References:
 commit b556bf5ba8
 commit ad4269f118
2020-12-22 15:31:39 +11:00
Craig Small
fa389631ca build-sys: Make pwait test dependent on pwait built
As pwait building is conditional, testsuite should
only run pwait tests if there is a pwait binary.
2020-12-22 15:21:39 +11:00
Craig Small
4a54ae97a0 testsuite: Add pwait tests
They're pretty simple tests but its something.

References:
  commit 09327c2b77
2020-12-22 12:25:44 +11:00
Craig Small
4090fa711b build-sys: Enable testing of sigqueue
The referenced commits enavled both pkill and kill to send an integer to
the killed or signalled process. The test_process now will report on the
integer if sent and the testsuite changes take advantage of this
new feature.

Another process make/destroy set had to be made as using spawn
instead of exec changes both the SID and TTY for the underlying
process, making other tests fail.

References:
 commit 7d55409b82
 commit 2b804a532a
2020-04-28 19:47:39 +10:00
Arun Chandrasekaran
2b804a532a kill: use sigqueue to pass value with the signal.
New -q/--queue option for kill so it will send an integer to the
signalled process. See sigqueue(3) for details.

References:
 https://pubs.opengroup.org/onlinepubs/009695399/functions/sigqueue.html
 procps-ng/procps!32

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2020-04-24 19:22:47 +10:00
Clay Baenziger
f5fbbdbef8 testsuite: pgrep: Provide test for matching a more than 4k command line; beware as TCL does not seem to match on strings >4k 2019-09-21 16:39:13 +10:00
Craig Small
2fed385ac2 testsuite: Remove pgrep ?15 char test
The referenced commit removed the warning for using pgrep with over
15 characters. The check for this warning needs to also be removed.

References:
 commit c32ab58b94
2018-05-19 21:50:21 +10:00
Craig Small
ca07bcad4d misc: fix ps etime tests
The test assumes only one process appears which, depending on the
speed of things, may not be true. It now matches one to many process
lines.
2018-04-10 22:09:40 +10:00
Craig Small
5d0b094b8c ps: Add NEWS and checks for times and cputimes
The previous commit had one minor bug in it because the fields need
to be alphabetical and times comes after timeout.

Added NEWS item for this feature
Added another testsuite check for new flags in case they
disappear or go strange one day.

References:
 commit 8a94ed6111
2018-03-02 22:07:46 +11:00
Craig Small
e82dd07b3b free: Update tests and fix for previous patch
The previous two patches updated free, but needed a tweak and the tests
also needed to be updated. I've hand-calculated the results using bc and
both the testsuite and bc results equal what free prints out.

References:
 commit 9365be7633
 procps-ng/procps#45
2018-01-13 16:09:54 +11:00
Wayne Porter
53e101452f Consolidated patch of previously merged CYGWIN support
The combined results of merge request #49 without that
overhead plus distortion in this repository's history.

Prototyped-by: Wayne Porter <wporter82@gmail.com>
2017-09-03 20:59:23 +10:00
Craig Small
536cea324b kill: -l space between name parses correctly
kill -lHUP would work correctly, but kill -l HUP would not.

The list option in kill was hit by a quirk of getopt_long where an
option with an optional argument would not attempt to get the argument
beyond the space, even though a mandatory argument would do that.

The fix is a kludge to scan to the next argument and if it looks
like something we can use, use it. Lucky for us, the list option is
one where parsing can stop immediately.

Thanks to Brian Vandenberg for the way forward.

References:
 http://stackoverflow.com/questions/1052746/getopt-does-not-parse-optional-arguments-to-parameters
 https://bugs.debian.org/854407
2017-02-07 22:05:18 +11:00
Jan Rybar
1aacf4af7f pgrep: warning about 15+ chars name only if zero matches found
This avoids situations where longer regex which matches short-named proc is used.
Test for pgrep updated.
2017-01-02 14:50:22 +01:00
Craig Small
24fd2605c5 pgrep: Fix off by one error in line check
There is now a warning if your command is longer than 15 characters
and therefore can never match. Except it was checking for more than
16 characters.

Adjusted this and added a test case.

References:
 !25
 commit 8e8835b2ee
2016-09-11 10:11:25 +10:00
Olof Sivertsson
586bfb7655 kill: Fix free() with bad pointer on SIG-prefixed signal-name
kill -l SIGHUP (or any other signal-name prefixed with "SIG")
would cause free() to be called with a bad pointer instead of
a pointer to what was allocated. Fix this and add test-case.
2016-09-08 22:32:18 +02:00
Craig Small
6118be808c misc: testsuite to source aux scripts correctly
Because I don't know how to redirect properly in tcl, there are
some small scripts that do this for me. With your standard
make check, all is good because the scripts and the binary are
in the usual spots.

make distcheck however puts them all over the place. The binary is
in a different tree to the test and aux scripts. The change now
tells where aux script where its binary is.
2016-07-10 09:04:44 +10:00
Craig Small
1ec2b0eeb1 testsuite: kill test fails on signal names
Some archs have + and - in their signal names, such as hppa
which comes with signals such as RTMIN+-9 RTMIN+-8
The kill -l test failed because of this, we now accept these
odd names.

References:
 https://bugs.debian.org/762764
 https://buildd.debian.org/status/fetch.php?pkg=procps&arch=hppa&ver=1%3A3.3.10-1&stamp=1411601407
2016-01-03 18:20:45 +11:00
Craig Small
898e3cc3cf testsuite: fix ps signals test
On some setups the signals count can change and be truncated. You
will notice this because the number will have "<" prepended. The
testsuite didn't handle this.
You could either get:
         BLOCKED          BLOCKED          BLOCKED           CAUGHT
CAUGHT          CATCHED
0000000000000000 0000000000000000 0000000000000000 00000001f3d1fef9 00000001f3d1fef9 00000001f3d1fef9

or
  BLOCKED   BLOCKED   BLOCKED    CAUGHT    CAUGHT   CATCHED
 00000000  00000000  00000000 <f3d1fef9 <f3d1fef9 <f3d1fef9
2015-06-14 15:20:48 +10:00
Craig Small
eb6190e61a Do not link test process to libprocps
The test process introduced at 420cd9c7 incorrectly linked to
libprocps which made the CI runner fail.
2015-06-14 08:54:59 +10:00
Craig Small
54fdbb19a2 Skip tests where /proc/vmstat unreadable
testsuite would fail if /proc/vmstat was unreadable.
Issue #3 brought up by Mike Frysinger.
test script explicitly checks to see if it is readable and
sets these tests to unsupported if not.
2015-06-13 15:13:39 +10:00
Craig Small
420cd9c7c2 Create test process
For the test suite, procps used to use sleep which would just
create a process or two to test the tools against.  Some setups
coreutils creates all programs including sleep into one blob which
means a lot of the tests fail, see issue #2

procps has its own sleep program now.
2015-06-13 15:04:31 +10:00
dmarc-noreply@freelists.org
e40b0060c2 tests: slabinfo should not be too strict about slab names
Before this commit, the test checking `vmstat -m` (slabinfo) output uses
a fairly strict regular expression that only allows alphanumeric
characters and a few exceptions such as "_", "-", "(" and ")".

However, recent kernels use a wider range of characters, such as ">".
For instance, see this Linux commit which creates a "page->ptl" slab:
  https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/mm/memory.c?id=b35f1819acd9243a3ff7ad25b1fa8bd6bfe80fb2#n4283

Other patches for reporting slab usage per memcg include the names of
the cgroup in the slabinfo output, which can include additional
characters and use dots for abbreviation.

The check should not be so string, instead it could simply look for a
chain of non-whitespace characters and that should be enough.

Tested that `make check` is still working, including in some of the
environments where features that enable the additional slabinfo names.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Signed-off-by: Craig Small <csmall@enc.com.au>
2015-05-10 15:05:28 +10:00
dmarc-noreply@freelists.org
af6e264b46 tests: fix regexp in ps_sched_batch.exp to match in first line
The current regexp checks for a \s+ in the beginning, however that will
only match if there is a \n in the `ps` output before test-schedbatch,
but that will not happen if test-schedbatch is the first process in the
list, which happens if the PID of test-schedbatch is low enough to bring
it up in the sorted list.

Fix it by enabling newline-sensitive matching with (?n) which then
allows using ^ and $ anchors in the regexp (including an optional \r
introduced by expect.) Matching the end of line also improves checking
that the last field matches 18 exactly and not something like 181, etc.

Tested that `make check` does not break and also fixed the flakiness
seen in an environment with few processes running under the test user
which made the issue more frequent.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Signed-off-by: Craig Small <csmall@enc.com.au>
2015-05-10 15:05:02 +10:00
dmarc-noreply@freelists.org
e981f2bbd2 tests: do not mark ps_sched_batch.exp as untested
Right now the test case is both testing it (expect_pass "$test") and
marking it as untested (untested "$test"), it should do either one or
the other, so stop marking it as untested.

Before this change, these lines appear in testsuite/ps.log or the output
of `make check RUNTESTFLAGS="--all"`:

  PASS: ps SCHED_BATCH scheduler
  UNTESTED: ps SCHED_BATCH scheduler

Note that the second line is confusing, it's implying that the test is
untested, right after having tested it and indicated it passes.

After this change, only the first line will appear.

Tested that both `make check` and `make distcheck` continue working with
this commit.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Signed-off-by: Craig Small <csmall@enc.com.au>
2015-05-10 15:04:46 +10:00
Craig Small
e0256d1fd6 revert ps_sched checks for following commits 2015-05-10 15:04:19 +10:00
Craig Small
34a1194af8 pgrep SID=1 is valid
On most systems the only process with a SID=1 is init
and certainly not a test sleep.  On docker systems this
test program IS on SID=1 and so our "impossible SID" becomes
possible.
2015-05-09 17:53:08 +10:00
Craig Small
4050148a45 Fix some sched and tty tests
The ps sched test has been disabled. There are too many
odd build farms this fails in strange ways.

Other odd build farms have no tty and so some tests check
for no tty and skip if not found.
2015-05-09 17:48:12 +10:00
Craig Small
f8e98b65ae free: Use IEC units
Free always used 1024 based units but used the confusing old style
kilo,mega etc.

This change changes the names to kibi,mebi for 1024 based divisors
and kilo,mega for 1000 based divisors or IEC units.

It also checks if you try to set two units, e.g free -k -m
Petabyte and Pebibyte have been added.

If you used to use the long options such as --mega these will now
actually print megabytes (they previously printed mebibytes).
The short options are being used on the IEC units

References: https://www.gitorious.org/procps/procps/merge_requests/38

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-04-03 19:18:58 +11:00
Craig Small
12f13f9fc2 Update free testsuite
free got a makeover to suit the newer kernel memory management.
This commit updates the tests to follow the new output for free

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-08-19 22:43:33 +10:00
Craig Small
cacba5613e Reliably kill test processes
It seems command -v also includes built-ins so checking for kill
is useless because it finds the built-in and those machines or
environments that have no /bin/kill fail at the check stage.
Oh and then TCL exec doesn't spawn a shell.

After reading way too many TCL websites, I believe this should
fix the problem. TCL quoting is... different to say the least but
it works reliably here. The script now even picked up a typo elsewhere
which was nice.

This change should stop the intermittent FTBFS bugs from the Debian
pbuilders, I hope! You'd think kill $var wouldn't be this difficult.
2014-07-01 18:51:21 +10:00
Craig Small
f4cc9720ee Reduced partition type check
vmstat -p checks used to fail on systems with odd
partition tables, including some Debian buildd servers.
This change limits what sort of test partitions are used,
otherwise the test is skipped.

There probably are other valid partitions, these can be added
later, if known.
2014-05-27 20:49:16 +10:00
Craig Small
8e7ef322e2 Update help files
Benno Schulenberg suggested some changes to the help messages
to provide some consistency and clarity for both the users and
translators of procps.

The test needed to be updated as the pmap output changed too.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-02-02 18:13:01 +11:00
Craig Small
5a34ff0a99 Check for presence of disks in vmstat
vmstat -d or vmstat -p would crash mysteriously under different
circumstances. The problem was eventually tracked down to /sys not
being mounted which meant is_disk() always returned false.
The partition would then be attempted to be linked to a non-existent
disk causing a segfault.

vmstat will now not link to a disk if none exists.
The change in testing will skip those tests when /sys/block doesn't
exist.

Many thanks to Daniel Schepler for his analysis and suggestions.

Bug-Debian: http://bugs.debian.org/736628
2014-01-29 22:22:11 +11:00
Craig Small
91ff7c6e22 Fixed check for vmstat with stolen time
Commit a8a4a4f added stolen time to vmstat, but broke the checks as
we have another column. This commit fixes the checks
2013-12-03 22:08:30 +11:00
Craig Small
422a4a5e67 Skip some tests if kill cannot be found
Some Debian pbuilders error out on some of the tests because
they cannot find kill to kill the test processes. Now if we
cannot find kill we skip those lot of tests.

Still need to work out why the S390 doesn't like test_sched

References: http://bugs.debian.org/725743
2013-10-09 19:18:55 +11:00
Craig Small
b83788993b Conditional test vmstat -p 2013-07-31 21:54:53 +10:00
Gilles Espinasse
f0b7271810 procps-ng testsuite : simplify DEJAGNU workaround
No need to distribute an empty file
/dev/null is enought to silent global config file warning

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
2013-05-26 07:32:02 +10:00
Gilles Espinasse
ab7009888e procps-ng : tests, remove which dependency
which is a separate package that may not be available and is not yet build on Linux from scratch build order.
Instead use posix command -v. command -v  is a builtin working with bash-4.2, 3.0.25 or even old bash-2.05 or current debian dash

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
2013-05-26 07:30:16 +10:00
Gilles Espinasse
53b253b75a skip kill test too if running runtest
I find more readable instead of make check to run
cd testsuite && make site.exp && DEJAGNU=global-conf.exp runtest

But in that case, kill.exp was still trying to run with
ERROR: tcl error sourcing ./kill.test/kill.exp.
ERROR: couldn't execute "/usr/src/procps-ng-3.3.7/kill": no such file or
directory
...

Simply return from test if kill is not build

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
2013-05-26 07:25:55 +10:00
Pierre Labastie
1b63eb8671 Improved regexp test for pmap
The change in pmap is necessary if it happens that the whole output of
pmap -X or -XX has been done before the second regexp is matched. Since
the matching is greedy, it is matched by the full output, so that
nothing is left for the third regexp and the test fails with
FAIL: extra extended output (footer).

Reference: http://comments.gmane.org/gmane.linux.lfs.devel/13961

Signed-off-by: Craig Small <csmall@enc.com.au>
2013-04-07 18:31:26 +10:00
Gilles Espinasse
a059034856 Revert "Fixed last_value for loops over 99999"
This reverts bogus commit 2840d7f4c6.
99 was already added with 7f15f07b3f

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
2013-04-07 08:30:48 +10:00
Craig Small
2840d7f4c6 Fixed last_value for loops over 99999
For large loops, the value 999,999 was big, but not big enough.

References: http://www.linuxfromscratch.org/lfs/view/development/chapter06/procps-ng.html
2013-03-25 21:56:23 +11:00
Craig Small
0696570a94 Conditionally test kill when we compile it 2013-03-25 21:46:17 +11:00
Jim Warner
f85439e42d pmap: restore a proper response when arguments missing
Ever since pmap was refactored via the reference below
(and sprinkled with those damn tabs), the response for
the absence of any argument has been an error message.

This patch restores the proper behavior ('usage' text)
and updates the dejagnu 'no arguments' expect pattern.

Reference(s):
commit d50884788d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-18 18:42:07 +01:00
Jaromir Capik
7f15f07b3f testsuite: increasing the upper limit of permitted values
This commit increases the upper limit of permitted values
in the expect_table_dsc procedure from 999,999 to 99,999,999.
The previous value was insufficient and causing the slabtop test
to fail on build systems where the number of objects exceeds
one milion.
2013-03-14 14:31:03 +01:00
Jim Warner
fe75e26ab6 miscellaneous: clean up trailing whitespace throughout
The entire tree's polluted with inappropriate trailing
whitespace. This commit rids our environment of all of
those useless keystrokes. Unfortunately, it sure ain't
a permanent solution and requires every contributor to
instruct their editor(s) to prevent or eliminate them.

Plus it's strongly recommended we all insert something
like what's shown below to our '.gitconfig' file so as
to provide at least some warnings when we try to apply
any patches (git am) that do contain the #@!%& things!

References(s):
~/.gitconfig excerpt ---------------------------------
[core]
  whitespace = trailing-space, space-before-tab, blank-at-eof
[apply]
  whitespace = warn
--------------------------------- ~/.gitconfig excerpt

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-14 12:36:47 +01:00
Craig Small
0e6e79522b test for previous commit
Add a test routine to test for --since option added to uptime in
previous commit
2012-12-26 23:21:44 +11:00
Craig Small
1f1201f896 Added pmap -X and -XX tests
The two extra extended pmap options were not tested previously.
We test against our known process and process 1 which we should
not be able to get data for.

Unfortunately, the tests cannot catch SEGSEGVs but they should.

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-12-24 10:05:24 +11:00