Commit Graph

30 Commits

Author SHA1 Message Date
Craig Small
fc960774d5 testsuite: Make test program compile on Hurd
procps fails to build from source due to usage of field si_int of struct
siginfo_t in lib/test_process.c which does not exist on GNU/Hurd.

Thanks to Svante Signell for the patch.

References:
 https://bugs.debian.org/987557

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-10-13 07:59:04 +11:00
Jan Rybar
a1bc3bf207 Coverity scan findings - memleaks, unused vars, potential nullptr dereferences 2021-05-06 16:32:11 +02: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
Dr. Werner Fink
4ed44ab58e misc: fix strtod_nol_err tests
A better way of implementing the string to double
conversion and a better way of testing it.

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-07-13 20:08:51 +10:00
Craig Small
aa9bd38d0a tests: Conditionally add prctl to test process
prctl was already bypassed on Cygwin systems. This extends to
non-Linux systems such as kFreeBSD and Hurd.

References:
 https://bugs.debian.org/816237
2016-04-17 09:09:41 +10:00
Wayne Porter
eea5e467ae Added Cygwin build support
strverscmp is included to satisfy a dependency in Cygwin.
Excluded utmp and prctl functions that are not supported currently.
2016-03-10 15:04:27 -08:00
Craig Small
32e1b2e297 A locale-independent strtod
There is a need in some utilities to have a way of accepting both
types of decimal points "." and ",". The only way seems to be to
rebuild strtod().

This new function will accept "123.456" and "123,456" as 123.456
and considers them the same number. It means we lose thousands
separator, but this is rarely used.

test scripts are added to check the function returns the proper
values. There was simpler predecessor that got stuck on negative
0 or -0.123 which these tests flushed out.

References:
2016-03-03 21:24:08 +11: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
Filipe Brandenburger
c1c73c0d00 build-sys: merge automake subdirs into toplevel
This will be required for subdir-objects, otherwise automake will have
problems with more than one Makefile.am having rules to build the same
files.

Tested that it builds and both `make check` and `make distcheck` work.

Tested `make install` and compared the tree with the one installed
before this commit, both installed the binaries to the same locations.
The binaries are also in the same location in the build tree (for
instance, ps/pscommand is still there.)

Checked the binaries for the correct libraries linked into them. Binary
sizes matched before and after this change.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-01 23:19:31 -07:00
Filipe Brandenburger
b56fd9d358 build-sys: split test cases in lib/ into their own files
In order to avoid compiling the same source files twice, with and
without the TEST_PROGRAM define.

Tested that the build still works and that `make distcheck` works as
expected.

