mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
proc-buddyinfo tests
This commit is contained in:
3
tests/fixtures/linux-proc/buddyinfo
vendored
Normal file
3
tests/fixtures/linux-proc/buddyinfo
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Node 0, zone DMA 0 0 0 1 1 1 1 1 0 1 3
|
||||||
|
Node 0, zone DMA32 78 114 82 52 38 25 13 9 3 4 629
|
||||||
|
Node 0, zone Normal 0 22 8 10 1 1 2 11 13 0 0
|
1
tests/fixtures/linux-proc/buddyinfo.json
vendored
Normal file
1
tests/fixtures/linux-proc/buddyinfo.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"node":0,"zone":"DMA","free_chunks":[0,0,0,1,1,1,1,1,0,1,3]},{"node":0,"zone":"DMA32","free_chunks":[78,114,82,52,38,25,13,9,3,4,629]},{"node":0,"zone":"Normal","free_chunks":[0,22,8,10,1,1,2,11,13,0,0]}]
|
45
tests/test_proc_buddyinfo.py
Normal file
45
tests/test_proc_buddyinfo.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
import json
|
||||||
|
from typing import Dict
|
||||||
|
import jc.parsers.proc_buddyinfo
|
||||||
|
|
||||||
|
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_buddyinfo': (
|
||||||
|
'fixtures/linux-proc/buddyinfo',
|
||||||
|
'fixtures/linux-proc/buddyinfo.json')
|
||||||
|
}
|
||||||
|
|
||||||
|
for file, filepaths in fixtures.items():
|
||||||
|
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as f:
|
||||||
|
cls.f_in[file] = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as f:
|
||||||
|
cls.f_json[file] = json.loads(f.read())
|
||||||
|
|
||||||
|
|
||||||
|
def test_proc_buddyinfo_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'proc_buddyinfo' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.proc_buddyinfo.parse('', quiet=True), [])
|
||||||
|
|
||||||
|
def test_proc_buddyinfo(self):
|
||||||
|
"""
|
||||||
|
Test '/proc/buddyinfo'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.proc_buddyinfo.parse(self.f_in['proc_buddyinfo'], quiet=True),
|
||||||
|
self.f_json['proc_buddyinfo'])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Reference in New Issue
Block a user