mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
proc_pid tests
This commit is contained in:
1
tests/fixtures/linux-proc/pid_fdinfo.json
vendored
Normal file
1
tests/fixtures/linux-proc/pid_fdinfo.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"pos":0,"flags":2004002,"mnt_id":9,"scm_fds":"0","ino":63107,"lock":"1: FLOCK ADVISORY WRITE 359 00:13:11691 0 EOF"}
|
1
tests/fixtures/linux-proc/pid_fdinfo_dma.json
vendored
Normal file
1
tests/fixtures/linux-proc/pid_fdinfo_dma.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"pos":0,"flags":4002,"mnt_id":9,"ino":63107,"size":32768,"count":2,"exp_name":"system-heap"}
|
1
tests/fixtures/linux-proc/pid_fdinfo_epoll.json
vendored
Normal file
1
tests/fixtures/linux-proc/pid_fdinfo_epoll.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"pos":0,"flags":2,"mnt_id":9,"ino":63107,"epoll":{"tfd":5,"events":"1d","data":"ffffffffffffffff","pos":0,"ino":"61af","sdev":"7"}}
|
1
tests/fixtures/linux-proc/pid_fdinfo_fanotify.json
vendored
Normal file
1
tests/fixtures/linux-proc/pid_fdinfo_fanotify.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"pos":0,"flags":2,"mnt_id":9,"ino":63107,"fanotify":{"flags":"10","event-flags":"0","mnt_id":"12","mflags":"0","mask":"3b","ignored_mask":"40000000","ino":"4f969","sdev":"800013","fhandle-bytes":"8","fhandle-type":"1","f_handle":"69f90400c275b5b4"}}
|
1
tests/fixtures/linux-proc/pid_fdinfo_inotify.json
vendored
Normal file
1
tests/fixtures/linux-proc/pid_fdinfo_inotify.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"pos":0,"flags":2000000,"mnt_id":9,"ino":63107,"inotify":{"wd":3,"ino":"9e7e","sdev":"800013","mask":"800afce","ignored_mask":"0","fhandle-bytes":"8","fhandle-type":"1","f_handle":"7e9e0000640d1b6d"}}
|
1
tests/fixtures/linux-proc/pid_fdinfo_timerfd.json
vendored
Normal file
1
tests/fixtures/linux-proc/pid_fdinfo_timerfd.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"pos":0,"flags":2,"mnt_id":9,"ino":63107,"clockid":0,"ticks":0,"settime flags":1,"it_value":[0,49406829],"it_interval":[1,0]}
|
1
tests/fixtures/linux-proc/pid_io.json
vendored
Normal file
1
tests/fixtures/linux-proc/pid_io.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"rchar":4699288382,"wchar":2931802997,"syscr":661897,"syscw":890910,"read_bytes":168468480,"write_bytes":27357184,"cancelled_write_bytes":16883712}
|
1
tests/fixtures/linux-proc/pid_maps.json
vendored
Normal file
1
tests/fixtures/linux-proc/pid_maps.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/linux-proc/pid_mountinfo.json
vendored
Normal file
1
tests/fixtures/linux-proc/pid_mountinfo.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/linux-proc/pid_numa_maps.json
vendored
Normal file
1
tests/fixtures/linux-proc/pid_numa_maps.json
vendored
Normal file
File diff suppressed because one or more lines are too long
94
tests/test_proc_pid_fdinfo.py
Normal file
94
tests/test_proc_pid_fdinfo.py
Normal file
@ -0,0 +1,94 @@
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
from typing import Dict
|
||||
import jc.parsers.proc_pid_fdinfo
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
fixtures = {
|
||||
'proc_pid_fdinfo': (
|
||||
'fixtures/linux-proc/pid_fdinfo',
|
||||
'fixtures/linux-proc/pid_fdinfo.json'),
|
||||
'proc_pid_fdinfo_dma': (
|
||||
'fixtures/linux-proc/pid_fdinfo_dma',
|
||||
'fixtures/linux-proc/pid_fdinfo_dma.json'),
|
||||
'proc_pid_fdinfo_epoll': (
|
||||
'fixtures/linux-proc/pid_fdinfo_epoll',
|
||||
'fixtures/linux-proc/pid_fdinfo_epoll.json'),
|
||||
'proc_pid_fdinfo_fanotify': (
|
||||
'fixtures/linux-proc/pid_fdinfo_fanotify',
|
||||
'fixtures/linux-proc/pid_fdinfo_fanotify.json'),
|
||||
'proc_pid_fdinfo_inotify': (
|
||||
'fixtures/linux-proc/pid_fdinfo_inotify',
|
||||
'fixtures/linux-proc/pid_fdinfo_inotify.json'),
|
||||
'proc_pid_fdinfo_timerfd': (
|
||||
'fixtures/linux-proc/pid_fdinfo_timerfd',
|
||||
'fixtures/linux-proc/pid_fdinfo_timerfd.json')
|
||||
}
|
||||
|
||||
for file, filepaths in fixtures.items():
|
||||
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||
cls.f_in[file] = a.read()
|
||||
cls.f_json[file] = json.loads(b.read())
|
||||
|
||||
|
||||
def test_proc_pid_fdinfo_nodata(self):
|
||||
"""
|
||||
Test 'proc_pid_fdinfo' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_fdinfo.parse('', quiet=True), {})
|
||||
|
||||
def test_proc_pid_fdinfo(self):
|
||||
"""
|
||||
Test '/proc/<pid>/fdinfo/<fd>'
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_fdinfo.parse(self.f_in['proc_pid_fdinfo'], quiet=True),
|
||||
self.f_json['proc_pid_fdinfo'])
|
||||
|
||||
def test_proc_pid_fdinfo_dma(self):
|
||||
"""
|
||||
Test '/proc/<pid>/fdinfo/<fd>' dma file
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_fdinfo.parse(self.f_in['proc_pid_fdinfo_dma'], quiet=True),
|
||||
self.f_json['proc_pid_fdinfo_dma'])
|
||||
|
||||
def test_proc_pid_fdinfo_epoll(self):
|
||||
"""
|
||||
Test '/proc/<pid>/fdinfo/<fd>' epoll file
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_fdinfo.parse(self.f_in['proc_pid_fdinfo_epoll'], quiet=True),
|
||||
self.f_json['proc_pid_fdinfo_epoll'])
|
||||
|
||||
def test_proc_pid_fdinfo_fanotify(self):
|
||||
"""
|
||||
Test '/proc/<pid>/fdinfo/<fd>' fanotify file
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_fdinfo.parse(self.f_in['proc_pid_fdinfo_fanotify'], quiet=True),
|
||||
self.f_json['proc_pid_fdinfo_fanotify'])
|
||||
|
||||
def test_proc_pid_fdinfo_inotify(self):
|
||||
"""
|
||||
Test '/proc/<pid>/fdinfo/<fd>' inotify file
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_fdinfo.parse(self.f_in['proc_pid_fdinfo_inotify'], quiet=True),
|
||||
self.f_json['proc_pid_fdinfo_inotify'])
|
||||
|
||||
def test_proc_pid_fdinfo_timerfd(self):
|
||||
"""
|
||||
Test '/proc/<pid>/fdinfo/<fd>' timerfd file
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_fdinfo.parse(self.f_in['proc_pid_fdinfo_timerfd'], quiet=True),
|
||||
self.f_json['proc_pid_fdinfo_timerfd'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
44
tests/test_proc_pid_io.py
Normal file
44
tests/test_proc_pid_io.py
Normal file
@ -0,0 +1,44 @@
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
from typing import Dict
|
||||
import jc.parsers.proc_pid_io
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
fixtures = {
|
||||
'proc_pid_io': (
|
||||
'fixtures/linux-proc/pid_io',
|
||||
'fixtures/linux-proc/pid_io.json')
|
||||
}
|
||||
|
||||
for file, filepaths in fixtures.items():
|
||||
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||
cls.f_in[file] = a.read()
|
||||
cls.f_json[file] = json.loads(b.read())
|
||||
|
||||
|
||||
def test_proc_pid_io_nodata(self):
|
||||
"""
|
||||
Test 'proc_pid_io' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_io.parse('', quiet=True), {})
|
||||
|
||||
def test_proc_pid_io(self):
|
||||
"""
|
||||
Test '/proc/<pid>/io'
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_io.parse(self.f_in['proc_pid_io'], quiet=True),
|
||||
self.f_json['proc_pid_io'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
44
tests/test_proc_pid_maps.py
Normal file
44
tests/test_proc_pid_maps.py
Normal file
@ -0,0 +1,44 @@
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
from typing import Dict
|
||||
import jc.parsers.proc_pid_maps
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
fixtures = {
|
||||
'proc_pid_maps': (
|
||||
'fixtures/linux-proc/pid_maps',
|
||||
'fixtures/linux-proc/pid_maps.json')
|
||||
}
|
||||
|
||||
for file, filepaths in fixtures.items():
|
||||
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||
cls.f_in[file] = a.read()
|
||||
cls.f_json[file] = json.loads(b.read())
|
||||
|
||||
|
||||
def test_proc_pid_maps_nodata(self):
|
||||
"""
|
||||
Test 'proc_pid_maps' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_maps.parse('', quiet=True), [])
|
||||
|
||||
def test_proc_pid_maps(self):
|
||||
"""
|
||||
Test '/proc/<pid>/maps'
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_maps.parse(self.f_in['proc_pid_maps'], quiet=True),
|
||||
self.f_json['proc_pid_maps'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
44
tests/test_proc_pid_mountinfo.py
Normal file
44
tests/test_proc_pid_mountinfo.py
Normal file
@ -0,0 +1,44 @@
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
from typing import Dict
|
||||
import jc.parsers.proc_pid_mountinfo
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
fixtures = {
|
||||
'proc_pid_mountinfo': (
|
||||
'fixtures/linux-proc/pid_mountinfo',
|
||||
'fixtures/linux-proc/pid_mountinfo.json')
|
||||
}
|
||||
|
||||
for file, filepaths in fixtures.items():
|
||||
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||
cls.f_in[file] = a.read()
|
||||
cls.f_json[file] = json.loads(b.read())
|
||||
|
||||
|
||||
def test_proc_pid_mountinfo_nodata(self):
|
||||
"""
|
||||
Test 'proc_pid_mountinfo' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_mountinfo.parse('', quiet=True), [])
|
||||
|
||||
def test_proc_pid_mountinfo(self):
|
||||
"""
|
||||
Test '/proc/<pid>/mountinfo'
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_mountinfo.parse(self.f_in['proc_pid_mountinfo'], quiet=True),
|
||||
self.f_json['proc_pid_mountinfo'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
44
tests/test_proc_pid_numa_maps.py
Normal file
44
tests/test_proc_pid_numa_maps.py
Normal file
@ -0,0 +1,44 @@
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
from typing import Dict
|
||||
import jc.parsers.proc_pid_numa_maps
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
fixtures = {
|
||||
'proc_pid_numa_maps': (
|
||||
'fixtures/linux-proc/pid_numa_maps',
|
||||
'fixtures/linux-proc/pid_numa_maps.json')
|
||||
}
|
||||
|
||||
for file, filepaths in fixtures.items():
|
||||
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||
cls.f_in[file] = a.read()
|
||||
cls.f_json[file] = json.loads(b.read())
|
||||
|
||||
|
||||
def test_proc_pid_numa_maps_nodata(self):
|
||||
"""
|
||||
Test 'proc_pid_numa_maps' with no data
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_numa_maps.parse('', quiet=True), [])
|
||||
|
||||
def test_proc_pid_numa_maps(self):
|
||||
"""
|
||||
Test '/proc/<pid>/numa_maps'
|
||||
"""
|
||||
self.assertEqual(jc.parsers.proc_pid_numa_maps.parse(self.f_in['proc_pid_numa_maps'], quiet=True),
|
||||
self.f_json['proc_pid_numa_maps'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in New Issue
Block a user