Compare commits

..

2 Commits

Author SHA1 Message Date
Síle Ekaterin Liszka 38614aad08
tests: stop using files 2024-01-13 23:50:23 -08:00
Síle Ekaterin Liszka 090d5191f7
we don't actually need setup.py 2024-01-13 21:36:46 -08:00
9 changed files with 60 additions and 93 deletions

View File

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

View File

@ -1,37 +0,0 @@
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',
}
)

View File

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

View File

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

View File

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

View File

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

View File

@ -1,21 +0,0 @@
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)"
}
}

View File

@ -1,19 +0,0 @@
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,43 +1,77 @@
import pytest
from xbc import load_xbc
from xbc import loads_xbc
'''
The tests in this file are samples drawn from
https://lwn.net/Articles/806002/.
'''
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 load_xbc('tests/01-keyvalue.xbc') == d
assert loads_xbc(i) == 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 load_xbc('tests/02-block-keyvalue.xbc') == d
assert loads_xbc(i) == d
def test_03():
i = 'feature.options = "foo", "bar"'
d = {
'feature': False,
'feature.options': ['foo', 'bar']
}
assert load_xbc('tests/03-keyvalue-string.xbc') == d
assert loads_xbc(i) == 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 load_xbc('tests/10-compact.xbc') == d
assert loads_xbc(i) == 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,
@ -60,9 +94,28 @@ 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 load_xbc('tests/11-config.xbc') == d
assert loads_xbc(i) == 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,
@ -83,4 +136,4 @@ def test_12():
'ftrace.event.synthetic.initcall_latency.hist.vals': 'lat',
'ftrace.event.synthetic.initcall_latency.hist.sort': 'lat'
}
assert load_xbc('tests/12-config2.xbc') == d
assert loads_xbc(i) == d