comparison env/lib/python3.9/site-packages/psutil/tests/test_sunos.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 #!/usr/bin/env python3
2
3 # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 """Sun OS specific tests."""
8
9 import os
10
11 import psutil
12 from psutil import SUNOS
13 from psutil.tests import PsutilTestCase
14 from psutil.tests import sh
15 from psutil.tests import unittest
16
17
18 @unittest.skipIf(not SUNOS, "SUNOS only")
19 class SunOSSpecificTestCase(PsutilTestCase):
20
21 def test_swap_memory(self):
22 out = sh('env PATH=/usr/sbin:/sbin:%s swap -l' % os.environ['PATH'])
23 lines = out.strip().split('\n')[1:]
24 if not lines:
25 raise ValueError('no swap device(s) configured')
26 total = free = 0
27 for line in lines:
28 line = line.split()
29 t, f = line[-2:]
30 total += int(int(t) * 512)
31 free += int(int(f) * 512)
32 used = total - free
33
34 psutil_swap = psutil.swap_memory()
35 self.assertEqual(psutil_swap.total, total)
36 self.assertEqual(psutil_swap.used, used)
37 self.assertEqual(psutil_swap.free, free)
38
39 def test_cpu_count(self):
40 out = sh("/usr/sbin/psrinfo")
41 self.assertEqual(psutil.cpu_count(), len(out.split('\n')))
42
43
44 if __name__ == '__main__':
45 from psutil.tests.runner import run_from_name
46 run_from_name(__file__)