- if event["count"] != 1:
- success = False
- tap.diagnostic("Expected event {} not found".format(event["name"]))
- if unknown_event_count != 0:
- success = False
- return success
-
-
-tap = lttngtest.TapGenerator(num_tests)
-tap.diagnostic("Test user space constructor/destructor instrumentation coverage")
-
-with lttngtest.test_environment(with_sessiond=True, log=tap.diagnostic) as test_env:
- outputlocation = capture_trace(tap, test_env)
- tap.test(
- validate_trace(outputlocation.path, tap),
- "Validate that trace constains expected events",
- )
+ may_fail = "may_fail" in event.keys() and event["may_fail"]
+ if not may_fail:
+ tap.test(
+ event["count"] == 1,
+ 'Found expected event name="{}" msg="{}"'.format(
+ event["name"], str(event["msg"])
+ ),
+ ),
+ else:
+ tap.skip("Event '{}' may or may not be recorded".format(event["name"]))
+
+ tap.test(unknown_event_count == 0, "Found no unexpected events")
+
+
+success = True
+tests = [
+ {
+ "description": "Test user space constructor/destructor instrumentation coverage (C++ w/ static archive)",
+ "application": "gen-ust-events-constructor/gen-ust-events-constructor-a",
+ "expected_events": copy.deepcopy(expected_events_common + expected_events_tp_a),
+ "skip_if_application_not_present": False,
+ },
+ {
+ "description": "Test user space constructor/destructor instrumentation coverage (C++ w/ dynamic object",
+ "application": "gen-ust-events-constructor/gen-ust-events-constructor-so",
+ "expected_events": copy.deepcopy(
+ expected_events_common + expected_events_tp_so
+ ),
+ # This application is not be built when `NO_SHARED` is set in the
+ # configuration options.
+ "skip_if_application_not_present": True,
+ },
+]
+
+success = True
+for test in tests:
+ tap = lttngtest.TapGenerator(7 + len(test["expected_events"]))
+ with lttngtest.test_environment(with_sessiond=True, log=tap.diagnostic) as test_env:
+ try:
+ outputlocation = capture_trace(
+ tap, test_env, test["application"], test["description"]
+ )
+ except FileNotFoundError as fne:
+ tap.diagnostic(fne)
+ if test["skip_if_application_not_present"]:
+ tap.skip(
+ "Test application '{}' not found".format(test["application"]),
+ tap.remaining_test_cases,
+ )
+ break
+ # Warning: validate_trace mutates test['expected_events']
+ validate_trace(outputlocation.path, tap, test["expected_events"])
+ success = success and tap.is_successful
+