kiranvizru / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Failed tests #434

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Some tests are failing on NixOS linux distro where i maintain this package.

While this is not show stopper, it would be nice to be able to run automated 
tests, now i have to disable them for psutil.

======================================================================
ERROR: test_disk_usage (test.test_psutil.TestExampleScripts)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 2272, in test_disk_usage
    self.assert_stdout('disk_usage.py')
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 2242, in assert_stdout
    out = sh(sys.executable + ' ' + exe).strip()
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 121, in sh
    raise RuntimeError(stderr)
RuntimeError: Traceback (most recent call last):
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/examples/disk_usage.py", line 50, in <module>
    sys.exit(main())
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/examples/disk_usage.py", line 36, in main
    for part in psutil.disk_partitions(all=False):
  File "/nix/store/0929kmzn8jya1haz8yf7gxpzrnng4rjx-python2.7-psutil-1.0.1/lib/python2.7/site-packages/psutil-1.0.1-py2.7-linux-x86_64.egg/psutil/__init__.py", line 1206, in disk_partitions
    return _psplatform.disk_partitions(all)
  File "/nix/store/0929kmzn8jya1haz8yf7gxpzrnng4rjx-python2.7-psutil-1.0.1/lib/python2.7/site-packages/psutil-1.0.1-py2.7-linux-x86_64.egg/psutil/_pslinux.py", line 292, in disk_partitions
    partitions = _psutil_linux.get_disk_partitions()
OSError: [Errno 2] No such file or directory

======================================================================
ERROR: test_disk_partitions (test.test_psutil.TestSystemAPIs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 703, in test_disk_partitions
    for disk in psutil.disk_partitions(all=False):
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/psutil/__init__.py", line 1206, in disk_partitions
    return _psplatform.disk_partitions(all)
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/psutil/_pslinux.py", line 292, in disk_partitions
    partitions = _psutil_linux.get_disk_partitions()
OSError: [Errno 2] No such file or directory

======================================================================
FAIL: test_who (test.test_psutil.TestExampleScripts)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 2284, in test_who
    self.assert_stdout('who.py')
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 2249, in assert_stdout
    assert out, out
AssertionError

======================================================================
FAIL: test_get_threads (test.test_psutil.TestProcess)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 1131, in test_get_threads
    self.assertEqual(step2[0].id, os.getpid())
AssertionError: 110 != 85

======================================================================
FAIL: test_terminal (test.test_psutil.TestProcess)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 1015, in test_terminal
    assert terminal, repr(terminal)
AssertionError: None

======================================================================
FAIL: test_get_users (test.test_psutil.TestSystemAPIs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 809, in test_get_users
    assert users
AssertionError

======================================================================
FAIL: test_sys_cpu_times_percent (test.test_psutil.TestSystemAPIs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 663, in test_sys_cpu_times_percent
    self._test_cpu_percent(sum(cpu))
  File "/tmp/nix-build-python2.7-psutil-1.0.1.drv-0/psutil-1.0.1/test/test_psutil.py", line 642, in _test_cpu_percent
    self.assertLessEqual(percent, 100.0)
AssertionError: 100.10000000000001 not less than or equal to 100.0

----------------------------------------------------------------------
Ran 95 tests in 13.579s

On what operating system? Is it 32bit or 64bit version?

Please provide any additional information below.

Original issue reported on code.google.com by jakahudo...@gmail.com on 24 Sep 2013 at 10:43

GoogleCodeExporter commented 9 years ago
Hello there.
Could you please:

1) tell me whether you have /etc/mtab file and if not report what file 'man 
setmntent' recommends to use

2) paste the output of 'who' command

3) paste the output of 'cat /proc/self/stat'

4) paste the output of "import os; print os.name"

5) paste the output of this python script:

import os, glob
from pprint import pprint as pp

def get_terminal_map():
    ret = {}
    ls = glob.glob('/dev/tty*') + glob.glob('/dev/pts/*')
    for name in ls:
        assert name not in ret
        try:
            ret[os.stat(name).st_rdev] = name
        except OSError:
            err = sys.exc_info()[1]
            if err.errno != errno.ENOENT:
                raise
    return ret

pp(get_terminal_map())

Original comment by g.rodola on 25 Sep 2013 at 8:24

GoogleCodeExporter commented 9 years ago
Hello!

1. /etc/mtab is present, but it's not accessible in build phase, because nixos 
builder runs in a chroot, to secure the build. Is there any way to mockup mtab 
file? Well i could force to run without chroot, but it would be nicer to make 
tests more portable. And i can't make /etc/mtab, because builder must also be 
able to run without chroot. If there would be environment variable to set mtab 
path i would be able fix this.

2. who returns nothing

3. cat /proc/self/stat
87 (cat) R 1 1 1 0 -1 4202496 195 0 0 0 0 0 0 0 20 0 1 0 18124671 4370432 98 
18446744073709551615 4194304 4239060 140734887800304 140734887797128 
139893949358080 0 0 0 0 0 0 0 17 0 0 0 0 0 0 6336512 6337792 31752192 
140734887802431 140734887802451 140734887802451 140734887808949 0

4.
>>> import os 
>>> print os.name
posix