Tested that the test_* programs in lib/ keep working. (Though they are
not really invoked by `make check` and in particular test_nsutils is
quite useless, test_fileutils also quite poor.)

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-01 17:43:51 -07:00
Filipe Brandenburger
90cc5460aa build-sys: add $(top_srcdir) to include search dir
This is required for out-of-tree build to work, since many source files
include e.g. proc/*.h which is not under the include/ directory.

Tested that `make distcheck` starts working after this patch.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-01 17:09:55 -07:00
Jaromir Capik
5d818a7a6d library: fixing stdio.h include position in nsutils.c
The previous commit removes the stdio_ext.h header,
but the ns_read function calls snprintf that needs
stdio.h and therefore moving the stdio.h include
from the bottom test program to the top line.
2014-08-26 15:24:55 +02:00
Fredrik Fornwall
41f7ff3ea8 library: remove unused includes in nsutils.c
The <stdio_ext.h> include breaks building on platforms without that header and is unused in nsutils.c.

Also remove unused but harmless <error.h> include.
2014-08-26 15:24:34 +02:00
Craig Small
0f8f760307 Manpage translations in Makefiles
The translated manpage generation has moved from scripts to
Makefiles. This asists with conditional building as well, no
need to regenerate the German pgrep man page if both
the original pgrep.1 and man-po/de.po is not changed.

My Makefile-fu fails me on producing a cross-product or double
iteration for languages and man pages. Until that is solved
each man page is explicitly built. No big deal but it doesn't
look elegant in the Makefile. Languages will be picked
up automatically if they are found in man-po, man-po/top or
man-po/ps

The README describes the three-step process for translating
the files, incase I forget or someone else wants to update them.
2014-06-28 23:38:13 +10:00
Craig Small
dd6f24dbed Merge commit 'refs/merge-requests/13' of git://gitorious.org/procps/procps into merge-requests/13
Conflicts:
	pgrep.c
	ps/output.c
	ps/ps.1
2013-09-11 21:34:05 +10:00
Jim Warner
ce5e995921 library: for atexit() support, fix fileutils for EPIPE
When fileutils with stream error checking was borrowed
from GNU lib, an omission was also propagated where an
errno of EPIPE wouldn't be preserved in close_stream()
making a test for EPIPE in close_stdout() meaningless.

This patch corrects such oversight so that an errno of
EPIPE no longer produces 'write error' at program end.

( gnulib provides for optionally ignoring EPIPE, but )
( if a program chooses to ignore it, then their code )
( appears to suffer from this close_stream oversight )

Reference(s):
. original fileutilis addition
commit c7cf98b0e0
. bugzilla report
https://bugzilla.redhat.com/show_bug.cgi?id=976199
2013-06-26 17:58:56 +02:00
Aristeu Rozanski
de7b3b9222 pgrep: introduce support for namespaces
A PID should be specified with --ns:
	$ pgrep --ns 12345
which will only match the processes which belong to to the same 6
namespaces. It is also possible to specify which namespaces to test:
	$ pgrep --ns 12345 --nslist mnt,net,ipc
which will match processes that belong to the same mount, network and
IPC namespaces as PID 12345.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
2013-04-16 15:05:31 -04:00
Rainer Müller
838e5d8941 configure: Check for error.h
For portability, check for error.h during configure and define
HAVE_ERROR_H accordingly.

If this header is not available, emulate the functionality of error()
from glibc with an inline wrapper in include/c.h.
2013-03-20 16:32:06 +01:00
Rainer Müller
6df4fc403d configure: Check for stdio_ext.h
For portability, check for stdio_ext.h during configure and define
HAVE_STDIO_EXT_H accordingly.

If the current system does not provide this header, use a fallback for
__fpending(). This definition will not work on all systems as it relies
on internal data structures of libc. A more portable solution should be
preferred, for example by using gnulib.
2013-03-20 16:32:06 +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
Sami Kerola
9e3c259fae lib/fileutils: fix compiler warnings
./lib/fileutils.c:9:5: warning: no previous declaration for 'close_stream' [-Wmissing-declarations]
./lib/fileutils.c:23:6: warning: no previous declaration for 'close_stdout' [-Wmissing-declarations]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:28:30 +11:00
Sami Kerola
c7cf98b0e0 lib: add fileutils file with stream error checking facility
The close_stream() is copied from GNU lib. Inspiration to do this
is talk by Jim Meyering - Goodbye World! The perils of relying on
output streams in C.

Reference: http://www.irill.org/events/ghm-gnu-hackers-meeting/videos/jim-meyering-goodbye-world-the-perils-of-relying-on-output-streams-in-c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-23 15:57:41 +01:00
Sami Kerola
ce61089059 docs: clarification to license headers in files
Add license header to all files.  The summary of licensing is below,
taken from Craig Small's email which is referred in commit message
tail.

sysctl and pgrep are GPL 2+
The rest is LGPL 2.1+

Reference: http://www.freelists.org/post/procps/Incorrect-FSF-address-in-the-license-files,8
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=797962
CC: Craig Small <csmall@enc.com.au>
CC: Jaromir Capik <jcapik@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:41:11 +11:00
Sami Kerola
56ed9826a5 test: add lib/strutils check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:36:29 +11:00
Sami Kerola
4ffc7c4f20 strutils: reindent the file
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-11 21:42:39 +01:00
Sami Kerola
cac93d35d0 build-sys: use dist-xz
Even as conservative project as coreutils has switched to xz distributions so
neither should we have any reason to use gz and waste space & bandwidth.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-08 23:02:17 +01:00
Craig Small
fb11e1fe0a Changed the err and warns to macros
err and warn are BSD format but they are not recommended by library
developers.  However their consiseness is useful!

The solution is to use some macros that create xerr etc which then
just map to the error() function.  The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name

This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
2012-01-03 18:48:43 +11:00
Sami Kerola
c0e7e96c1a lib: add strtod_or_err()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Sami Kerola
7b6084451d other: tell what was taken from util-linux package
Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
b260b11a3b lib: add strtol into utility library
The utility library is for functions which are shared in commands,
but that does not belong to libproc-ng.  The first function is a
wrapper for strtol that performs error checking, and exists if such
happen.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:52 +01:00