From 38614aad080084990500c00977e31cbe8add6191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=ADle=20Ekaterin=20Liszka?= Date: Sat, 13 Jan 2024 23:50:23 -0800 Subject: [PATCH] tests: stop using files --- MAINFEST.IN | 1 - tests/01-keyvalue.xbc | 2 - tests/02-block-keyvalue.xbc | 4 -- tests/03-keyvalue-string.xbc | 1 - tests/10-compact.xbc | 1 - tests/11-config.xbc | 21 ------- tests/12-config2.xbc | 19 ------- tests/{test_files.py => test_upstream.py} | 67 ++++++++++++++++++++--- 8 files changed, 60 insertions(+), 56 deletions(-) delete mode 100644 MAINFEST.IN delete mode 100644 tests/01-keyvalue.xbc delete mode 100644 tests/02-block-keyvalue.xbc delete mode 100644 tests/03-keyvalue-string.xbc delete mode 100644 tests/10-compact.xbc delete mode 100644 tests/11-config.xbc delete mode 100644 tests/12-config2.xbc rename tests/{test_files.py => test_upstream.py} (67%) diff --git a/MAINFEST.IN b/MAINFEST.IN deleted file mode 100644 index 243be3e..0000000 --- a/MAINFEST.IN +++ /dev/null @@ -1 +0,0 @@ -include tests/*.xbc \ No newline at end of file diff --git a/tests/01-keyvalue.xbc b/tests/01-keyvalue.xbc deleted file mode 100644 index a76b551..0000000 --- a/tests/01-keyvalue.xbc +++ /dev/null @@ -1,2 +0,0 @@ -feature.option.foo = 1 -feature.option.bar = 2 diff --git a/tests/02-block-keyvalue.xbc b/tests/02-block-keyvalue.xbc deleted file mode 100644 index a594066..0000000 --- a/tests/02-block-keyvalue.xbc +++ /dev/null @@ -1,4 +0,0 @@ -feature.option { - foo = 1 - bar = 2 -} \ No newline at end of file diff --git a/tests/03-keyvalue-string.xbc b/tests/03-keyvalue-string.xbc deleted file mode 100644 index 3439539..0000000 --- a/tests/03-keyvalue-string.xbc +++ /dev/null @@ -1 +0,0 @@ -feature.options = "foo", "bar" diff --git a/tests/10-compact.xbc b/tests/10-compact.xbc deleted file mode 100644 index c9046d1..0000000 --- a/tests/10-compact.xbc +++ /dev/null @@ -1 +0,0 @@ -feature.option{foo=1;bar=2} \ No newline at end of file diff --git a/tests/11-config.xbc b/tests/11-config.xbc deleted file mode 100644 index 2b0966f..0000000 --- a/tests/11-config.xbc +++ /dev/null @@ -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)" - } -} \ No newline at end of file diff --git a/tests/12-config2.xbc b/tests/12-config2.xbc deleted file mode 100644 index aaa6ffa..0000000 --- a/tests/12-config2.xbc +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/tests/test_files.py b/tests/test_upstream.py similarity index 67% rename from tests/test_files.py rename to tests/test_upstream.py index 7a0edcb..d68da69 100644 --- a/tests/test_files.py +++ b/tests/test_upstream.py @@ -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