summaryrefslogtreecommitdiff
path: root/build-aux/measurestack/test_app_plugins.py
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/measurestack/test_app_plugins.py')
-rw-r--r--build-aux/measurestack/test_app_plugins.py185
1 files changed, 184 insertions, 1 deletions
diff --git a/build-aux/measurestack/test_app_plugins.py b/build-aux/measurestack/test_app_plugins.py
index d7e95b1..da8be65 100644
--- a/build-aux/measurestack/test_app_plugins.py
+++ b/build-aux/measurestack/test_app_plugins.py
@@ -174,7 +174,7 @@ def test_fct() -> None:
# if host:
# __lm_printf => fct=libfmt_libc_fct
# __lm_light_printf => fct=libfmt_libc_fct
- app_plugins.PicoFmtPlugin("rp2040"),
+ app_plugins.PicoFmtPlugin("rp2040", []),
]
def test_filter(name: QName) -> tuple[int, bool]:
@@ -194,3 +194,186 @@ def test_fct() -> None:
graph_plugin.assert_nstatic(result.groups["Main"].rows[QName("a")].nstatic, exp_a)
graph_plugin.assert_nstatic(result.groups["Main"].rows[QName("b")].nstatic, exp_b)
graph_plugin.assert_nstatic(result.groups["Main"].rows[QName("c")].nstatic, exp_c)
+
+
+def test_assert_formatter() -> None:
+ # _________________________________________________________
+ # | |
+ # | |
+ # | main |
+ # | | |
+ # | _ __wrap_vprintf |
+ # | / \ | _______________ |
+ # | | fmt_vfctprintf / \ |
+ # | | \ fmt_state_printf | |
+ # | | \____ ____/ | |
+ # | | \ / | |
+ # | | _vfctprintf | |
+ # | | ____/ \____ ^ |
+ # | | / ?<---snip | |
+ # | | conv_builtin \ | |
+ # | | | libfmt_conv_formatter | |
+ # | | | | | |
+ # | ^ \ lib9p_msg_Rread_format | |
+ # | | \ _____________/ | \______/ |
+ # | | \ / \ |
+ # | | fmt_state_putchar \ |
+ # | | ?<-?<--------snip | |
+ # | | / \_________ | |
+ # | | / \ | |
+ # | | stdio_buffered_printer \ | |
+ # | | \ libfmt_light_fct | |
+ # | | \ | / |
+ # | | \_______ | ________/ |
+ # | | \ | / |
+ # | | __assert_msg_fail |
+ # | | ___/ \____ |
+ # | | snip--->? \ |
+ # | | / \ |
+ # | | __lm_light_printf \ |
+ # | \____________/ __lm_abort |
+ # | |
+ # |_________________________________________________________|
+ #
+ graph: typing.Sequence[tuple[str, typing.Collection[str]]] = [
+ ("main", {"vprintf"}),
+ ("__wrap_vprintf", {"fmt_vfctprintf"}),
+ ("fmt_vfctprintf", {"_vfctprintf"}),
+ ("fmt_state_printf", {"_vfctprintf"}),
+ ("_vfctprintf", {"conv_builtin", "libfmt_conv_formatter"}),
+ ("conv_builtin", {"fmt_state_putchar"}),
+ ("libfmt_conv_formatter", {"lib9p_msg_Rread_format"}),
+ (
+ "lib9p_msg_Rread_format",
+ {"fmt_state_putchar", "__assert_msg_fail", "fmt_state_printf"},
+ ),
+ ("fmt_state_putchar", {"stdio_buffered_printer", "libfmt_light_fct"}),
+ ("stdio_buffered_printer", {"__assert_msg_fail"}),
+ ("libfmt_light_fct", {"__assert_msg_fail"}),
+ ("__assert_msg_fail", {"__lm_light_printf", "__lm_abort"}),
+ ("__lm_light_printf", {"fmt_vfctprintf"}),
+ ("__lm_abort", {}),
+ ]
+
+ # fct-determining wrappers have their callees marked with "|":
+ #
+ # 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <= call_depth
+ # - main() ; +
+ # - __wrap__vprintf() ; +
+ # |- fmt_vfctprintf() ; +
+ # | - _vfctprintf() ; +
+ # | - conv_builtin() ;
+ # | - fmt_state_putchar() ;
+ # | - stdio_buffered_printer() ;
+ # | - __assert_msg_fail() ;
+ # | - __lm_light_printf() ;
+ # | |- fmt_vfctprintf() ;
+ # | | - _vfctprintf() ;
+ # | | - conv_builtin() ;
+ # | | - fmt_state_putchar() ;
+ # | | - stdio_buffered_printer() ; skip (wrong fct)
+ # | | - libfmt_light_fct() ;
+ # | | - __assert_msg_fail() ;
+ # | | - __lm_light_printf() ; skip (nested __assert_msg_fail)
+ # | | - __lm_abort() ;
+ # | | - libfmt_conv_formatter() ; skip (fct won't use %v)
+ # | - __lm_abort() ;
+ # | - libfmt_light_fct() ; skip (wrong fct)
+ # | - libfmt_conv_formatter() ; +
+ # | - lib9p_msg_Rread_format() ; +
+ # | - fmt_state_putchar() ;
+ # | - stdio_buffered_printer() ;
+ # | - __assert_msg_fail() ;
+ # | - __lm_light_printf() ;
+ # | |- fmt_vfctprintf() ;
+ # | | - _vfctprintf() ;
+ # | | - conv_builtin() ;
+ # | | - fmt_state_putchar() ;
+ # | | - stdio_buffered_printer() ; skip (wrong fct)
+ # | | - libfmt_light_fct() ;
+ # | | - __assert_msg_fail() ;
+ # | | - __lm_light_printf() ; skip (neseted __assert_msg_fail)
+ # | | - __lm_abort() ;
+ # | | - libfmt_conv_formatter() ; skip (fct won't use %v)
+ # | - __lm_abort() ;
+ # | - libfmt_light_fct() ; skip (wrong fct)
+ # | - __assert_msg_fail() ;
+ # | - __lm_light_printf() ;
+ # | |- fmt_vfctprintf() ;
+ # | | - _vfctprintf() ;
+ # | | - conv_builtin() ;
+ # | | - fmt_state_putchar() ;
+ # | | - stdio_buffered_printer() ; skip (wrong fct)
+ # | | - libfmt_light_fct() ;
+ # | | - __assert_msg_fail() ;
+ # | | - __lm_light_printf() ; skip (nested__assert_msg_fail)
+ # | | - __lm_abort() ;
+ # | | - libfmt_conv_formatter() ; skip (formatter won't use %v)
+ # | - __lm_abort() ;
+ # | - fmt_state_printf() ; +
+ # | - _vfctprintf() ; +
+ # | - conv_builtin() ; +
+ # | - fmt_state_putchar() ; +
+ # | - stdio_buffered_printer() ; +
+ # | - __assert_msg_fail() ; +
+ # | - __lm_light_printf() ; +
+ # | |- fmt_vfctprintf() ; +
+ # | | - _vfctprintf() ; +
+ # | | - conv_builtin() ; +
+ # | | - fmt_state_putchar() ; +
+ # | | - stdio_buffered_printer() ; skip (wrong fct)
+ # | | - libfmt_light_fct() ; +
+ # | | - __assert_msg_fail() ; +
+ # | | - __lm_light_printf() ; skip (neseted __assert_msg_fail)
+ # | | - __lm_abort() ; +
+ # | | - libfmt_conv_formatter() ; skip (fct won't use %v)
+ # | - __lm_abort() ;
+ # | - libfmt_light_fct() ; skip (wrong fct)
+ # | - libfmt_conv_formatter() ; skip (formatter won't use %v)
+ max_call_depth = 20
+ exp = [
+ "main",
+ "__wrap_vprintf",
+ "fmt_vfctprintf",
+ "_vfctprintf",
+ "libfmt_conv_formatter",
+ "lib9p_msg_Rread_format",
+ "fmt_state_printf",
+ "_vfctprintf",
+ "conv_builtin",
+ "fmt_state_putchar",
+ "stdio_buffered_printer",
+ "__assert_msg_fail",
+ "__lm_light_printf",
+ "fmt_vfctprintf",
+ "_vfctprintf",
+ "conv_builtin",
+ "fmt_state_putchar",
+ "libfmt_light_fct",
+ "__assert_msg_fail",
+ "__lm_abort",
+ ]
+
+ graph_plugin = testutil.GraphProviderPlugin(max_call_depth, graph)
+
+ plugins: list[util.Plugin] = [
+ graph_plugin,
+ app_plugins.LibMiscPlugin(arg_c_fnames=[]),
+ app_plugins.PicoFmtPlugin("rp2040", [BaseName("lib9p_msg_Rread_format")]),
+ ]
+
+ def test_filter(name: QName) -> tuple[int, bool]:
+ if name.base() == BaseName("main"):
+ return 1, True
+ return 0, False
+
+ result = analyze.analyze(
+ ci_fnames=[],
+ app_func_filters={
+ "Main": test_filter,
+ },
+ app=util.PluginApplication(testutil.nop_location_xform, plugins),
+ cfg_max_call_depth=max_call_depth,
+ )
+
+ graph_plugin.assert_nstatic(result.groups["Main"].rows[QName("main")].nstatic, exp)