Merge remote-tracking branch 'origin/char69/cores' into hunt/intermittent-68-suite-cores

# Conflicts:
#	ci/required-suites.json
This commit is contained in:
feder-cr committed 2026-11-22 14:20:52 +01:00
commit ca142970a2
8 files changed
+441 -101

No files matched your search

+3 -2
View File
@@ -113,8 +113,9 @@ jobs:
sudo apt-get install -y xvfb
# the fontconfig e2e trace the opens of the browser: strace is not in the runner image (setsid is, util-linux)
sudo apt-get install -y strace
# tests/test_security_state_engine_e2e.py, on a crash of the engine: a core file where kernel.core_pattern says, and gdb to read it (the test deletes the core and
# uploads the backtrace with the evidence). Only a process that lifts its own core limit leaves a core, the runner's default limit is 0.
# TEMPORARY (the -11 at the exit of the security state's generate): a core file of any crash where kernel.core_pattern says, and gdb to read it. tests/conftest.py
# lifts the core limit of the pytest session (the runner's default soft limit is 0) and, after a test that fails, tests/_crash_cores.py saves gdb's text of every
# core in INVPW_CORE_DIR under invpw-evidence/cores/<test>/ and deletes the core.
sudo apt-get install -y gdb
mkdir -p "$RUNNER_TEMP/invpw-cores"
sudo sysctl -w kernel.core_pattern="$RUNNER_TEMP/invpw-cores/core.%e.%p"
+2 -2
View File
@@ -14,8 +14,8 @@
{"id": "wrapper.e2e.fakeweb", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_fakeweb_p2_e2e.py", "tests/test_fakeweb_p4_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The fake web, offline: our browser on the hard pages (profile P2: a reused routed page reaches networkidle every time, also under a load of three other browsers; the other site is another process) and on the 17-step journey of a person (profile P4), each judged against what stock Firefox does, as tests/fakeweb/pages.json declares it. 4 = 3 + 1. Stock itself is held to that declaration, and compared with ours step by step, by scripts/run_fakeweb.py in .github/workflows/fakeweb.yml. Needs the candidate binary (STEALTHFOX_E2E_BINARY)."},
{"id": "wrapper.e2e.fontconfig", "giro": "G2", "os": ["linux"], "min_tests": 2, "exact": true, "tests": ["tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py"], "marker": "e2e", "needs_root": false, "linux_only": "Fontconfig exists only on Linux: the parent of the engine shows <GRE>/fonts to it (FcConfigAppFontAddDir) to rebuild a font from a path and a face index. On Windows DirectWrite opens the file from its path, with no folder to scan and no cache to read, so this test has no Windows counterpart.", "note": "2 = (1) the stand-in that runs the engine under strace stays in the engine's place, as the core launches it (the leader of a process group of its own): a fake engine with a child, no browser; the process the launcher holds lives as long as the fake engine, and the group killed holds strace and the child (the stand-in that exec'd setsid forked and exited 0 at once: candidate 44161687675); (2) the warm launch of the parent reads the bundle from fontconfig's cache and does not scan it again (from firefox-66, engine_at_least). Two launches under strace with the same XDG_CACHE_HOME of the test, the first cold and the second warm: the cold parent opens every font file of <GRE>/fonts (the folder as the disk lists it) before any page and fontconfig writes its cache; the warm parent does not open every one of them, and it opens a *.cache-* file of fontconfig (a few files are opened to be used, so the verdict asks about the whole folder, as a scan does). Scan and drawing are told apart by position: only what the parent opens before the first page counts (the opens that draw are written as after_startup). Evidence in RUNNER_TEMP/invpw-evidence/fontconfig-cache: the interval and the number of opens of the bundle, the names of the files of the bundle each launch opened before the first page, the size of the cache file, the VmRSS of the parent after about:blank and after a page with every family, and a third launch with gfx.bundled-fonts.activate=0 (the behaviour before), which is evidence only. Needs strace on the runner: without it both are red, not skipped. No threshold."},
{"id": "wrapper.unit.compositing", "giro": "G1", "os": ["linux", "windows"], "min_tests": 30, "exact": true, "tests": ["tests/test_the_page_bytes_reference_compares_decoded_pixels.py"], "marker": "unit", "needs_root": false, "note": "The helpers of wrapper.e2e.compositing on known inputs, no browser: the PNG compared on decoded pixels (another deBG chunk and compression are the same, one pixel is not, every scanline filter), the comparison with a reference (changed, missing and extra keys named, the entry to record), the type of an engine process, an engine process known by its executable and not by the name it gives itself (Linux), and the CPU of a window, and the shape of the committed Windows reference, and the box cut out of a screenshot (its pixels, a box outside the picture refused, written as a PNG and read back, two boxes told apart by a pixel that is named, the pixels that are not grey)."},
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 2307, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_report.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_launch_counters_run_on_github.py", "tests/test_launcher_config.py", "tests/test_launcher_helpers.py", "tests/test_motion_never_hides_a_programming_error.py", "tests/test_moving_page_model.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_no_legacy_in_the_wrapper.py", "tests/test_no_override_leaves_the_persona_scheme.py", "tests/test_no_thread_is_started_on_the_reader.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/testLine truncated
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 2308, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_report.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_launch_counters_run_on_github.py", "tests/test_launcher_config.py", "tests/test_launcher_helpers.py", "tests/test_motion_never_hides_a_programming_error.py", "tests/test_moving_page_model.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_no_legacy_in_the_wrapper.py", "tests/test_no_override_leaves_the_persona_scheme.py", "tests/test_no_thread_is_started_on_the_reader.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pin.py", "tests/test_pin_dicts_Line truncated
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 2311, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_report.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_launch_counters_run_on_github.py", "tests/test_launcher_config.py", "tests/test_launcher_helpers.py", "tests/test_motion_never_hides_a_programming_error.py", "tests/test_moving_page_model.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_no_legacy_in_the_wrapper.py", "tests/test_no_override_leaves_the_persona_scheme.py", "tests/test_no_thread_is_started_on_the_reader.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/testLine truncated
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 2312, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_report.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_launch_counters_run_on_github.py", "tests/test_launcher_config.py", "tests/test_launcher_helpers.py", "tests/test_motion_never_hides_a_programming_error.py", "tests/test_moving_page_model.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_no_legacy_in_the_wrapper.py", "tests/test_no_override_leaves_the_persona_scheme.py", "tests/test_no_thread_is_started_on_the_reader.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pin.py", "tests/test_pin_dicts_Line truncated
{"id": "wrapper.e2e.securitystate", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_security_state_engine_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The security state the core declares, against the engine: the engine launched directly in its generate mode makes what it is given (the contract's result, security_state/ with the bytes of the full filter and of the delta, the core's own validation of it); a normal launch declares no pref of the mode and re-imports nothing; a certificate that Mozilla's CRLite test data say is revoked in a delta is refused at the first navigation (SEC_ERROR_REVOKED_CERTIFICATE) while a valid one loads, and the revoked one loads when the ready directory has no data; a ready directory with no or an empty security_state/ starts. Certificates made on the run (a fresh root trusted in cert9.db by the engine's own xpcshell, Mozilla's default test key as the key of CN=int), servers on loopback, no network. Red on firefox-67 (no generate mode)."},
{"id": "wrapper.e2e.suite.linux.1", "giro": "G2", "os": ["linux"], "min_tests": 376, "exact": true, "tests": ["tests/test_a_closed_browser_leaves_the_others_alone_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_left_documents_body_is_evicted_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_browser_output_is_drained.py", "tests/test_click_rhythm.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_declared_host_network_e2e.py", "tests/test_detectors_e2e.py", "tests/test_e2e.py", "tests/test_element_handle_actions.py", "tests/test_element_screenshot_e2e.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_display_linux.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_ignore_https_errors_e2e.py", "tests/test_injected_node_surface.py", "tests/test_juggler_connection.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_navigation_response.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_oop_frame_element.py", "tests/test_oop_frame_geometry.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_screencast.py", "tests/test_screencast_stop_e2e.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_security_state_engine_e2e.py", "tests/test_service_worker.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_offline_e2e.py", "tests/test_shadow_trusted_input.py", "tests/test_strict_and_force.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_a_launch_scans_no_process_of_the_machine", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_after_close_no_process_of_the_session_is_left", "tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_trial_does_not_act.py", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_ua_widget_not_selectable.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_through_the_proxy_of_that_context", "tests/test_webrtc_realness.py::test_two_contexts_with_two_proxies_each_gets_the_srflx_of_its_own"], "marker": "e2e", "needs_root": false, "windows_twin"Line truncated
{"id": "wrapper.e2e.suite.linux.2", "giro": "G2", "os": ["linux"], "min_tests": 411, "exact": true, "tests": ["tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_drag_motion.py", "tests/test_expose_binding_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_new_page_defaults.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_e2e.py", "tests/test_route_post_data_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screenshot_of_text_returns_linux_e2e.py", "tests/test_scroll_into_view.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_service_workers_blocked.py", "tests/test_set_input_files_payloads.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 564 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapLine truncated
+174
View File
@@ -0,0 +1,174 @@
"""TEMPORARY: the core of every crash of an engine the tests start, read by gdb after a test that fails. Remove it with tests/_generation_evidence.py once the
exit by SIGSEGV (-11) of the engine in generate mode on Linux (runs 44985244053 and 45014369018) is understood and fixed.
A release build crashes in silence: MOZ_CRASH, MOZ_RELEASE_ASSERT and a Rust panic write to a null address and print nothing, so stderr cannot tell a crash the
code wanted from a bad access. The core can: `gMozCrashReason` says the reason of a wanted crash, the faulting address and the thread that fell say the rest.
* `lift_the_core_limit_of_the_session()`: once, at the start of pytest (tests/conftest.py, `pytest_configure`), on Linux: the soft RLIMIT_CORE of the pytest
process raised to its hard limit. Every process a test starts inherits it, the engines the CORE launches included (its `generate` passes no limit of its own),
so a crash of any of them leaves a core where `kernel.core_pattern` says. The Linux e2e jobs (e2e.yml, and gate.yml of the engine series) point it at
`$INVPW_CORE_DIR` and install gdb.
* `after_the_report(nodeid, when, failed)`: tests/conftest.py calls it after each phase of every test (`pytest_runtest_makereport`). When `$INVPW_CORE_DIR` is set:
after a phase that FAILED, every `core*` there is read by gdb into `<evidence>/cores/<nodeid>/<core>.gdb.txt` and deleted, and `notes.txt` says what was found
(no core included); after the teardown of a test that did not fail, the cores left are deleted and listed in `<evidence>/cores/after-passing-tests.txt` (a crash
in a passing test is information too). `<evidence>` is `$RUNNER_TEMP/invpw-evidence`, the folder the e2e jobs upload.
* `gdb_text(core, into)`: the one gdb path of the tests: the executable is the one the core's header names (else `$INVPW_BINARY_PATH`), and the text holds the
backtrace of every thread, their names, the signal's address, `gMozCrashReason`, the registers, the shared libraries with their addresses and build ids, and the
mappings. Only the text is kept: a core of the engine is hundreds of MB.
Best effort: nothing here raises, and nothing here decides a test.
"""
from __future__ import annotations
import contextlib
import os
import re
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
#: The folder under `$RUNNER_TEMP` the e2e workflows upload (`invpw-evidence-*`, "Keep what the tests saved").
EVIDENCE_FOLDER = "invpw-evidence"
CORES = "cores"
AFTER_PASSING = "after-passing-tests.txt"
#: How long gdb may take to read a core of the engine, and to read its header only.
GDB_TIMEOUT_S = 600
HEADER_TIMEOUT_S = 120
#: What gdb prints from the core: the crashing thread first, then every thread with its name, the signal, the reason of a wanted crash, where libxul is.
GDB_COMMANDS = (
"set pagination off",
"set width 0",
"bt",
"info threads",
"thread apply all bt",
"p $_siginfo",
"p $_siginfo._sifields._sigfault.si_addr",
"x/s *(char**)&gMozCrashReason",
"info registers",
"x/8i $pc",
"info sharedlibrary",
"python print('\\n'.join('%s %s' % (o.filename, o.build_id) for o in gdb.objfiles()))",
"info proc mappings",
)
_HEADER = re.compile(r"Core was generated by `([^']*)'")
#: The tests a phase of which failed: their teardown reads its cores too.
_FAILED = set()
def lift_the_core_limit_of_the_session():
"""Linux: the soft RLIMIT_CORE of this process raised to its hard limit, inherited by every child. Elsewhere, or if it is refused, nothing."""
if not sys.platform.startswith("linux"):
return
try:
import resource
_soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
resource.setrlimit(resource.RLIMIT_CORE, (hard, hard))
except (ImportError, OSError, ValueError):
pass
def core_pattern():
try:
return Path("/proc/sys/kernel/core_pattern").read_text(encoding="utf-8").strip()
except OSError as exc:
return "unreadable: %r" % (exc,)
def gdb():
"""The gdb command (a list), or None when gdb is not installed."""
found = shutil.which("gdb")
return [found] if found else None
def evidence_root():
base = os.environ.get("RUNNER_TEMP") or tempfile.gettempdir()
return Path(base) / EVIDENCE_FOLDER / CORES
def folder_name(nodeid):
return re.sub(r"[^A-Za-z0-9._-]+", "_", nodeid).strip("_")[:150] or "unnamed"
def _cores():
where = os.environ.get("INVPW_CORE_DIR")
if not where or not Path(where).is_dir():
return None, []
return Path(where), sorted((path for path in Path(where).glob("core*") if path.is_file()), key=lambda path: path.stat().st_mtime)
def executable_of(core, command):
"""The executable the core's header names when it is a file, else `$INVPW_BINARY_PATH` (or `$STEALTHFOX_E2E_BINARY`), else None. Returns (path, how)."""
header = ""
try:
done = subprocess.run(command + ["-batch", "-nx", "-c", str(core)], stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
timeout=HEADER_TIMEOUT_S)
header = done.stdout.decode("utf-8", "replace")
except Exception as exc: # best effort
header = "header unreadable: %r" % (exc,)
match = _HEADER.search(header)
named = match.group(1).split()[0] if match and match.group(1).split() else None
if named and Path(named).is_file():
return named, "from the core's header"
for variable in ("INVPW_BINARY_PATH", "STEALTHFOX_E2E_BINARY"):
if os.environ.get(variable) and Path(os.environ[variable]).is_file():
return os.environ[variable], "from $%s (the header names %r)" % (variable, named)
return None, "none (the header names %r)" % (named,)
def gdb_text(core, into):
"""gdb's text of `core` in `into/<core>.gdb.txt`. One line saying what was done. Does not delete the core."""
command = gdb()
size = core.stat().st_size
if command is None:
return "core %s (%d bytes, kernel.core_pattern %r) but gdb is not installed" % (core.name, size, core_pattern())
exe, how = executable_of(core, command)
argv = command + ["-batch", "-nx"]
for line in GDB_COMMANDS:
argv += ["-ex", line]
argv += ([exe] if exe else []) + ["-c", str(core)]
target = into / (core.name + ".gdb.txt")
try:
done = subprocess.run(argv, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=GDB_TIMEOUT_S)
target.write_bytes(("executable: %s (%s)\n\n" % (exe, how)).encode("utf-8") + done.stdout)
return "core %s (%d bytes): gdb exited %d, %d bytes of text in %s; executable %s" % (core.name, size, done.returncode, len(done.stdout), target.name, how)
except Exception as exc:
return "core %s (%d bytes): gdb failed: %r" % (core.name, size, exc)
def after_the_report(nodeid, when, failed):
"""After a phase (`setup`, `call`, `teardown`) of the test `nodeid`: see the module's docstring. Never raises."""
try:
failed_before = nodeid in _FAILED
if failed:
_FAILED.add(nodeid)
if when == "teardown":
_FAILED.discard(nodeid)
where, cores = _cores()
if where is None:
return
if failed or (failed_before and cores):
into = evidence_root() / folder_name(nodeid)
into.mkdir(parents=True, exist_ok=True)
notes = ["%s failed (phase %s); INVPW_CORE_DIR %s, kernel.core_pattern %r, gdb %s" % (nodeid, when, where, core_pattern(), gdb())]
if not cores:
notes.append("no core file in %s" % where)
for core in cores:
notes.append(gdb_text(core, into))
with open(str(into / "notes.txt"), "a", encoding="utf-8") as sink:
sink.write("\n".join(notes) + "\n")
elif when == "teardown" and cores:
root = evidence_root()
root.mkdir(parents=True, exist_ok=True)
with open(str(root / AFTER_PASSING), "a", encoding="utf-8") as sink:
for core in cores:
sink.write("%s\t%s\t%d bytes (deleted, not read)\n" % (nodeid, core.name, core.stat().st_size))
else:
return
for core in cores:
with contextlib.suppress(OSError):
core.unlink()
except Exception: # the evidence is best effort: the test's own outcome is what counts
pass
+25 -67
View File
@@ -4,15 +4,16 @@
Two launches of the engine in generate mode run in tests/test_security_state_engine_e2e.py: the test's own (`-profile <p>` with the four prefs) and the
CORE's (`invisible_core._security_state_generate.generate`, which `_ready` calls once per module and whose outcome the three tests that need a ready
directory share). The core sends the engine's stdout and stderr to the null device, deletes its work profile before it raises `GenerationError`, and
starts the engine with the core size limit of the test process (0 on the runners): a crash of its launch left nothing at all.
starts the engine with the core size limit of the test process: a crash of its launch left nothing at all.
* `save_what_the_failed_generation_left` saves, in `$RUNNER_TEMP/invpw-evidence/<name>/` (the folder the e2e jobs upload), the engine's stdout and stderr,
the files of the profile with their sizes (the result, `user.js` and `security_state/` copied), and on Linux gdb's backtrace of the core the crash left
(`kernel.core_pattern` points at `$INVPW_CORE_DIR` on the e2e job, which installs gdb);
* `lift_the_core_limit` is the `preexec_fn` of a launch: the child's soft RLIMIT_CORE raised to its hard limit, so a crash leaves a core;
* `save_what_the_failed_generation_left` saves, in `$RUNNER_TEMP/invpw-evidence/<name>/` (the folder the e2e jobs upload), the engine's stdout and stderr and
the files of the profile with their sizes (the result, `user.js` and `security_state/` copied);
* `the_core_s_generation_keeps_its_evidence(work, name)` wraps the core's own launch while it is in force: its Popen writes stdout and stderr to files of
`work` and lifts the core limit, the files of the work profile are noted when the engine exits (before the core deletes them), and when `generate`
raises, everything is saved under `name` and the error is raised unchanged. The core's launch line, environment and outcome are not touched.
`work`, the files of the work profile are noted when the engine exits (before the core deletes them), and when `generate` raises, everything is saved
under `name` and the error is raised unchanged. The core's launch line, environment and outcome are not touched.
The CORE file of a crash is not read here: tests/_crash_cores.py lifts the core limit of the whole pytest session (every engine inherits it, the core's
launches included) and, after the test fails, saves gdb's text of every core in `$INVPW_CORE_DIR` under `invpw-evidence/cores/<test>/`.
Saving is best effort: it never raises and never decides a test (the assertion of the test, or the core's error, does).
"""
@@ -27,12 +28,12 @@ import sys
import time
from pathlib import Path
import _crash_cores
#: The folder under `$RUNNER_TEMP` the e2e workflows upload (`invpw-evidence-*`).
EVIDENCE_FOLDER = "invpw-evidence"
RESULT_NAME = "securitystate-result.json"
STATE_DIR = "security_state"
#: How long gdb may take to read a core of the engine.
GDB_TIMEOUT_S = 600
def evidence_folder(name, fallback):
@@ -43,17 +44,6 @@ def evidence_folder(name, fallback):
return folder
def lift_the_core_limit():
"""In the child, before exec (`preexec_fn`, Linux): the soft RLIMIT_CORE raised to the hard one. A failure is left silent: the child starts as it would have."""
try:
import resource
_soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
resource.setrlimit(resource.RLIMIT_CORE, (hard, hard))
except (ImportError, OSError, ValueError):
pass
def _profile_of(argv):
argv = [str(part) for part in argv]
return Path(argv[argv.index("-profile") + 1]) if "-profile" in argv[:-1] else None
@@ -76,10 +66,10 @@ def snapshot_the_profile(profile, into):
return "profile files: %d" % len(listing)
def save_what_the_failed_generation_left(binary, profile, output, started_at, code, why, folder, *, snapshot=None, cwd=None):
"""ONLY after a generation that failed: `<output>.stdout` and `<output>.stderr` copied as `engine.stdout`/`engine.stderr`, the profile's files (from `profile`,
or from a `snapshot` folder made by `snapshot_the_profile` when the profile is gone), and on Linux the backtrace of the core the crash left; `notes.txt` says
what was found. Never raises."""
def save_what_the_failed_generation_left(profile, output, code, why, folder, *, snapshot=None):
"""ONLY after a generation that failed: `<output>.stdout` and `<output>.stderr` copied as `engine.stdout`/`engine.stderr` and the profile's files (from
`profile`, or from a `snapshot` folder made by `snapshot_the_profile` when the profile is gone); `notes.txt` says what was found, and where the core of a
crash goes. Never raises."""
notes = ["exit code %r; %s" % (code, why or "the engine exited")]
try:
for suffix in (".stdout", ".stderr"):
@@ -94,47 +84,19 @@ def save_what_the_failed_generation_left(binary, profile, output, started_at, co
notes.append("profile: as the engine left it at its exit (the core deleted it afterwards)")
else:
notes.append(snapshot_the_profile(profile, folder))
if sys.platform.startswith("linux"):
notes.append(core_backtrace(binary, cwd or os.getcwd(), folder, started_at))
notes.append(where_the_core_goes())
except Exception as exc: # the evidence is best effort: the test reports the failure
notes.append("saving the evidence failed: %r" % (exc,))
with open(str(folder / "notes.txt"), "a", encoding="utf-8") as sink:
sink.write("\n".join(notes) + "\n")
def core_pattern():
try:
return Path("/proc/sys/kernel/core_pattern").read_text(encoding="utf-8").strip()
except OSError as exc:
return "unreadable: %r" % (exc,)
def core_backtrace(binary, cwd, folder, started_at):
"""The core the crash left (in `$INVPW_CORE_DIR`, the folder e2e.yml points `kernel.core_pattern` at; else in `cwd`, the working directory of the launch, where
a relative pattern writes): gdb's backtraces in `gdb-backtrace.txt`. The cores found are deleted (they are hundreds of MB). One line saying what was done."""
pattern = core_pattern()
where = Path(os.environ.get("INVPW_CORE_DIR") or cwd)
cores = sorted((path for path in where.glob("core*") if path.is_file() and path.stat().st_mtime >= started_at - 2), key=lambda path: path.stat().st_mtime)
gdb = shutil.which("gdb")
if not cores:
return "no core file in %s (kernel.core_pattern is %r, INVPW_CORE_DIR is %r, gdb is %s)" % (where, pattern, os.environ.get("INVPW_CORE_DIR"), gdb)
core = cores[-1]
size = core.stat().st_size
try:
if gdb is None:
return "core %s (%d bytes, kernel.core_pattern %r) but gdb is not installed" % (core.name, size, pattern)
try:
done = subprocess.run([gdb, "-batch", "-nx", "-ex", "set pagination off", "-ex", "bt", "-ex", "info registers", "-ex", "x/8i $pc", "-ex", "info sharedlibrary",
"-ex", "thread apply all bt", str(binary), str(core)], stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
timeout=GDB_TIMEOUT_S)
(folder / "gdb-backtrace.txt").write_bytes(done.stdout)
return "core %s (%d bytes, kernel.core_pattern %r): gdb exited %d, %d bytes of backtrace" % (core.name, size, pattern, done.returncode, len(done.stdout))
except Exception as exc:
return "core %s (%d bytes, kernel.core_pattern %r): gdb failed: %r" % (core.name, size, pattern, exc)
finally:
for leftover in cores:
with contextlib.suppress(OSError):
leftover.unlink()
def where_the_core_goes():
"""One line for `notes.txt`: where the core of a crash is read (Linux), or that there is none to read (elsewhere)."""
if not sys.platform.startswith("linux"):
return "core files: Linux only (tests/_crash_cores.py); none is looked for on %s" % sys.platform
return "core file: read by tests/_crash_cores.py after the test fails, into invpw-evidence/cores/<test>/ (INVPW_CORE_DIR %r, kernel.core_pattern %r, gdb %s)" % (
os.environ.get("INVPW_CORE_DIR"), _crash_cores.core_pattern(), _crash_cores.gdb())
class _Subprocess:
@@ -149,8 +111,8 @@ class _Subprocess:
@contextlib.contextmanager
def the_core_s_generation_keeps_its_evidence(work, name):
"""While in force, every engine the core's `generate` starts writes its stdout and stderr to files of `work`, has its core limit lifted (Linux), and has the
files of its profile noted when it exits; if the block raises (the core's `GenerationError`), each launch is saved in the evidence folder `name` and the
"""While in force, every engine the core's `generate` starts writes its stdout and stderr to files of `work` and has the files of its profile noted when it
exits; if the block raises (the core's `GenerationError`), each launch is saved in the evidence folder `name` and the
exception goes on unchanged. Yields the list of the launches (dicts: argv, output, started_at, code, snapshot)."""
module = importlib.import_module("invisible_core._security_state_generate")
work = Path(work)
@@ -161,13 +123,10 @@ def the_core_s_generation_keeps_its_evidence(work, name):
def popen(argv, *args, **kwargs):
output = work / ("engine-%d" % len(launches))
launch = {"argv": [str(part) for part in argv], "output": output, "started_at": time.time(), "code": "not exited", "snapshot": None,
"cwd": kwargs.get("cwd")}
launch = {"argv": [str(part) for part in argv], "output": output, "started_at": time.time(), "code": "not exited", "snapshot": None}
launches.append(launch)
sinks = [open(str(output) + ".stdout", "wb"), open(str(output) + ".stderr", "wb")]
kwargs["stdout"], kwargs["stderr"] = sinks
if sys.platform.startswith("linux") and kwargs.get("preexec_fn") is None:
kwargs["preexec_fn"] = lift_the_core_limit
try:
proc = real_popen(argv, *args, **kwargs)
finally:
@@ -200,8 +159,7 @@ def the_core_s_generation_keeps_its_evidence(work, name):
target.mkdir(parents=True, exist_ok=True)
with open(str(target / "notes.txt"), "a", encoding="utf-8") as sink:
sink.write("argv: %r\n" % (launch["argv"],))
save_what_the_failed_generation_left(launch["argv"][0], _profile_of(launch["argv"]), launch["output"], launch["started_at"], launch["code"], str(exc),
target, snapshot=launch["snapshot"], cwd=launch["cwd"])
save_what_the_failed_generation_left(_profile_of(launch["argv"]), launch["output"], launch["code"], str(exc), target, snapshot=launch["snapshot"])
raise
finally:
module.subprocess, module._wait_for_exit = real_module, real_wait
+14
View File
@@ -71,6 +71,10 @@ def _watchdog_open():
def pytest_configure(config):
# TEMPORARY, with tests/_crash_cores.py (the -11 at the exit of the security state's generate): on Linux every engine of the run, the core's launches
# included, inherits a core limit equal to the hard one, so a crash leaves a core in $INVPW_CORE_DIR (kernel.core_pattern on the e2e jobs).
import _crash_cores
_crash_cores.lift_the_core_limit_of_the_session()
# The run stops at the first refusal of the engine (tests/engine_refusal.py).
from engine_refusal import StopAtTheFirstRefusal
config.pluginmanager.register(StopAtTheFirstRefusal(config), "engine-refusal-stop")
@@ -96,6 +100,16 @@ def pytest_runtest_teardown(item, nextitem):
faulthandler.cancel_dump_traceback_later()
@pytest.hookimpl(wrapper=True)
def pytest_runtest_makereport(item, call):
"""TEMPORARY, with tests/_crash_cores.py: after a phase that failed, gdb's text of every core in $INVPW_CORE_DIR is saved in the evidence and the core deleted;
the cores left after a test that passed are deleted and listed."""
report = yield
import _crash_cores
_crash_cores.after_the_report(item.nodeid, report.when, report.failed)
return report
def pytest_collection_modifyitems(config, items):
"""The e2e tests of the post-publication files (``tests/_post_publication.py``: pip, uv, PyPI, GitHub) belong to the round after a publication: a run
that does not NAME their file does not run them. ``user-install.yml`` names both files; ``scripts/run_e2e.py`` and every PR or candidate leg do not."""
@@ -1,14 +1,18 @@
"""TEMPORARY, with tests/_generation_evidence.py: a generation of the security state that fails through the CORE's own launch leaves its evidence.
"""TEMPORARY, with tests/_generation_evidence.py and tests/_crash_cores.py: a generation of the security state that fails through the CORE's own launch leaves its
evidence, gdb's text of the core included.
In run 45014369018 the core's `generate` (called once per module by `_ready` of tests/test_security_state_engine_e2e.py, its outcome shared by three tests)
saw the engine exit with -11 and the evidence folder had nothing of it: the core sends stdout and stderr to the null device, deletes the work profile before it
raises, and starts the engine with the test process's core limit (0 on the runners). Here a fake engine (this Python, a script) goes through the same path, the
core's real `generate` under `the_core_s_generation_keeps_its_evidence`, no browser:
core's real `generate` under `the_core_s_generation_keeps_its_evidence`, no browser, and then through what tests/conftest.py does after a test that fails
(`_crash_cores.after_the_report`):
* a fake that writes on stdout and stderr, leaves a file in its profile and ends by SIGSEGV (on Windows `os.kill` ends it with exit code 11): the error of the core
is raised unchanged, and the folder holds the two outputs, the profile's files and the exit code; on Linux the fake's own RLIMIT_CORE says the soft limit was
raised to the hard one, and where a core can land where it is looked for (a relative `kernel.core_pattern`, or `$INVPW_CORE_DIR`) and gdb exists, gdb's
backtrace is there; elsewhere the notes say which of the two is missing;
is raised unchanged, and the folder holds the two outputs, the profile's files and the exit code. On Linux the fake's own RLIMIT_CORE is the session's, its soft
limit equal to the hard one (raised once by tests/conftest.py at the start of pytest, not by the launch: the core's Popen is not given a limit), and where a core
lands where it is looked for (`$INVPW_CORE_DIR` under an absolute `kernel.core_pattern` there, as on the e2e jobs, or a relative pattern) and gdb exists, the
evidence holds gdb's TEXT with a backtrace of the SIGSEGV and the core is deleted; where no core can land, the notes say there was none. On Windows the notes say
that cores are Linux only and nothing of them is written;
* a fake that exits 0 but leaves no result: the core refuses AFTER the exit, the profile is already deleted, and its files are saved from what was noted at exit;
* the control: the same crash through the core WITHOUT the wrapper leaves no evidence folder at all (the state of run 45014369018), and the wrapper puts the core's
module back as it found it.
@@ -16,17 +20,22 @@ core's real `generate` under `the_core_s_generation_keeps_its_evidence`, no brow
from __future__ import annotations
import json
import os
import re
import subprocess
import sys
from pathlib import Path
import pytest
from _generation_evidence import core_pattern, the_core_s_generation_keeps_its_evidence
import _crash_cores
from _generation_evidence import the_core_s_generation_keeps_its_evidence
pytestmark = pytest.mark.unit
NAME = "generation-under-test"
#: The test whose failure `after_the_report` is told about.
NODEID = "tests/test_security_state_engine_e2e.py::the_test_that_failed"
LEFT = "left-by-the-fake-engine.txt"
_FAKE = r'''
@@ -58,18 +67,42 @@ def _inputs(directory):
return Inputs(directory / "intermediates.json", directory / "onecrl.json", directory / "crlite.json")
def _where_a_core_lands(tmp_path, monkeypatch):
"""Linux: the folder where a crash of the fake leaves its core and `after_the_report` looks for it, set as `$INVPW_CORE_DIR`; or None when no core can land
there (a piped `kernel.core_pattern`, a hard limit of 0), with `$INVPW_CORE_DIR` an empty folder. Windows: None, and no `$INVPW_CORE_DIR` (as on the runners)."""
if not sys.platform.startswith("linux"):
monkeypatch.delenv("INVPW_CORE_DIR", raising=False)
return None
import resource
pattern = _crash_cores.core_pattern()
given = (os.environ.get("INVPW_CORE_DIR") or "").rstrip("/")
if resource.getrlimit(resource.RLIMIT_CORE)[1] != 0:
if given and Path(given).is_dir() and pattern.startswith(given + "/") and "/" not in pattern[len(given) + 1:]:
return Path(given)
if not pattern.startswith("|") and "/" not in pattern and not pattern.startswith("unreadable"):
monkeypatch.setenv("INVPW_CORE_DIR", str(tmp_path / "cwd"))
return tmp_path / "cwd"
(tmp_path / "no-core").mkdir()
monkeypatch.setenv("INVPW_CORE_DIR", str(tmp_path / "no-core"))
return None
@pytest.fixture
def setting(tmp_path, monkeypatch):
"""The evidence under `tmp_path/runner` (as `$RUNNER_TEMP` would be), cores of a relative pattern in `tmp_path/cwd`, the fake and the inputs."""
"""The evidence under `tmp_path/runner` (as `$RUNNER_TEMP` would be), the folder a core lands in, the fake and the inputs. At the end the cores the fakes left
(the control's crash too) are deleted as after a passing test, while `$RUNNER_TEMP` is still `tmp_path/runner`."""
monkeypatch.setenv("RUNNER_TEMP", str(tmp_path / "runner"))
monkeypatch.delenv("INVPW_CORE_DIR", raising=False)
(tmp_path / "cwd").mkdir()
monkeypatch.chdir(tmp_path / "cwd")
lands = _where_a_core_lands(tmp_path, monkeypatch)
fake = tmp_path / "fake_engine.py"
fake.write_text(_FAKE, encoding="utf-8")
inputs_dir = tmp_path / "inputs"
inputs_dir.mkdir()
return {"root": tmp_path, "fake": fake, "inputs": _inputs(inputs_dir), "folder": tmp_path / "runner" / "invpw-evidence" / NAME}
yield {"root": tmp_path, "fake": fake, "inputs": _inputs(inputs_dir), "folder": tmp_path / "runner" / "invpw-evidence" / NAME, "lands": lands,
"cores": tmp_path / "runner" / "invpw-evidence" / "cores"}
_crash_cores.after_the_report("the fixture of " + NODEID, "teardown", False)
def _generate(setting, mode, *, wrapped):
@@ -90,8 +123,9 @@ def _read(path):
return path.read_text(encoding="utf-8", errors="replace") if path.is_file() else "<%s is not there>" % path.name
def test_a_crash_of_the_core_s_launch_keeps_the_engine_s_output_the_profile_and_the_core(setting):
def test_a_crash_of_the_core_s_launch_keeps_the_engine_s_output_the_profile_and_gdb_s_text_of_the_core(setting):
error = _generate(setting, "crash", wrapped=True)
_crash_cores.after_the_report(NODEID, "call", True) # what tests/conftest.py does after the test that ran the generation fails
expected_code = -11 if sys.platform != "win32" else 11
assert "exited with %d" % expected_code in error, error
folder = setting["folder"]
@@ -103,16 +137,30 @@ def test_a_crash_of_the_core_s_launch_keeps_the_engine_s_output_the_profile_and_
listing = _read(folder / "profile-files.tsv")
assert LEFT in listing and "user.js" in listing, listing
assert (folder / "user.js").is_file(), sorted(p.name for p in folder.iterdir())
if sys.platform.startswith("linux"):
limits = [line.split()[1:] for line in stderr.splitlines() if line.startswith("RLIMIT_CORE ")]
assert len(limits) == 1 and limits[0][0] == limits[0][1], "the fake's core limit was not raised to its hard limit: %s" % stderr
pattern = core_pattern()
lands_here = not pattern.startswith("|") and "/" not in pattern and not pattern.startswith("unreadable")
if lands_here and subprocess.run(["sh", "-c", "command -v gdb"], stdout=subprocess.DEVNULL).returncode == 0:
assert "gdb exited" in notes and (folder / "gdb-backtrace.txt").stat().st_size > 0, notes
assert not list(Path.cwd().glob("core*")), "the core was not deleted after gdb read it"
else:
assert "no core file" in notes or "gdb is not installed" in notes, notes
if not sys.platform.startswith("linux"):
assert "core files: Linux only" in notes, notes
assert not setting["cores"].exists(), "a folder of cores on %s: %s" % (sys.platform, sorted(p.name for p in setting["cores"].rglob("*")))
return
import resource
session = resource.getrlimit(resource.RLIMIT_CORE)
limits = [tuple(int(part) for part in line.split()[1:]) for line in stderr.splitlines() if line.startswith("RLIMIT_CORE ")]
assert session[0] == session[1], "the session's core limit was not raised to its hard limit: %r" % (session,)
assert limits == [session], "the fake's core limit %r is not the session's %r" % (limits, session)
assert "read by tests/_crash_cores.py" in notes, notes
cores = setting["cores"] / _crash_cores.folder_name(NODEID)
cores_notes = _read(cores / "notes.txt")
if setting["lands"] is not None and subprocess.run(["sh", "-c", "command -v gdb"], stdout=subprocess.DEVNULL).returncode == 0:
texts = sorted(cores.glob("core*.gdb.txt"))
assert len(texts) == 1, cores_notes
text = _read(texts[0])
assert "SIGSEGV" in text and re.search(r"^#0\s", text, re.M), "gdb's text has no backtrace of the SIGSEGV:\n%s" % text[:4000]
assert "gdb exited" in cores_notes, cores_notes
assert not list(setting["lands"].glob("core*")), "the core was not deleted after gdb read it"
elif setting["lands"] is not None:
assert "gdb is not installed" in cores_notes, cores_notes
else:
assert "no core file" in cores_notes, cores_notes
def test_a_refusal_after_a_clean_exit_keeps_the_profile_the_core_deleted(setting):
+7 -10
View File
@@ -34,13 +34,12 @@ import ssl
import subprocess
import sys
import threading
import time
from http.server import BaseHTTPRequestHandler
from pathlib import Path
import pytest
from _generation_evidence import evidence_folder, lift_the_core_limit, save_what_the_failed_generation_left, the_core_s_generation_keeps_its_evidence
from _generation_evidence import evidence_folder, save_what_the_failed_generation_left, the_core_s_generation_keeps_its_evidence
from _servers import LocalServer
pytestmark = pytest.mark.e2e
@@ -118,12 +117,11 @@ def _engine_env(work: Path) -> dict:
return env
def _run_to_the_end(argv, env, cwd, timeout_s, *, output_to=None, core_dumps=False):
def _run_to_the_end(argv, env, cwd, timeout_s, *, output_to=None):
"""Runs `argv` with nothing on stdout and stderr (or, with `output_to`, with both written to files `<output_to>.stdout` and `<output_to>.stderr`, which is all
that changes); (exit code, None) or (None, "timed out ...") with its whole tree ended. `core_dumps` (Linux only) lifts the core size limit of the process, so that
a crash leaves a core file where `kernel.core_pattern` says (e2e.yml sets it)."""
that changes); (exit code, None) or (None, "timed out ...") with its whole tree ended. A crash leaves a core where `kernel.core_pattern` says: the process
inherits the core limit of the session (TEMPORARY, tests/_crash_cores.py, which reads it after the test fails)."""
flags = getattr(subprocess, "CREATE_NO_WINDOW", 0) if sys.platform == "win32" else 0
extra = {"preexec_fn": lift_the_core_limit} if core_dumps and sys.platform.startswith("linux") else {}
sinks = [subprocess.DEVNULL, subprocess.DEVNULL]
opened = []
if output_to is not None:
@@ -131,7 +129,7 @@ def _run_to_the_end(argv, env, cwd, timeout_s, *, output_to=None, core_dumps=Fal
opened.append(open(str(output_to) + suffix, "wb"))
sinks[index] = opened[-1]
try:
proc = subprocess.Popen(argv, stdin=subprocess.DEVNULL, stdout=sinks[0], stderr=sinks[1], env=env, cwd=str(cwd), creationflags=flags, **extra)
proc = subprocess.Popen(argv, stdin=subprocess.DEVNULL, stdout=sinks[0], stderr=sinks[1], env=env, cwd=str(cwd), creationflags=flags)
try:
try:
return proc.wait(timeout=timeout_s), None
@@ -274,10 +272,9 @@ def test_the_engine_generates_the_security_state_it_is_given(ff, inputs, tmp_pat
profile.mkdir()
(profile / "user.js").write_bytes(_user_js(files))
output = work / "engine-output"
started_at = time.time()
code, why = _run_to_the_end([ff, "-headless", "-no-remote", "-profile", str(profile)], _engine_env(work), work, GENERATE_TIMEOUT_S, output_to=output, core_dumps=True)
code, why = _run_to_the_end([ff, "-headless", "-no-remote", "-profile", str(profile)], _engine_env(work), work, GENERATE_TIMEOUT_S, output_to=output)
if code != 0: # TEMPORARY, with tests/_generation_evidence.py
save_what_the_failed_generation_left(ff, profile, output, started_at, code, why, evidence_folder("security-state-generate", work), cwd=work)
save_what_the_failed_generation_left(profile, output, code, why, evidence_folder("security-state-generate", work))
said = (profile / RESULT_NAME).read_bytes().decode("utf-8") if (profile / RESULT_NAME).is_file() else "no %s" % RESULT_NAME
assert code == 0, "the engine in generate mode %s (exit code %r); its result: %s" % (why or "exited", code, said)
@@ -0,0 +1,148 @@
"""TEMPORARY, with tests/_crash_cores.py: after a test that fails, gdb's text of every core in `$INVPW_CORE_DIR` is in the evidence and the core is gone.
The exit by SIGSEGV (-11) of the engine in generate mode (runs 44985244053 and 45014369018) left no core: a release build crashes in silence, and only a core tells a
wanted crash (`gMozCrashReason`) from a bad access. tests/conftest.py lifts the core limit of the session on Linux and calls `_crash_cores.after_the_report` from
`pytest_runtest_makereport` after each phase of every test. Here the hook itself runs, with a fake core file and a fake gdb (a script of this Python that logs how
it was called and answers like gdb), so it is proved on every system, no browser:
* a phase that fails: the conftest hook hands the report back unchanged, gdb is given the executable the core's header names, the core and every command the
diagnosis needs (all the threads' backtraces and names, the signal's address, `gMozCrashReason`, the shared libraries), its text is saved under
`cores/<test>/` with notes, and the core is deleted;
* when the header names no file, the executable is `$INVPW_BINARY_PATH`;
* a core left after a test that passed is deleted and listed in `cores/after-passing-tests.txt`, and gdb is not run; a core found at the teardown of a test that
failed in its call is read like one found at the failure;
* the controls: without `$INVPW_CORE_DIR` nothing is written and the core is left; a failure with no core says so; on Linux the session's soft core limit is the
hard one, elsewhere lifting it is a no-op that does not raise.
"""
from __future__ import annotations
import json
import os
import sys
from pathlib import Path
from types import SimpleNamespace
import pytest
import _crash_cores
pytestmark = pytest.mark.unit
NODEID = "tests/test_some_engine_e2e.py::test_it[in-process]"
CORE = "core.Socket Thread.4242"
_FAKE_GDB = r'''
import json, os, sys
with open(os.environ["FAKE_GDB_LOG"], "a") as log:
log.write(json.dumps(sys.argv[1:]) + "\n")
sys.stdout.write("Core was generated by `%s -contentproc 7 socket'.\n" % os.environ["FAKE_GDB_NAMES"])
sys.stdout.write("Program terminated with signal SIGSEGV, Segmentation fault.\n")
if "-ex" in sys.argv:
sys.stdout.write("#0 0x00007f0000001234 in FakeCrash () from /fake/libxul.so\n")
'''
@pytest.fixture
def fake(tmp_path, monkeypatch):
"""A core folder with one fake core, the evidence under `tmp_path/runner`, a fake gdb in place of gdb, an engine file the header names."""
cores = tmp_path / "cores-dir"
cores.mkdir()
(cores / CORE).write_bytes(b"\x7fELF fake core")
engine = tmp_path / "engine" / "firefox"
engine.parent.mkdir()
engine.write_bytes(b"fake engine")
script = tmp_path / "fake_gdb.py"
script.write_text(_FAKE_GDB, encoding="utf-8")
log = tmp_path / "gdb-calls.jsonl"
monkeypatch.setenv("RUNNER_TEMP", str(tmp_path / "runner"))
monkeypatch.setenv("INVPW_CORE_DIR", str(cores))
monkeypatch.setenv("FAKE_GDB_LOG", str(log))
monkeypatch.setenv("FAKE_GDB_NAMES", str(engine))
monkeypatch.delenv("INVPW_BINARY_PATH", raising=False)
monkeypatch.delenv("STEALTHFOX_E2E_BINARY", raising=False)
monkeypatch.setattr(_crash_cores, "gdb", lambda: [sys.executable, "-I", str(script)])
monkeypatch.setattr(_crash_cores, "_FAILED", set())
evidence = tmp_path / "runner" / "invpw-evidence" / "cores"
return SimpleNamespace(cores=cores, core=cores / CORE, engine=engine, log=log, evidence=evidence, folder=evidence / _crash_cores.folder_name(NODEID))
def _calls(fake):
return [json.loads(line) for line in fake.log.read_text(encoding="utf-8").splitlines()] if fake.log.is_file() else []
def _the_conftest_hook(request):
for plugin in request.config.pluginmanager.get_plugins():
if Path(getattr(plugin, "__file__", "") or "").name == "conftest.py" and hasattr(plugin, "pytest_runtest_makereport"):
return plugin.pytest_runtest_makereport
raise AssertionError("no conftest.py has a pytest_runtest_makereport hook")
def _through_the_hook(hook, when, failed):
"""Drives the conftest wrapper as pluggy does: the report goes in at its yield and must come out unchanged."""
report = SimpleNamespace(when=when, failed=failed)
run = hook(item=SimpleNamespace(nodeid=NODEID), call=None)
next(run)
with pytest.raises(StopIteration) as stop:
run.send(report)
assert stop.value.value is report, "the hook did not hand the report back"
def test_a_failed_phase_has_its_core_read_by_gdb_through_the_conftest_hook_and_deleted(fake, request):
hook = _the_conftest_hook(request)
_through_the_hook(hook, "setup", False)
assert fake.core.is_file() and not _calls(fake), "a phase that passed read or deleted the core"
_through_the_hook(hook, "call", True)
calls = _calls(fake)
assert len(calls) == 2, calls # the header, then the full read
full = calls[-1]
commands = [full[index + 1] for index, part in enumerate(full) if part == "-ex"]
for needed in ("thread apply all bt", "info threads", "p $_siginfo._sifields._sigfault.si_addr", "x/s *(char**)&gMozCrashReason", "info sharedlibrary"):
assert needed in commands, (needed, commands)
assert full[-3:] == [str(fake.engine), "-c", str(fake.core)], full
text = (fake.folder / (CORE + ".gdb.txt")).read_text(encoding="utf-8")
assert "#0 0x00007f0000001234 in FakeCrash ()" in text and "from the core's header" in text, text
notes = (fake.folder / "notes.txt").read_text(encoding="utf-8")
assert NODEID in notes and "phase call" in notes and "gdb exited 0" in notes, notes
assert not fake.core.exists(), "the core was not deleted after gdb read it"
_through_the_hook(hook, "teardown", False)
assert len(_calls(fake)) == 2 and not (fake.evidence / _crash_cores.AFTER_PASSING).exists()
def test_when_the_header_names_no_file_the_executable_is_the_binary_of_the_run(fake, monkeypatch):
monkeypatch.setenv("FAKE_GDB_NAMES", str(fake.engine.parent / "not-there"))
monkeypatch.setenv("INVPW_BINARY_PATH", str(fake.engine))
_crash_cores.after_the_report(NODEID, "call", True)
full = _calls(fake)[-1]
assert full[-3:] == [str(fake.engine), "-c", str(fake.core)], full
assert "from $INVPW_BINARY_PATH" in (fake.folder / (CORE + ".gdb.txt")).read_text(encoding="utf-8")
def test_a_core_left_by_a_test_that_passed_is_deleted_and_listed_and_one_at_the_teardown_of_a_failed_test_is_read(fake):
for when in ("setup", "call", "teardown"):
_crash_cores.after_the_report(NODEID, when, False)
assert not fake.core.exists() and not _calls(fake), "the core of a passing test was not deleted, or gdb read it"
listed = (fake.evidence / _crash_cores.AFTER_PASSING).read_text(encoding="utf-8")
assert listed.startswith(NODEID + "\t" + CORE + "\t"), listed
assert not fake.folder.exists()
_crash_cores.after_the_report(NODEID, "call", True) # no core yet: noted
assert "no core file" in (fake.folder / "notes.txt").read_text(encoding="utf-8")
fake.core.write_bytes(b"\x7fELF fake core") # the crash is found only at the teardown
_crash_cores.after_the_report(NODEID, "teardown", False)
assert (fake.folder / (CORE + ".gdb.txt")).is_file() and not fake.core.exists(), sorted(p.name for p in fake.folder.iterdir())
assert len(listed.splitlines()) == len((fake.evidence / _crash_cores.AFTER_PASSING).read_text(encoding="utf-8").splitlines())
def test_without_a_core_folder_nothing_is_done_and_the_session_s_limit_is_the_hard_one(fake, monkeypatch):
monkeypatch.delenv("INVPW_CORE_DIR")
_crash_cores.after_the_report(NODEID, "call", True)
_crash_cores.after_the_report(NODEID, "teardown", False)
assert fake.core.is_file() and not _calls(fake) and not fake.evidence.exists(), "something was done without $INVPW_CORE_DIR"
_crash_cores.lift_the_core_limit_of_the_session()
if sys.platform.startswith("linux"):
import resource
soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
assert soft == hard, "the session's core limit is (%r, %r)" % (soft, hard)
else: # Windows has no core limit and no core files: lifting is a no-op that does not raise
assert os.name == "nt", os.name