Compare commits

..

No commits in common. "38614aad080084990500c00977e31cbe8add6191" and "4b45acd0b6700e65ddea30bb77f29bd373f11e8a" have entirely different histories.

9 changed files with 93 additions and 60 deletions

1
MAINFEST.IN Normal file
View File

@ -0,0 +1 @@
include tests/*.xbc

37
setup.py Normal file
View File

@ -0,0 +1,37 @@
import pathlib
import sys
from setuptools import setup, find_packages
here = pathlib.Path(__file__).parent.resolve()
src = here / 'src'
sys.path.append(src.as_posix())
from xbc.version import version
long_description = (here / "README.md").read_text(encoding="utf-8")
setup(
name='py-xbc',
version=version,
description='A library for manipulating eXtra Boot Configuration (XBC) files',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://gitea.treehouse.systems/VulpineAmethyst/py-xbc',
author='Síle Ekaterin Liszka',
author_email='sheila@vulpine.house',
keywords='xbc, configuration, bootconfig',
package_dir={'': 'src'},
packages=find_packages(where='src'),
python_requires='>=3.7, <4',
install_requires=['pyparsing'],
extras_require={
'test': ['pytest'],
},
project_urls={
'Bug Reports': 'https://gitea.treehouse.systems/VulpineAmethyst/py-xbc/issues',
'Source': 'https://gitea.treehouse.systems/VulpineAmethyst/py-xbc',
}
)

2
tests/01-keyvalue.xbc Normal file
View File

@ -0,0 +1,2 @@
feature.option.foo = 1
feature.option.bar = 2

View File

@ -0,0 +1,4 @@
feature.option {
foo = 1
bar = 2
}

View File

@ -0,0 +1 @@
feature.options = "foo", "bar"

1
tests/10-compact.xbc Normal file
View File

@ -0,0 +1 @@
feature.option{foo=1;bar=2}

21
tests/11-config.xbc Normal file
View File

@ -0,0 +1,21 @@
ftrace.event {
task.task_newtask {
filter = "pid < 128"
enable
}
kprobes.vfs_read {
probes = "vfs_read $arg1 $arg2"
filter = "common_pid < 200"
enable
}
synthetic.initcall_latency {
fields = "unsigned long func", "u64 lat"
actions = "hist:keys=func.sym,lat:vals=lat:sort=lat"
}
initcall.initcall_start {
actions = "hist:keys=func:ts0=common_timestamp.usecs"
}
initcall.initcall_finish {
actions = "hist:keys=func:lat=common_timestamp.usecs-$ts0:onmatch(initcall.initcall_start).initcall_latency(func,$lat)"
}
}

19
tests/12-config2.xbc Normal file
View File

@ -0,0 +1,19 @@
ftrace.event.synthetic.initcall_latency {
fields = "unsigned long func", "u64 lat"
hist {
from {
event = initcall.initcall_start
key = func
assigns = "ts0=common_timestamp.usecs"
}
to {
event = initcall.initcall_finish
key = func
assigns = "lat=common_timestamp.usecs-$ts0"
onmatch = func, $lat
}
keys = func.sym, lat
vals = lat
sort = lat
}
}

View File

@ -1,77 +1,43 @@
import pytest
from xbc import loads_xbc
'''
The tests in this file are samples drawn from
https://lwn.net/Articles/806002/.
'''
from xbc import load_xbc
def test_01():
i = '''feature.option.foo = 1
feature.option.bar = 2'''
d = {
'feature.option': False,
'feature': False,
'feature.option.foo': '1',
'feature.option.bar': '2'
}
assert loads_xbc(i) == d
assert load_xbc('tests/01-keyvalue.xbc') == d
def test_02():
i = '''feature.option {
foo = 1
bar = 2
}'''
d = {
'feature.option': False,
'feature': False,
'feature.option.foo': '1',
'feature.option.bar': '2'
}
assert loads_xbc(i) == d
assert load_xbc('tests/02-block-keyvalue.xbc') == d
def test_03():
i = 'feature.options = "foo", "bar"'
d = {
'feature': False,
'feature.options': ['foo', 'bar']
}
assert loads_xbc(i) == d
assert load_xbc('tests/03-keyvalue-string.xbc') == d
def test_10():
i = 'feature.option{foo=1;bar=2}'
d = {
'feature.option': False,
'feature': False,
'feature.option.foo': '1',
'feature.option.bar': '2'
}
assert loads_xbc(i) == d
assert load_xbc('tests/10-compact.xbc') == d
def test_11():
i = '''ftrace.event {
task.task_newtask {
filter = "pid < 128"
enable
}
kprobes.vfs_read {
probes = "vfs_read $arg1 $arg2"
filter = "common_pid < 200"
enable
}
synthetic.initcall_latency {
fields = "unsigned long func", "u64 lat"
actions = "hist:keys=func.sym,lat:vals=lat:sort=lat"
}
initcall.initcall_start {
actions = "hist:keys=func:ts0=common_timestamp.usecs"
}
initcall.initcall_finish {
actions = "hist:keys=func:lat=common_timestamp.usecs-$ts0:onmatch(initcall.initcall_start).initcall_latency(func,$lat)"
}
}'''
d = {
'ftrace': False,
'ftrace.event': False,
@ -94,28 +60,9 @@ def test_11():
'ftrace.event.initcall.initcall_finish': False,
'ftrace.event.initcall.initcall_finish.actions': "hist:keys=func:lat=common_timestamp.usecs-$ts0:onmatch(initcall.initcall_start).initcall_latency(func,$lat)"
}
assert loads_xbc(i) == d
assert load_xbc('tests/11-config.xbc') == d
def test_12():
i = '''ftrace.event.synthetic.initcall_latency {
fields = "unsigned long func", "u64 lat"
hist {
from {
event = initcall.initcall_start
key = func
assigns = "ts0=common_timestamp.usecs"
}
to {
event = initcall.initcall_finish
key = func
assigns = "lat=common_timestamp.usecs-$ts0"
onmatch = func, $lat
}
keys = func.sym, lat
vals = lat
sort = lat
}
}'''
d = {
'ftrace': False,
'ftrace.event': False,
@ -136,4 +83,4 @@ def test_12():
'ftrace.event.synthetic.initcall_latency.hist.vals': 'lat',
'ftrace.event.synthetic.initcall_latency.hist.sort': 'lat'
}
assert loads_xbc(i) == d
assert load_xbc('tests/12-config2.xbc') == d