summaryrefslogtreecommitdiff
path: root/psutil/_psutil_linux.c
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-18 21:43:30 +0200
committerGitHub <noreply@github.com>2017-05-18 21:43:30 +0200
commitcee414dca663bdac9712c0779e43ce0c184e904e (patch)
tree374be75e513991e9e963a1f024e7cc072c67c985 /psutil/_psutil_linux.c
parentd58c4338d64fad9b3c0eebb2451cd55f660e86cf (diff)
downloadpsutil-cee414dca663bdac9712c0779e43ce0c184e904e.tar.gz
PSUTIL_TESTING env var (#1083)
* Introduce PSUTIL_TESTING env var ...so that we can make stricter assertions in C and py code during tests only. * define a C function in _common.c which returns whether the var is set * set PSUTIL_TESTING from the Makefile * cache psutil_testing() result * winmake: set PSUTIL_TESTING env var for tests
Diffstat (limited to 'psutil/_psutil_linux.c')
-rw-r--r--psutil/_psutil_linux.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c
index 1a96fea0..e262ac70 100644
--- a/psutil/_psutil_linux.c
+++ b/psutil/_psutil_linux.c
@@ -203,6 +203,8 @@ psutil_disk_partitions(PyObject *self, PyObject *args) {
if (py_retlist == NULL)
return NULL;
+ psutil_testing();
+
// MOUNTED constant comes from mntent.h and it's == '/etc/mtab'
Py_BEGIN_ALLOW_THREADS
file = setmntent(MOUNTED, "r");
@@ -574,7 +576,6 @@ error:
*/
static PyMethodDef
PsutilMethods[] = {
-
// --- per-process functions
#if PSUTIL_HAVE_IOPRIO
@@ -607,6 +608,9 @@ PsutilMethods[] = {
"Get or set process resource limits."},
#endif
+ // --- others
+ {"py_psutil_testing", py_psutil_testing, METH_VARARGS,
+ "Return True if PSUTIL_TESTING env var is set"},
{NULL, NULL, 0, NULL}
};