summaryrefslogtreecommitdiff
blob: 56a5e1168733dbb491f315d26ab42710ddd1f800 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py
index 21bb3e61..6c45c9e0 100644
--- a/psutil/tests/__init__.py
+++ b/psutil/tests/__init__.py
@@ -88,6 +88,7 @@ __all__ = [
     "HAS_IONICE", "HAS_MEMORY_MAPS", "HAS_PROC_CPU_NUM", "HAS_RLIMIT",
     "HAS_SENSORS_BATTERY", "HAS_BATTERY", "HAS_SENSORS_FANS",
     "HAS_SENSORS_TEMPERATURES", "HAS_MEMORY_FULL_INFO",
+    "GENTOO_TESTING",
     # subprocesses
     'pyrun', 'terminate', 'reap_children', 'spawn_testproc', 'spawn_zombie',
     'spawn_children_pair',
@@ -128,6 +129,7 @@ PYPY = '__pypy__' in sys.builtin_module_names
 APPVEYOR = 'APPVEYOR' in os.environ
 GITHUB_ACTIONS = 'GITHUB_ACTIONS' in os.environ or 'CIBUILDWHEEL' in os.environ
 CI_TESTING = APPVEYOR or GITHUB_ACTIONS
+GENTOO_TESTING = "GENTOO_TESTING" in os.environ
 # are we a 64 bit process?
 IS_64BIT = sys.maxsize > 2 ** 32
 
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index 20e28d29..ce5d10a0 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -28,6 +28,7 @@ from psutil._compat import PY3
 from psutil._compat import FileNotFoundError
 from psutil._compat import basestring
 from psutil._compat import u
+from psutil.tests import GENTOO_TESTING
 from psutil.tests import GITHUB_ACTIONS
 from psutil.tests import GLOBAL_TIMEOUT
 from psutil.tests import HAS_BATTERY
@@ -929,6 +930,7 @@ class TestLoadAvg(PsutilTestCase):
 @unittest.skipIf(not LINUX, "LINUX only")
 class TestSystemNetIfAddrs(PsutilTestCase):
 
+    @unittest.skipIf(GENTOO_TESTING, "broken in Gentoo test env")
     def test_ips(self):
         for name, addrs in psutil.net_if_addrs().items():
             for addr in addrs:
@@ -1491,6 +1493,7 @@ class TestMisc(PsutilTestCase):
             psutil.PROCFS_PATH = "/proc"
 
     @retry_on_failure()
+    @unittest.skipIf(GENTOO_TESTING, "broken in Gentoo test env")
     def test_issue_687(self):
         # In case of thread ID:
         # - pid_exists() is supposed to return False
@@ -1596,6 +1599,8 @@ class TestSensorsBattery(PsutilTestCase):
             self.assertEqual(psutil.sensors_battery().power_plugged, False)
             assert m.called
 
+    @unittest.skipIf(GENTOO_TESTING,
+                     "mocking doesn't work with non-BAT0 battery")
     def test_emulate_power_undetermined(self):
         # Pretend we can't know whether the AC power cable not
         # connected (assert fallback to False).
@@ -1614,6 +1619,8 @@ class TestSensorsBattery(PsutilTestCase):
             self.assertIsNone(psutil.sensors_battery().power_plugged)
             assert m.called
 
+    @unittest.skipIf(GENTOO_TESTING,
+                     "mocking doesn't work with non-BAT0 battery")
     def test_emulate_energy_full_0(self):
         # Emulate a case where energy_full files returns 0.
         with mock_open_content(
@@ -1621,6 +1628,8 @@ class TestSensorsBattery(PsutilTestCase):
             self.assertEqual(psutil.sensors_battery().percent, 0)
             assert m.called
 
+    @unittest.skipIf(GENTOO_TESTING,
+                     "mocking doesn't work with non-BAT0 battery")
     def test_emulate_energy_full_not_avail(self):
         # Emulate a case where energy_full file does not exist.
         # Expected fallback on /capacity.
@@ -1634,6 +1643,8 @@ class TestSensorsBattery(PsutilTestCase):
                         "/sys/class/power_supply/BAT0/capacity", b"88"):
                     self.assertEqual(psutil.sensors_battery().percent, 88)
 
+    @unittest.skipIf(GENTOO_TESTING,
+                     "mocking doesn't work with non-BAT0 battery")
     def test_emulate_no_power(self):
         # Emulate a case where /AC0/online file nor /BAT0/status exist.
         with mock_open_exception(
@@ -2220,6 +2231,7 @@ class TestProcessAgainstStatus(PsutilTestCase):
         value = self.read_status_file("nonvoluntary_ctxt_switches:")
         self.assertEqual(self.proc.num_ctx_switches().involuntary, value)
 
+    @unittest.skipIf(GENTOO_TESTING, "broken in Gentoo test env")
     def test_cpu_affinity(self):
         value = self.read_status_file("Cpus_allowed_list:")
         if '-' in str(value):
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py
index d946eb62..a53de565 100755
--- a/psutil/tests/test_misc.py
+++ b/psutil/tests/test_misc.py
@@ -32,6 +32,7 @@ from psutil._compat import PY3
 from psutil._compat import redirect_stderr
 from psutil.tests import APPVEYOR
 from psutil.tests import CI_TESTING
+from psutil.tests import GENTOO_TESTING
 from psutil.tests import HAS_BATTERY
 from psutil.tests import HAS_MEMORY_MAPS
 from psutil.tests import HAS_NET_IO_COUNTERS
@@ -401,6 +402,7 @@ class TestMisc(PsutilTestCase):
                 reload_module(psutil)
             self.assertIn("version conflict", str(cm.exception).lower())
 
+    @unittest.skipIf(GENTOO_TESTING, "broken in Gentoo test env")
     def test_debug(self):
         if PY3:
             from io import StringIO
diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py
index 31b81926..7eb9bac5 100755
--- a/psutil/tests/test_posix.py
+++ b/psutil/tests/test_posix.py
@@ -23,6 +23,7 @@ from psutil import OPENBSD
 from psutil import POSIX
 from psutil import SUNOS
 from psutil.tests import CI_TESTING
+from psutil.tests import GENTOO_TESTING
 from psutil.tests import HAS_NET_IO_COUNTERS
 from psutil.tests import PYTHON_EXE
 from psutil.tests import PsutilTestCase
@@ -326,6 +327,7 @@ class TestSystemAPIs(PsutilTestCase):
                     "couldn't find %s nic in 'ifconfig -a' output\n%s" % (
                         nic, output))
 
+    @unittest.skipIf(GENTOO_TESTING, "broken in Gentoo test env")
     @unittest.skipIf(CI_TESTING and not psutil.users(), "unreliable on CI")
     @retry_on_failure()
     def test_users(self):
diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py
index c9059e33..0050c42a 100755
--- a/psutil/tests/test_process.py
+++ b/psutil/tests/test_process.py
@@ -38,6 +38,7 @@ from psutil._compat import long
 from psutil._compat import super
 from psutil.tests import APPVEYOR
 from psutil.tests import CI_TESTING
+from psutil.tests import GENTOO_TESTING
 from psutil.tests import GITHUB_ACTIONS
 from psutil.tests import GLOBAL_TIMEOUT
 from psutil.tests import HAS_CPU_AFFINITY
@@ -292,6 +293,7 @@ class TestProcess(PsutilTestCase):
         time.strftime("%Y %m %d %H:%M:%S", time.localtime(p.create_time()))
 
     @unittest.skipIf(not POSIX, 'POSIX only')
+    @unittest.skipIf(GENTOO_TESTING, "broken in Gentoo test env")
     def test_terminal(self):
         terminal = psutil.Process().terminal()
         if terminal is not None:
@@ -341,6 +343,7 @@ class TestProcess(PsutilTestCase):
             self.assertGreaterEqual(io2[i], 0)
             self.assertGreaterEqual(io2[i], 0)
 
+    @unittest.skipIf(GENTOO_TESTING, "fails if builder is ioniced already")
     @unittest.skipIf(not HAS_IONICE, "not supported")
     @unittest.skipIf(not LINUX, "linux only")
     def test_ionice_linux(self):
@@ -1406,6 +1409,7 @@ class TestProcess(PsutilTestCase):
         if not OSX and GITHUB_ACTIONS:
             self.assertEqual(d1, d2)
 
+    @unittest.skipIf(GENTOO_TESTING, "broken by Gentoo sandbox")
     @unittest.skipIf(not HAS_ENVIRON, "not supported")
     @unittest.skipIf(not POSIX, "POSIX only")
     def test_weird_environ(self):
diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py
index db2cb348..b1faa154 100755
--- a/psutil/tests/test_system.py
+++ b/psutil/tests/test_system.py
@@ -33,6 +33,7 @@ from psutil._compat import long
 from psutil.tests import ASCII_FS
 from psutil.tests import CI_TESTING
 from psutil.tests import DEVNULL
+from psutil.tests import GENTOO_TESTING
 from psutil.tests import GITHUB_ACTIONS
 from psutil.tests import GLOBAL_TIMEOUT
 from psutil.tests import HAS_BATTERY
@@ -199,6 +200,7 @@ class TestMiscAPIs(PsutilTestCase):
         self.assertGreater(bt, 0)
         self.assertLess(bt, time.time())
 
+    @unittest.skipIf(GENTOO_TESTING, "broken in Gentoo test env")
     @unittest.skipIf(CI_TESTING and not psutil.users(), "unreliable on CI")
     def test_users(self):
         users = psutil.users()