5.
{1024: '/dev/tty0',
 1025: '/dev/tty1',
 1026: '/dev/tty2',
 1027: '/dev/tty3',
 1028: '/dev/tty4',
 1029: '/dev/tty5',
 1030: '/dev/tty6',
 1031: '/dev/tty7',
 1032: '/dev/tty8',
 1033: '/dev/tty9',
 1034: '/dev/tty10',
 1035: '/dev/tty11',
 1036: '/dev/tty12',
 1037: '/dev/tty13',
 1038: '/dev/tty14',
 1039: '/dev/tty15',
 1040: '/dev/tty16',
 1041: '/dev/tty17',
 1042: '/dev/tty18',
 1043: '/dev/tty19',
 1044: '/dev/tty20',
 1045: '/dev/tty21',
 1046: '/dev/tty22',
 1047: '/dev/tty23',
 1048: '/dev/tty24',
 1049: '/dev/tty25',
 1050: '/dev/tty26',
 1051: '/dev/tty27',
 1052: '/dev/tty28',
 1053: '/dev/tty29',
 1054: '/dev/tty30',
 1055: '/dev/tty31',
 1056: '/dev/tty32',
 1057: '/dev/tty33',
 1058: '/dev/tty34',
 1059: '/dev/tty35',
 1060: '/dev/tty36',
 1061: '/dev/tty37',
 1062: '/dev/tty38',
 1063: '/dev/tty39',
 1064: '/dev/tty40',
 1065: '/dev/tty41',
 1066: '/dev/tty42',
 1067: '/dev/tty43',
 1068: '/dev/tty44',
 1069: '/dev/tty45',
 1070: '/dev/tty46',
 1071: '/dev/tty47',
 1072: '/dev/tty48',
 1073: '/dev/tty49',
 1074: '/dev/tty50',
 1075: '/dev/tty51',
 1076: '/dev/tty52',
 1077: '/dev/tty53',
 1078: '/dev/tty54',
 1079: '/dev/tty55',
 1080: '/dev/tty56',
 1081: '/dev/tty57',
 1082: '/dev/tty58',
 1083: '/dev/tty59',
 1084: '/dev/tty60',
 1085: '/dev/tty61',
 1086: '/dev/tty62',
 1087: '/dev/tty63',
 1088: '/dev/ttyS0',
 1089: '/dev/ttyS1',
 1090: '/dev/ttyS2',
 1091: '/dev/ttyS3',
 1280: '/dev/tty',
 1282: '/dev/pts/ptmx',
 34816: '/dev/pts/0',
 34817: '/dev/pts/1',
 34818: '/dev/pts/2',
 34819: '/dev/pts/3',
 34820: '/dev/pts/4',
 34821: '/dev/pts/5',
 34822: '/dev/pts/6',
 34823: '/dev/pts/7'}

Thanks!

Original comment by jakahudo...@gmail.com on 25 Sep 2013 at 10:28

GoogleCodeExporter commented 9 years ago
> 1. /etc/mtab is present, but it's not accessible in 
> build phase, because nixos builder runs in a chroot, 
> to secure the build. Is there any way to mockup mtab 
> file?

I'd be for letting the test fail.
That's an uncommon system configuration and I see little value in adding these 
kind of workarounds during tests.
FWIW I committed revision 5e6d941a9a9f: that will at least provide a more 
useful message by signaling /etc/mtab is not present.

> 2. who returns nothing

Same here.
Any idea why that happens BTW?

>     assert terminal, repr(terminal)
> AssertionError: None

...can you please paste the output of "tty" command?

>     self.assertLessEqual(percent, 100.0)
> AssertionError: 100.10000000000001 not less than or equal to 100.0

This is weird because if os.name == 'posix' that line (assertEqual) shouldn't 
be executed.
It seems that while the tests were running for some reason os.name was 
different than 'posix'.
I don't have any idea why that happened (do you?).

Do you think there's some reason why this Linux distro behave so strangely 
(this is the first time I hear about nixos)?

Original comment by g.rodola on 26 Sep 2013 at 6:43

GoogleCodeExporter commented 9 years ago
Nix is a different concept than standard package managers, it does things a bit 
differnetly and more properly. The whole point is that it is deterministic in 
any time, by providing every package only things it needs. That's also why it 
can run on linux, osx, freebsd and there were even attempts for windows. If you 
have any time please take a look at http://nixos.org/. In a meanwhile i will 
try to fix tests.

Original comment by jakahudo...@gmail.com on 26 Sep 2013 at 7:51

GoogleCodeExporter commented 9 years ago
Maintaining glances for Debian I faced the same /etc/mtab issue [0].

The discussion in the bug report raises an interesting point regarding the 
assumption of /etc/mtab presence on linux system.

I have neither a personal idea of what should be done here nor the expertise to 
have one, I just wanted to share with you what we've discussed on this bug 
report.

The point is glibc mentioning this:
"Note that the fstab and mtab files are maintained on a system by
convention. It is possible for the files not to exist or not to be
consistent with what is really mounted or available to mount" [1]

Using procfs might be more robust then (ie. /proc/mounts).

[0] http://bugs.debian.org/733168
[1] http://www.gnu.org/software/libc/manual/html_mono/libc.html#Mount-Informati
on

Cheers

Original comment by mxondeb...@free.fr on 28 Dec 2013 at 6:42