From 70d6ee518de750655934f350b2502251e41c6de9 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Thu, 12 Feb 2015 17:19:14 +0100 Subject: [PATCH] add new 'make test-memleaks-by-name' command; also fix some compilation warnings on SunOS --- Makefile | 6 +++++- docs/index.rst | 2 +- psutil/_psutil_sunos.c | 8 +++----- test/test_memory_leaks.py | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index cb28b6fdc..71e2e2074 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ test-system: install $(PYTHON) -m unittest -v test.test_psutil.TestSystemAPIs test-memleaks: install - $(PYTHON) -m unittest -v test.test_memory_leaks + $(PYTHON) test/test_memory_leaks.py # Run a specific test by name; e.g. "make test-by-name disk_" will run # all test methods containing "disk_" in their name. @@ -54,6 +54,10 @@ test-memleaks: install test-by-name: install @$(PYTHON) -m nose test/test_psutil.py --nocapture -v -m $(filter-out $@,$(MAKECMDGOALS)) +# same as above but for test_memory_leaks.py script +test-memleaks-by-name: install + @$(PYTHON) -m nose test/test_memory_leaks.py --nocapture -v -m $(filter-out $@,$(MAKECMDGOALS)) + # requires "pip install pep8" pep8: @git ls-files | grep \\.py$ | xargs pep8 diff --git a/docs/index.rst b/docs/index.rst index f860cce7c..b3690e7af 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -807,7 +807,7 @@ Process class >>> p.io_counters() pio(read_count=454556, write_count=3456, read_bytes=110592, write_bytes=0) - Availability: all platforms except OSX + Availability: all platforms except OSX and Solaris .. method:: num_ctx_switches() diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c index 32108e09f..3284012ab 100644 --- a/psutil/_psutil_sunos.c +++ b/psutil/_psutil_sunos.c @@ -442,8 +442,6 @@ psutil_per_cpu_times(PyObject *self, PyObject *args) kstat_ctl_t *kc; kstat_t *ksp; cpu_stat_t cs; - int numcpus; - int i; PyObject *py_retlist = PyList_New(0); PyObject *py_cputime = NULL; @@ -805,7 +803,7 @@ static PyObject * psutil_net_connections(PyObject *self, PyObject *args) { long pid; - int sd = NULL; + int sd = 0; mib2_tcpConnEntry_t *tp = NULL; mib2_udpEntry_t *ude; #if defined(AF_INET6) @@ -1083,7 +1081,7 @@ psutil_net_connections(PyObject *self, PyObject *args) Py_XDECREF(py_raddr); Py_DECREF(py_retlist); // TODO : free databuf - if (sd != NULL) + if (sd != 0) close(sd); return NULL; } @@ -1132,7 +1130,7 @@ psutil_cpu_count_phys(PyObject *self, PyObject *args) for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) { if (strcmp(ksp->ks_module, "cpu_info") != 0) continue; - if (kstat_read(kc, ksp, NULL) == NULL) + if (kstat_read(kc, ksp, NULL) == -1) goto error; ncpus += 1; } diff --git a/test/test_memory_leaks.py b/test/test_memory_leaks.py index 1441daa14..223cc1ed3 100644 --- a/test/test_memory_leaks.py +++ b/test/test_memory_leaks.py @@ -168,7 +168,7 @@ def test_ionice_set(self): self.execute('ionice', psutil.IOPRIO_CLASS_NONE) self.execute_w_exc(OSError, 'ionice', -1) - @unittest.skipIf(OSX, "feature not supported on this platform") + @unittest.skipIf(OSX or SUNOS, "feature not supported on this platform") @skip_if_linux() def test_io_counters(self): self.execute('io_counters')