Commit Graph

61 Commits (3e7da36a465196a2ed079088aa0be685e670be93)

Author SHA1 Message Date
shirou 7be7e7807f [process] extend maxElapsedTime on process_test
Tom Barker 9248140c98 Wait for server connection to be established before checking
connections.
Tom Barker bc4661937d Minor cleanups motivated by staticcheck warnings.
Tom Barker 5ce887df8f Make sure that Test_AllProcesses_cmdLine doesn't ignore failures.
Tom Barker 34cdfa258b Test_Connections currently fails intermittently on Linux (and maybe
other OSs), and fails consistently if run with `go test -times=N`

On inspection, Go closes TCP connections when they go out of scope and
are garbage collected. I've re-written Test_Connections() to explicitly
close connectections once the test has finished. This has the other
benefit of closing gracefully, which means the -times argument should
work.

I've also removed the t.Skip() calls inside goroutines as they are
unsupported.
Max Altgelt 73fee847e6
chore: add tests
Add simple tests to verify that environment variables are read.
Max Altgelt b02b92e16b
feat: Add support for environment variable read
Add support (for Linux and Windows for now) for reading the
environment variables of a process, with a similar syntax to
os.Environ().
For Windows, this includes some refactoring for clean access to the
RTL_USER_PROCESS_PARAMETERS structure which points to the command
line and the environment variables.
John Blesener e8b2bea47f
Fix spaces on long process names for MacOS
Lomanic 995610e109 [process][windows] Fix Nice() test expecting Unix values
Lomanic eaa34817d0 [process] Add benchmarks for New(), Name() Ppid()
run only them with: go test -bench=. -run=xxx github.com/shirou/gopsutil/process
Lomanic 64ba9d03cd [process] Properly test Ppid() against known value
Lomanic 1b3e0c6643 [linux] Fix #900, skip or fix failing tests in docker
TestGetProcInodesAll: create a server so there are some opened inodes
TestUsers: skip if Users is empty, because of an empty /var/run/utmp
Test_Process_Groups: skip if Groups is empty
TestConnectionsMax: skip on CI, not only CircleCI
shirou 7e94bb8bcd
Merge pull request #775 from TakayukiBGoto/add_additional_gids_support
[Process] Implement Groups() to get additional gids.
Mauro Leggieri 00957cfedc Fixed slow command line retrieval on Windows
Lomanic e7090ba9fc [process] Fix Test_Children test regression because of some other running test
Lomanic 1fcea92f73 [process] Skip if not implemented Test_IsRunning (for openbsd)
Lomanic e4f087a4af [process] Test process.Name() with long names #795
TakayukiB Goto 9c6cedb822 [Process] Fix typo
TakayukiB Goto f55f202e81 [Process] Implement Groups() to get additional gids.
Lomanic 547679f88e [process] Fix #760 implement IsRunning by checking process with same PID has same CreateTime as current process
Lomanic f09ba75b25 [process] Skip tests on non-implemented platforms #446 and fix Kill/Children tests on windows
Lomanic f49203762b [process] Fix Connections() test with goroutines listening/connecting on TCP
mingrammer 64a995aad4 Refactor with gofmt
mingrammer 017c9f9cbc Fix typos
shirou a33a26bd97
Merge pull request #567 from tagirb/grouped_memorymaps
implement grouped memorymaps output
Iskander Sharipov f3d4342c30 cpu,process: remove commented-out code
Found using https://go-critic.github.io/overview#commentedOutCode-ref
Tagir Bakirov 29b3c3719b fix slice indices
Tagir Bakirov 47166d6a81 implement grouped memorymaps output
Michal Rostecki 91ac1d66ac process: Check for error objects
shirou d1fb05a30b Skip some test if CircleCI.
WAKAYAMA shirou f5e19d7e16 [process]windows: implements process.Kill using os/exec
Leonid Podolny 7ee4a4c6ff Fix Threads() signature to better match python original
WAKAYAMA Shirou 906b00fc23 add features to README. Thank you for all of great contributors!
Shirou WAKAYAMA 15a7edb712 [process]linux: linux process status change to "R" not "Running" see #173
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters
Shirou WAKAYAMA 715c421b57 [process]: add OpenFiles() test.
Shirou WAKAYAMA 1de1357e77 [process]: add FailNow to avoid panic.
Chris Gilling b8c40ac83c process: add CmdlineSlice function for linux + freebsd
This allows for getting more exact information about each argument
especially if there are arguments that have spaces in them.

This was not implemented for darwin or for windows because they
both currently have not way of properly parsing the cmdline string.
Darwin parses the output of 'ps' which is already whitespace
segmented, and windows just has the cmdline string.
Johan Walles 3232d34b24 Add test for process.CPUTimes()
Johan Walles e3a7a45492 process.Username(): Correct user names on Darwin
Before this change, process.Username() returned "root" for all processes on
Darwin.
Shirou WAKAYAMA dd13300833 process[linux,freebsd,darwin]: implements Children using pgrep.
Daniel Theophanes 0af895258e common: rename package common to internal/common. Add ENV helper funcs.
Package common wasn't used for public functions. Place it in an
internal directory to prevent other packages from using.

Remove the distributed references to "HOST_PROC" and "HOST_SYS"
consts and combine into a common function. This also helps so that
if a env var is defined with a trailing slash all will continue to
work as expected.

Fixes #100
andy cf5660bfd3 process[linux]: calculate the CreateTime and then convert to microseconds
Shirou WAKAYAMA b3cf7354f6 process[linux, darwin]: implements Connections using lsof.
Shirou WAKAYAMA c50db4f462 net[darwin]: implement NetConnections().
Shirou WAKAYAMA d6ac361a24 process[darwin,linux]: implements Parent using lsof.
Shirou WAKAYAMA eb7739a6a5 process: forget to add guard.
Shirou WAKAYAMA fc513b6f9a proces[darwin]: change exec.Command to interface to enable mocking.
Add common.invoker interface to mock exec.Command. common.FakeInvoker returns
expected file if exists instead of invoke exec.Command.
Currenly, mocking is enabled only process.Pids(). I will expand to other funcs incrementally.
Shirou WAKAYAMA 0921e1f153 [linux] Process.CreateTime was returned msec, not sec.
WAKAYAMA Shirou 79f4358f65 process: Exe, Cmdline and Name implemented in windows by using wmic