From: Kienan Stewart Date: Wed, 7 Feb 2024 20:49:26 +0000 (-0500) Subject: tests: Handle test failures for ust-constructors with heap allocation X-Git-Url: http://git.liburcu.org/?a=commitdiff_plain;h=b8e79f3f1057ff91224991f76b3837202bde5a06;hp=b8e79f3f1057ff91224991f76b3837202bde5a06;p=lttng-tools.git tests: Handle test failures for ust-constructors with heap allocation Observed issue ============== A number of tests from `ust/ust-constructor/test_ust_constructor.py` fail when compiled with gcc-4.8 (observed on SLES12SP5). Eg. ``` 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 8 - Found expected event name="tp_a:constructor_c_provider_static_archive" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 10 - Found expected event name="tp_a:constructor_cplusplus_provider_static_archive" msg="global - static archive define and provider" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 11 - Found expected event name="tp:constructor_c_across_units_before_define" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 12 - Found expected event name="tp:constructor_cplusplus" msg="global - across units before define" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 13 - Found expected event name="tp:constructor_c_same_unit_before_define" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 14 - Found expected event name="tp:constructor_c_same_unit_after_define" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 15 - Found expected event name="tp:constructor_cplusplus" msg="global - same unit before define" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 16 - Found expected event name="tp:constructor_cplusplus" msg="global - same unit after define" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 17 - Found expected event name="tp:constructor_c_across_units_after_define" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 18 - Found expected event name="tp:constructor_cplusplus" msg="global - across units after define" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 19 - Found expected event name="tp:constructor_c_same_unit_before_provider" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 20 - Found expected event name="tp:constructor_c_same_unit_after_provider" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 21 - Found expected event name="tp:constructor_cplusplus" msg="global - same unit before provider" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 34 - Found expected event name="tp:destructor_cplusplus" msg="global - same unit before provider" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 35 - Found expected event name="tp:destructor_cplusplus" msg="global - across units after define" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 36 - Found expected event name="tp:destructor_cplusplus" msg="global - same unit after define" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 37 - Found expected event name="tp:destructor_cplusplus" msg="global - same unit before define" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 38 - Found expected event name="tp:destructor_cplusplus" msg="global - across units before define" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 39 - Found expected event name="tp_a:destructor_cplusplus_provider_static_archive" msg="global - static archive define and provider" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 41 - Found expected event name="tp:destructor_c_across_units_after_provider" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 42 - Found expected event name="tp:destructor_c_same_unit_after_provider" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 43 - Found expected event name="tp:destructor_c_same_unit_before_provider" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 44 - Found expected event name="tp:destructor_c_across_units_after_define" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 45 - Found expected event name="tp:destructor_c_same_unit_after_define" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 46 - Found expected event name="tp:destructor_c_same_unit_before_define" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 47 - Found expected event name="tp:destructor_c_across_units_before_define" msg="None" 12:22:17 FAIL: ust/ust-constructor/test_ust_constructor.py 48 - Found expected event name="tp_a:destructor_c_provider_static_archive" msg="None" ``` Cause ===== As gcc-4.8 and earlier don't support C99 compound literals, the lttngust `ust-compiler.h` falls back to using heap allocated compound literals[1][2]. The probe registration in these cases is done via a C++ object[3]. As C-style constructors are executed before the C++ runtime is processed, the probe is not yet registered[4]. In a case where g++ <= 4.8 is being used or `-DLTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP` is defined, the following tracepoints will not be recorded: * C-style constructors and destructors in statically linked archives * C-style constructors and destructors in the application itself * Some C++ constructors and destructors invoked during the initialization of the static global variables * Note: this depends on the initialization order both between translation units, which is not specified, and the initialization order (usually lexicographical) within a given translation unit. This is a known limitation; however, the test does not support verifying that it's being run in a such a situation. Solution ======== A small program has been added which returns a different status code depending on whether `LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP` is defined or not. The test script uses this application to signal that certain events may fail (in that they may be present, or they may be absent). Drawbacks ========= None. References ========== [1]: https://github.com/lttng/lttng-ust/commit/e1904921db97b70d94e69f0ab3264c6f7fe62f32 [2]: https://github.com/lttng/lttng-ust/commit/7edfc1722684982b9df894c054d69808dc588a6a [3]: https://github.com/lttng/lttng-ust/commit/05bfa3dc3a6e6b2ece3686a5f384b6645c2a5010 [4]: https://github.com/lttng/lttng-ust/blob/3287f48be61ef3491aff0a80b7185ac57b3d8a5d/include/lttng/ust-compiler.h#L110 Change-Id: I49159df4f85126c641aaf5fb0a8b5b22fd91bf12 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau ---