ci: the host oracle warms each engine up, compares the tree only, and the network oracle has jobs of its own
Host oracle - Each engine run starts with a discarded warm-up launch (the first seed), an experiment control and not an excuse: its trace is kept in the footprint and the report lists what only the warm-up did (WARMUP-ONLY, per kind and per path, with the process that did it), and which of those both engines have. The measured launches are compared as they are: a pingsender or a socket process that differs after the warm-up is red. - Only the tree of the launch is compared. On Windows the ancestry is the creator's pid chain of the 4688 events and every open of the machine is read, so what a process outside the tree opened (a service, the antivirus) is counted by process name (OUTSIDE THE TREE) and left out; on Linux the strace tree is the tree. - A path or a kind that differs names the processes to blame: touched_by (the kinds that opened each host path, on both systems, a thread's open counted for its process) and spawned_by (the kinds that spawned each kind), in the DIFF lines and the problems. e2e.yml - tests/test_ab_network_e2e.py has its own jobs, e2e (network, linux) and e2e (network, windows), with the setup of the shared jobs, one test that must pass (no skip), 40 minutes (the test's own budget for 5 seeds is 30); the shared Linux job ignores the file (OWN_JOB_FILES) and the Windows parts leave it out of the collection (own_job). The workflow tests take a job by its name now, and the network jobs are held to the same rules as the others.
This commit is contained in:
1 parent
88b058956a
commit
9072dbb74f
9 files changed
+586
-80
No files matched your search
+142
-2
@@ -168,10 +168,12 @@ jobs:
|
||||
ROOT_FILES: tests/test_a_proxy_that_cannot_carry_udp_leaks_nothing_direct_e2e.py
|
||||
ROOT_NODES: tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_before_the_tick
|
||||
SANDBOX_FILES: tests/test_the_socket_process_is_sandboxed_e2e.py
|
||||
# The network oracle's A/A has jobs of its own (e2e-network, e2e-network-windows below): five seeds of it do not fit in this job's 40 minutes.
|
||||
OWN_JOB_FILES: tests/test_ab_network_e2e.py
|
||||
# The root ones are left out by name and run in the step below, as root: here, as the runner user, they errored. The sandbox one is left out
|
||||
# by name too and runs in its own step after them: it is red on a runner whose AppArmor refuses user namespaces to a normal user.
|
||||
run: |
|
||||
IGNORE=(); for f in $ROOT_FILES $SANDBOX_FILES; do IGNORE+=("--ignore=$f"); done
|
||||
IGNORE=(); for f in $ROOT_FILES $SANDBOX_FILES $OWN_JOB_FILES; do IGNORE+=("--ignore=$f"); done
|
||||
DESELECT=(); for n in $ROOT_NODES; do DESELECT+=("--deselect=$n"); done
|
||||
xvfb-run -a python -u scripts/run_e2e.py "$FF" "${IGNORE[@]}" "${DESELECT[@]}"
|
||||
|
||||
@@ -409,7 +411,8 @@ jobs:
|
||||
rows = json.load(open("ci/required-suites.json", encoding="utf-8"))
|
||||
left_out = [t for r in rows if r.get("linux_only") for t in r["tests"]]
|
||||
files = [l.strip() for l in open(os.path.join(tmp, "e2e_files.txt")) if l.strip()]
|
||||
files = [f for f in files if f not in left_out]
|
||||
own_job = ["tests/test_ab_network_e2e.py"] # the network oracle's A/A: e2e-network-windows below
|
||||
files = [f for f in files if f not in left_out and f not in own_job]
|
||||
mine = [f for i, f in enumerate(files) if i % 4 == part - 1]
|
||||
nodes = [t for t in left_out if "::" in t and t.split("::")[0] in mine]
|
||||
open(os.path.join(tmp, "e2e_args.txt"), "w").write("\n".join(mine + ["--deselect=" + n for n in nodes]) + "\n")
|
||||
@@ -458,3 +461,140 @@ jobs:
|
||||
path: ${{ runner.temp }}/invpw-evidence
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
|
||||
# ``The network oracle``: the A/A of tests/test_ab_network_e2e.py (the P4 journey and the lab, the published engine against itself) on its own job, Linux and Windows,
|
||||
# as its gate leg runs it. On a pull request that changes the oracle it visits all five seeds of the candidate set (scripts/ci_ab_pr_seeds.py), 30 minutes at most
|
||||
# for the run (the test's own budget: 120 s to start and, for each of the two engine runs, 240 s for the first seed and 150 s for each next one; about 15 minutes on
|
||||
# Linux and 19 on Windows expected), which would not fit in the shared job's 40 minutes next to everything else. The shared jobs leave this file out (OWN_JOB_FILES
|
||||
# above, `own_job` in the Windows parts). The same setup as the shared jobs: the security state, the engine, the GeoIP database made by the repository.
|
||||
e2e-network:
|
||||
name: e2e (network, linux)
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ".[dev]"
|
||||
python -m pip install "playwright==$(cat scripts/playwright_pin.txt)"
|
||||
- name: System deps (xvfb + Firefox runtime libs)
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y xvfb
|
||||
sudo "$(which python)" -m playwright install-deps firefox
|
||||
- name: The security state (a fixed directory of the repository)
|
||||
shell: bash
|
||||
run: python scripts/ci_lab_security_state.py set --pin ci/security-state.pin.json
|
||||
- name: Fetch the published firefox binary
|
||||
run: echo "FF=$(python -m invisible_playwright fetch | tail -1)" >> "$GITHUB_ENV"
|
||||
- name: The GeoIP database (made by the repository, same bytes every run)
|
||||
shell: bash
|
||||
run: python scripts/ci_lab_geoip.py build
|
||||
- name: Run the network oracle's A/A
|
||||
env:
|
||||
PYTHONUNBUFFERED: "1"
|
||||
run: |
|
||||
xvfb-run -a env -u PYTEST_ADDOPTS INVPW_BINARY_PATH="$FF" STEALTHFOX_E2E_BINARY="$FF" python -u -m pytest tests/test_ab_network_e2e.py -m e2e -o addopts= -o junit_family=xunit2 -p no:cacheprovider -p no:rerunfailures -rs -v --junitxml="$RUNNER_TEMP/network-e2e.xml"
|
||||
python - "$RUNNER_TEMP/network-e2e.xml" <<'PY'
|
||||
import sys, xml.etree.ElementTree as ET
|
||||
root = ET.parse(sys.argv[1]).getroot()
|
||||
suite = root if root.tag == "testsuite" else root.find("testsuite")
|
||||
counts = {k: int(suite.get(k, 0)) for k in ("tests", "failures", "errors", "skipped")}
|
||||
print(counts)
|
||||
sys.exit(0 if counts == {"tests": 1, "failures": 0, "errors": 0, "skipped": 0} else 1)
|
||||
PY
|
||||
- name: The leg ran with the pinned GeoIP database
|
||||
if: always()
|
||||
shell: bash
|
||||
run: |
|
||||
python scripts/ci_lab_geoip.py evidence --out "$(dirname "$GEOIP_USED_OUT")/geoip-evidence.json" > /dev/null
|
||||
python scripts/ci_lab_geoip.py verify --evidence "$(dirname "$GEOIP_USED_OUT")/geoip-evidence.json" --used "$GEOIP_USED_OUT"
|
||||
- name: Upload what the test saved
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: invpw-evidence-network-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
path: |
|
||||
${{ runner.temp }}/invpw-evidence
|
||||
${{ runner.temp }}/network-e2e.xml
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
|
||||
e2e-network-windows:
|
||||
name: e2e (network, windows)
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 40
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ".[dev]"
|
||||
python -m pip install "playwright==$(cat scripts/playwright_pin.txt)"
|
||||
- name: The security state (a fixed directory of the repository)
|
||||
shell: bash
|
||||
run: python scripts/ci_lab_security_state.py set --pin ci/security-state.pin.json
|
||||
- name: Fetch the published firefox binary
|
||||
run: echo "FF=$(cd "$RUNNER_TEMP" && python -m invisible_playwright fetch | tail -1)" >> "$GITHUB_ENV"
|
||||
- name: The GeoIP database (made by the repository, same bytes every run)
|
||||
run: python scripts/ci_lab_geoip.py build
|
||||
- name: Run the network oracle's A/A
|
||||
env:
|
||||
PYTHONUNBUFFERED: "1"
|
||||
run: |
|
||||
INVPW_BINARY_PATH="$FF" STEALTHFOX_E2E_BINARY="$FF" python -u -m pytest tests/test_ab_network_e2e.py -m e2e -o addopts= -o junit_family=xunit2 -p no:cacheprovider -p no:rerunfailures -rs -v --junitxml="$RUNNER_TEMP/network-e2e.xml"
|
||||
python - "$RUNNER_TEMP/network-e2e.xml" <<'PY'
|
||||
import sys, xml.etree.ElementTree as ET
|
||||
root = ET.parse(sys.argv[1]).getroot()
|
||||
suite = root if root.tag == "testsuite" else root.find("testsuite")
|
||||
counts = {k: int(suite.get(k, 0)) for k in ("tests", "failures", "errors", "skipped")}
|
||||
print(counts)
|
||||
sys.exit(0 if counts == {"tests": 1, "failures": 0, "errors": 0, "skipped": 0} else 1)
|
||||
PY
|
||||
- name: The leg ran with the pinned GeoIP database
|
||||
if: always()
|
||||
run: |
|
||||
python scripts/ci_lab_geoip.py evidence --out "$(dirname "$GEOIP_USED_OUT")/geoip-evidence.json" > /dev/null
|
||||
python scripts/ci_lab_geoip.py verify --evidence "$(dirname "$GEOIP_USED_OUT")/geoip-evidence.json" --used "$GEOIP_USED_OUT"
|
||||
- name: Close every Firefox left
|
||||
if: always()
|
||||
shell: pwsh
|
||||
run: |
|
||||
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
|
||||
- name: Upload what the test saved
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: invpw-evidence-network-windows-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
path: |
|
||||
${{ runner.temp }}/invpw-evidence
|
||||
${{ runner.temp }}/network-e2e.xml
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
@@ -14,10 +14,10 @@
|
||||
{"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": 2421, "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_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_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_ab_host.py", "tests/test_ab_network.py", "tests/test_ab_oracle.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_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_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_persona_cover.py", "tests/test_pin.py", "tests/test_pin_dicts_are_valid.py", "tests/test_pinning_doc.py", "tests/test_pointer_serLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 2422, "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_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_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_ab_host.py", "tests/test_ab_network.py", "tests/test_ab_oracle.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_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_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_persona_cover.py", "tests/test_pin.py", "tests/test_pin_dicts_are_valid.py", "tests/test_pinning_doc.py", "tests/test_pointer_server.py", "tests/test_popup_adoptLine truncated
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 2443, "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_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_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_ab_host.py", "tests/test_ab_network.py", "tests/test_ab_oracle.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_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_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_persona_cover.py", "tests/test_pin.py", "tests/test_pin_dicts_are_valid.py", "tests/test_pinning_doc.py", "tests/test_pointer_serLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 2444, "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_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_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_ab_host.py", "tests/test_ab_network.py", "tests/test_ab_oracle.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_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_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_persona_cover.py", "tests/test_pin.py", "tests/test_pin_dicts_are_valid.py", "tests/test_pinning_doc.py", "tests/test_pointer_server.py", "tests/test_popup_adoptLine 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.ab_oracle", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_oracle_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Same seed, same bytes: the engine published as firefox-68 against the candidate, on one machine, with the same core and wrapper, after the control: the published engine against ITSELF (the A/A; a difference is a broken control, exit 2, and the A/B is not run). On a pull request (no candidate: INVPW_BINARY_PATH is the published engine, no INVISIBLE_SEAL_FILE) the A/A is the whole test, on the first two seeds of the candidate set (all five when the pull request changes a file of this oracle: the step of e2e.yml that runs scripts/ci_ab_pr_seeds.py exports AB_ORACLE_PR_SEEDS), and saves both dumps and the diff under $AB_ORACLE_OUT or $RUNNER_TEMP/invpw-evidence/ab-oracle. scripts/ci_ab_oracle.py runs the host gate's dump (scripts/ci_host_gate.py dump: the persona seeds of ci/persona-seeds.json, each at its own DPR with nothing pinned, the whole page of scripts/host_gate; the `candidate` set of 5 seeds that reach every webgl renderer and every DPR, or with AB_ORACLE_SEED_SET=final and AB_ORACLE_SHARD=i/n the 20 seeds that reach every value of every dimension split over n jobs) twice, once with the firefox-68 binary (the release's seal.json, then the core's own download.ensure_binary under that seal: the archive's sha256 is checked against the seal) and once with the candidate binary of the leg under its own seal, and compares every leaf of every visit: the only differences allowed are the `noise` entries of scripts/host_gate/exceptions.json and the diag. keys; anything else is red with the leaf, the two values and the seed; fewer leaves than the host gate's reference holds (16439 per visit; a DPR the reference does not record is held to the least of those it does) is red. The files (dump-68.json, dump-68-again.json, diff-a-a.json and, with a candidate, dump-candidate.json and diff.json) are the artifact ab-oracle-<os> of the leg. 1 = the one test; the comparator's own cases (51, the A/A's among them) are in tests/test_ab_oracle.py, the persona seeds' (15) in tests/test_persona_cover.py, in the rows of the whole unit suite. Needs the engine's binary (INVPW_BINARY_PATH) and, for the A/B, the candidate's seal (INVISIBLE_SEAL_FILE) and the network (the release assets of firefox-68). The engine of the candidate must accept the core of the leg and the 68 engine must accept it too: a core that declares something the published engine refuses is a red of this suite, not of the engine."},
|
||||
{"id": "wrapper.e2e.ab_network", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_network_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Network A/B oracle: the P4 journey, HTTPS h1/h2 (ClientHello, h2 frames, header order), HTTP/3 (transport parameters, H3 SETTINGS), WebRTC through the coherent SOCKS5 lab gateway, DNS through the fake DoH, and an idle launch; transcripts compared leaf by leaf, direct connections red on either side. A/A first (the published engine twice: a difference is a broken control; ci/ab-network-volatile.json holds the leaves the A/A proved volatile, and may only shrink), then the published engine against the candidate. Without a candidate (a PR's e2e) the A/A alone, on the first seed (all five when the pull request changes a file of this oracle: AB_NETWORK_PR_SEEDS)."},
|
||||
{"id": "wrapper.e2e.ab_host", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_host_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Host A/B oracle: the whole TRACE of a closed run, from the launch to the exit of the browser, after the same journey. Compared: the processes by kind (the parent, -contentproc type, sandboxingKind, isForBrowser, the helpers by what they ran) with their count, except for the kinds of type tab whose count follows the idle time (only their presence counts), and the SET of host paths the tree touched, identical with no exception; what is ours (the package, the profile and temp dirs of the launch, the run cache, its own shared memory) leaves the comparison as a class. Linux: strace of the whole tree. Windows: the process-creation audit (event 4688, with the command line) and an ETW file trace of Kernel-File, which need an administrator. A/A first, then the published engine against the candidate; the one declared difference (Linux glxtest, gone on the 69) is in ci/ab-host-expected.json, applied by kind, a list that may only shrink. There is no list of noise. Without a candidate (a PR e2e) the A/A alone, on the first two seeds (all five when the pull request changes a file of this oracle: AB_HOST_PR_SEEDS)."}
|
||||
{"id": "wrapper.e2e.ab_network", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_network_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Network A/B oracle: the P4 journey, HTTPS h1/h2 (ClientHello, h2 frames, header order), HTTP/3 (transport parameters, H3 SETTINGS), WebRTC through the coherent SOCKS5 lab gateway, DNS through the fake DoH, and an idle launch; transcripts compared leaf by leaf, direct connections red on either side. A/A first (the published engine twice: a difference is a broken control; ci/ab-network-volatile.json holds the leaves the A/A proved volatile, and may only shrink), then the published engine against the candidate. Without a candidate (a PR's e2e) the A/A alone, on the first seed (all five when the pull request changes a file of this oracle: AB_NETWORK_PR_SEEDS), in jobs of its own in e2e.yml on Linux and on Windows (the shared e2e jobs leave this file out)."},
|
||||
{"id": "wrapper.e2e.ab_host", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_host_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Host A/B oracle: the whole TRACE of a closed run, from the launch to the exit of the browser, after the same journey. Compared: the processes by kind (the parent, -contentproc type, sandboxingKind, isForBrowser, the helpers by what they ran) with their count, except for the kinds of type tab whose count follows the idle time (only their presence counts), and the SET of host paths the tree touched, identical with no exception; what is ours (the package, the profile and temp dirs of the launch, the run cache, its own shared memory) leaves the comparison as a class. Linux: strace of the whole tree. Windows: the process-creation audit (event 4688, with the command line) and an ETW file trace of Kernel-File, which need an administrator. Each engine run starts with a discarded warm-up launch whose trace is kept and listed apart (what only the warm-up did, with the process that did it); only the tree of the launch is compared (a Windows service's paths are counted by process name and left out), and a path or a kind that differs names the processes to blame. A/A first, then the published engine against the candidate; the one declared difference (Linux glxtest, gone on the 69) is in ci/ab-host-expected.json, applied by kind, a list that may only shrink. There is no list of noise. Without a candidate (a PR e2e) the A/A alone, on the first two seeds (all five when the pull request changes a file of this oracle: AB_HOST_PR_SEEDS)."}
|
||||
]
|
||||
+204
-47
@@ -15,6 +15,15 @@ Two things are compared, over the whole trace:
|
||||
* the files: every path the tree touched (opened, stat'ed, accessed, read as a link, executed), classified `ours` or `host`. The SET of host
|
||||
paths must be identical, no exception. `ours` leaves the comparison as a class (OURS below: reading its own package is not touching the host).
|
||||
|
||||
The trace is of the TREE of the launch only: what a process outside it does (on Windows a service, the antivirus) is not the engine's, so it is left out of
|
||||
the comparison and the report says how many paths each outside process name touched (`OUTSIDE THE TREE`). A path or a kind that differs names the processes
|
||||
to blame (`by A: ... | B: ...`: who touched the path, who spawned the kind).
|
||||
|
||||
Each engine run starts with a discarded WARM-UP launch (the first seed), an experiment control and not an excuse: its trace is kept in the footprint and the
|
||||
report lists what only the warm-up did (`WARMUP-ONLY`, per kind and per path, with the process that did it), so that a first-launch-only behaviour (a
|
||||
helper spawned at the first shutdown of a cold machine) stays visible from run to run. The measured launches are compared as they are: a kind or a count that differs
|
||||
after the warm-up is red.
|
||||
|
||||
How the trace is taken:
|
||||
|
||||
* Linux: `strace -f -y` of the whole tree (the stand-in of tests/_strace_stand_in.py), calls execve, clone, fork, prctl and the file calls
|
||||
@@ -282,11 +291,8 @@ def _unescape(text: str) -> str:
|
||||
return codecs.escape_decode(text.encode("latin-1", errors="replace"))[0].decode("utf-8", errors="replace")
|
||||
|
||||
|
||||
def touched_paths(lines) -> set:
|
||||
"""Every path a strace log (read as lines) says a process of the tree touched, failed attempts included: opening, stat, access, readlink,
|
||||
execve. A path relative to a directory descriptor is joined to the path `-y` printed for it, one relative to the working directory is
|
||||
spelled `<cwd>/...`, an empty path (the descriptor itself) is not a path."""
|
||||
found = set()
|
||||
def _path_calls(lines):
|
||||
"""(pid, base, raw path) of every call of a strace log that names a path: `base` is what a relative path is relative to."""
|
||||
for line in lines:
|
||||
m = _LINE.match(line)
|
||||
if not m:
|
||||
@@ -302,14 +308,65 @@ def touched_paths(lines) -> set:
|
||||
else:
|
||||
continue
|
||||
if raw:
|
||||
found.add((base, raw))
|
||||
out = set()
|
||||
for base, raw in found:
|
||||
path = _unescape(raw)
|
||||
out.add(path if path.startswith("/") else _unescape(base).rstrip("/") + "/" + path)
|
||||
yield int(m.group(1)), base, raw
|
||||
|
||||
|
||||
def _joined(base: str, raw: str) -> str:
|
||||
path = _unescape(raw)
|
||||
return path if path.startswith("/") else _unescape(base).rstrip("/") + "/" + path
|
||||
|
||||
|
||||
def touched_paths(lines) -> set:
|
||||
"""Every path a strace log (read as lines) says a process of the tree touched, failed attempts included: opening, stat, access, readlink,
|
||||
execve. A path relative to a directory descriptor is joined to the path `-y` printed for it, one relative to the working directory is
|
||||
spelled `<cwd>/...`, an empty path (the descriptor itself) is not a path."""
|
||||
return {_joined(base, raw) for _pid, base, raw in _path_calls(lines)}
|
||||
|
||||
|
||||
def touched_by_pid(lines) -> dict:
|
||||
"""{path: {pids that touched it}} of a strace log: `touched_paths` with the process (or thread) that did it."""
|
||||
out: dict = {}
|
||||
for pid, base, raw in set(_path_calls(lines)):
|
||||
out.setdefault(_joined(base, raw), set()).add(pid)
|
||||
return out
|
||||
|
||||
|
||||
def thread_owners(lines) -> dict:
|
||||
"""{tid: pid of the process it belongs to} from the clones with CLONE_THREAD of a strace log (a thread's calls are logged under its tid)."""
|
||||
owners: dict = {}
|
||||
pending: dict = {}
|
||||
for line in lines:
|
||||
m = _LINE.match(line)
|
||||
if m:
|
||||
pid, call, rest = int(m.group(1)), m.group(2), m.group(3)
|
||||
if call in ("clone", "clone3"):
|
||||
flags = _FLAGS.search(rest)
|
||||
is_thread = bool(flags and "CLONE_THREAD" in flags.group(1)) or ("CLONE_THREAD" in rest)
|
||||
if "<unfinished ...>" in rest:
|
||||
pending[pid] = is_thread
|
||||
else:
|
||||
r = _RESULT.search(rest)
|
||||
if is_thread and r and int(r.group(1)) > 0:
|
||||
owners[int(r.group(1))] = pid
|
||||
continue
|
||||
m = _RESUMED.match(line)
|
||||
if m and m.group(2) in ("clone", "clone3"):
|
||||
pid = int(m.group(1))
|
||||
r = _RESULT.search(m.group(3))
|
||||
if pending.pop(pid, False) and r and int(r.group(1)) > 0:
|
||||
owners[int(r.group(1))] = pid
|
||||
return owners
|
||||
|
||||
|
||||
def owner_of(pid: int, owners: dict) -> int:
|
||||
"""The process a tid belongs to (itself when it is not a known thread)."""
|
||||
seen = set()
|
||||
while pid in owners and pid not in seen:
|
||||
seen.add(pid)
|
||||
pid = owners[pid]
|
||||
return pid
|
||||
|
||||
|
||||
def spawned_processes(lines, real: str) -> dict:
|
||||
"""{pid: {"parent", "exec", "name", "label"}} for every PROCESS (not thread) the traced tree made, from a strace log read as
|
||||
lines: a clone without CLONE_THREAD, a fork or a vfork is a process; the last execve says what it ran, else
|
||||
@@ -385,6 +442,25 @@ def spawned_processes(lines, real: str) -> dict:
|
||||
return procs
|
||||
|
||||
|
||||
def by_kind(pairs, label_of, ctx: Context) -> dict:
|
||||
"""{host path: sorted kinds of the processes that touched it} of `(pid, raw path)` pairs, `label_of(pid)` naming the process. Evidence: the cause
|
||||
of a path that differs, or that is only in the warm-up."""
|
||||
out: dict = {}
|
||||
for pid, raw in pairs:
|
||||
got = classify(raw, ctx)
|
||||
if got and got[0] == "host":
|
||||
out.setdefault(got[1], set()).add(label_of(pid))
|
||||
return {path: sorted(kinds) for path, kinds in sorted(out.items())}
|
||||
|
||||
|
||||
def spawners(labels: dict, parents: dict) -> dict:
|
||||
"""{kind: sorted kinds of the processes that spawned it} from {pid: kind} and {pid: parent pid}: the process that is to blame for a kind."""
|
||||
out: dict = {}
|
||||
for pid, label in labels.items():
|
||||
out.setdefault(label, set()).add(labels.get(parents.get(pid), "(oracle)"))
|
||||
return {kind: sorted(v) for kind, v in sorted(out.items())}
|
||||
|
||||
|
||||
def spawned_counts(procs: dict) -> dict:
|
||||
"""{label: how many processes} of `spawned_processes`."""
|
||||
return dict(sorted(collections.Counter(p["label"] for p in procs.values()).items()))
|
||||
@@ -489,9 +565,9 @@ def windows_processes(tree, real: str) -> dict:
|
||||
return out
|
||||
|
||||
|
||||
def etw_files(path, pids) -> tuple:
|
||||
"""`({(pid, file name)}, events)` of the Create events a `tracerpt -of XML` file holds, for the processes in `pids`. Read as a stream: the file
|
||||
has every open of the machine for the length of the run."""
|
||||
def etw_files(path, pids=None) -> tuple:
|
||||
"""`({(pid, file name)}, events)` of the Create events a `tracerpt -of XML` file holds, for the processes in `pids` (every process when None). Read as a
|
||||
stream: the file has every open of the machine for the length of the run."""
|
||||
seen, events = set(), 0
|
||||
for _ev, el in ET.iterparse(path, events=("end",)):
|
||||
if el.tag.rsplit("}", 1)[-1] != "Event":
|
||||
@@ -505,7 +581,7 @@ def etw_files(path, pids) -> tuple:
|
||||
pid = _number(raw) if raw else None
|
||||
elif tag == "Data" and child.get("Name") == "FileName":
|
||||
name = child.text
|
||||
if name and pid in pids:
|
||||
if name and pid is not None and (pids is None or pid in pids):
|
||||
seen.add((pid, name))
|
||||
el.clear()
|
||||
return seen, events
|
||||
@@ -544,6 +620,7 @@ class WindowsTrace:
|
||||
self.first_record = 0
|
||||
self.before = None
|
||||
self.session = False
|
||||
self.images: dict = {}
|
||||
|
||||
def _canary(self, which: str) -> str:
|
||||
"""A file of the oracle's own, written and read now: the session must have a Create event of it."""
|
||||
@@ -579,22 +656,39 @@ class WindowsTrace:
|
||||
|
||||
def tree(self, roots) -> list:
|
||||
xml = _tool(["wevtutil", "qe", "Security", "/q:*[System[(EventID=4688) and (EventRecordID>%d)]]" % self.first_record, "/f:xml"])
|
||||
return process_tree(parse_audit_events(xml), roots)
|
||||
events = parse_audit_events(xml)
|
||||
self.images = {e["pid"]: _base(e["image"]).lower() for e in events}
|
||||
return process_tree(events, roots)
|
||||
|
||||
def finish(self, roots, alive=None, sleep=time.sleep, now=time.monotonic) -> dict:
|
||||
"""`{"tree": [4688 events], "files": {(pid, name)}, "exited": {...}, "events": n}`: what the tree did from its first process to its last."""
|
||||
def finish(self, roots, alive=None, sleep=time.sleep, now=time.monotonic, namer=None) -> dict:
|
||||
"""`{"tree": [4688 events], "files": {(pid, name)}, "outside": {process name: paths}, "exited": {...}, "events": n}`: what the TREE did from its
|
||||
first process to its last (the ancestry by the creator's pid from the launched process). What a process outside the tree opened (a service, the
|
||||
antivirus, the oracle itself apart) is not the engine's: it is counted by process name and left out of the comparison."""
|
||||
if alive is None:
|
||||
import psutil
|
||||
|
||||
alive = psutil.pid_exists
|
||||
if namer is None:
|
||||
def namer(pid):
|
||||
try:
|
||||
import psutil
|
||||
|
||||
return psutil.Process(pid).name().lower()
|
||||
except Exception: # noqa: BLE001 - a process that is gone has no name
|
||||
return "pid %d" % pid
|
||||
tree, exited = wait_exited(lambda: self.tree(roots), alive, sleep=sleep, now=now)
|
||||
end_canary = self._canary("end")
|
||||
_tool(["logman", "stop", self.name, "-ets"])
|
||||
self.session = False
|
||||
summary = self.work / "files.txt"
|
||||
_tool(["tracerpt", str(self.etl), "-of", "XML", "-o", str(self.xml), "-summary", str(summary), "-y"])
|
||||
pids = {e["pid"] for e in tree} | {os.getpid()}
|
||||
seen, events = etw_files(self.xml, pids)
|
||||
everything, events = etw_files(self.xml)
|
||||
tree_pids = {e["pid"] for e in tree}
|
||||
seen = {(p, n) for p, n in everything if p in tree_pids or p == os.getpid()}
|
||||
outside: dict = {}
|
||||
for p, n in everything:
|
||||
if p not in tree_pids and p != os.getpid():
|
||||
outside.setdefault(self.images.get(p) or namer(p), set()).add(n)
|
||||
problems = []
|
||||
mine = {name for pid, name in seen if pid == os.getpid()}
|
||||
for label, canary in (("last start", self._start_canary), ("end", end_canary)):
|
||||
@@ -603,11 +697,11 @@ class WindowsTrace:
|
||||
lost = re.search(r"(?i)events?\s+lost\D{0,20}(\d+)", summary.read_text(encoding="utf-8", errors="replace") if summary.exists() else "")
|
||||
if lost and int(lost.group(1)):
|
||||
problems.append("the file trace lost %s events" % lost.group(1))
|
||||
tree_pids = {e["pid"] for e in tree}
|
||||
missing = sorted(tree_pids - {pid for pid, _n in seen})
|
||||
if missing:
|
||||
problems.append("the file trace holds no open of the process(es) %s" % ", ".join(str(p) for p in missing[:10]))
|
||||
return {"tree": tree, "files": {(p, n) for p, n in seen if p in tree_pids}, "exited": exited, "events": events, "problems": problems}
|
||||
return {"tree": tree, "files": {(p, n) for p, n in seen if p in tree_pids}, "outside": {k: len(v) for k, v in sorted(outside.items())},
|
||||
"exited": exited, "events": events, "problems": problems}
|
||||
|
||||
def cleanup(self) -> None:
|
||||
"""Put the machine back: the session closed, the audit as it was."""
|
||||
@@ -723,6 +817,37 @@ def _declared_covers(entry: dict, diff: dict) -> bool:
|
||||
return (published != MISSING and published >= 1) and candidate == MISSING
|
||||
|
||||
|
||||
def warmup_only(fp: dict) -> dict | None:
|
||||
"""What the discarded warm-up launch of an engine did that its measured launch of the same seed did not (a first-launch-only behaviour, which stays
|
||||
visible run to run): the kinds that are in the warm-up and not in the measured launch, or more of them (not for the tab kinds, whose count
|
||||
is the idle time's), and the host paths only the warm-up touched, each with the process that did it. None for a footprint with no warm-up."""
|
||||
w = fp.get("warmup")
|
||||
if not w:
|
||||
return None
|
||||
m = next((s for s in fp.get("seeds", []) if s["seed"] == w["seed"]), None)
|
||||
if m is None:
|
||||
return {"seed": w["seed"], "kinds": [], "files": [], "measured": False}
|
||||
kinds = []
|
||||
for kind, n in sorted(w.get("kinds", {}).items()):
|
||||
measured = m.get("kinds", {}).get(kind, 0)
|
||||
if measured == 0 or (n > measured and not is_tab(kind)):
|
||||
kinds.append({"kind": kind, "warmup": n, "measured": measured, "spawned_by": w.get("spawned_by", {}).get(kind, [])})
|
||||
measured_files = set(m.get("files", []))
|
||||
files = [{"path": path, "touched_by": w.get("touched_by", {}).get(path, [])} for path in w.get("files", []) if path not in measured_files]
|
||||
return {"seed": w["seed"], "kinds": kinds, "files": files, "measured": True}
|
||||
|
||||
|
||||
def _by_text(d: dict) -> str:
|
||||
by = d.get("by") or {}
|
||||
return " (by A: %s | B: %s)" % (", ".join(by.get("A", [])) or "-", ", ".join(by.get("B", [])) or "-") if by.get("A") or by.get("B") else ""
|
||||
|
||||
|
||||
def _by(seed_footprint: dict, leaf: str) -> list:
|
||||
"""The processes to blame for a leaf in a seed's footprint: who touched a path, who spawned a kind."""
|
||||
category, _dot, name = leaf.partition(".")
|
||||
return list(seed_footprint.get("touched_by" if category == "file" else "spawned_by", {}).get(name, []))
|
||||
|
||||
|
||||
def judge(a: dict, b: dict, expected: list | None = None, a_a: bool = False, platform: str | None = None,
|
||||
floors: dict | None = None) -> dict:
|
||||
"""The verdict on two footprints (the document `run` writes). `expected` is the declared differences, applied only when `a_a` is false.
|
||||
@@ -756,7 +881,8 @@ def judge(a: dict, b: dict, expected: list | None = None, a_a: bool = False, pla
|
||||
for leaf in sorted(set(la) | set(lb)):
|
||||
va, vb = la.get(leaf, MISSING), lb.get(leaf, MISSING)
|
||||
if va != vb:
|
||||
differences.append({"seed": seed, "category": category_of(leaf), "leaf": leaf, "a": _clip(va), "b": _clip(vb)})
|
||||
differences.append({"seed": seed, "category": category_of(leaf), "leaf": leaf, "a": _clip(va), "b": _clip(vb),
|
||||
"by": {"A": _by(seeds_a[seed], leaf), "B": _by(seeds_b[seed], leaf)}})
|
||||
stale = []
|
||||
if not a_a:
|
||||
for entry in expected or []:
|
||||
@@ -771,22 +897,40 @@ def judge(a: dict, b: dict, expected: list | None = None, a_a: bool = False, pla
|
||||
differences.remove(d)
|
||||
declared.append(dict(d, id=entry.get("id")))
|
||||
for d in differences:
|
||||
problems.append("seed %s %s: A %s | B %s" % (d["seed"], d["leaf"], json.dumps(d["a"], sort_keys=True)[:160],
|
||||
json.dumps(d["b"], sort_keys=True)[:160]))
|
||||
problems.append("seed %s %s: A %s | B %s%s" % (d["seed"], d["leaf"], json.dumps(d["a"], sort_keys=True)[:160],
|
||||
json.dumps(d["b"], sort_keys=True)[:160], _by_text(d)))
|
||||
tab = {str(seed): {"A": {k: n for k, n in seeds_a[seed].get("kinds", {}).items() if is_tab(k)},
|
||||
"B": {k: n for k, n in seeds_b[seed].get("kinds", {}).items() if is_tab(k)}}
|
||||
for seed in sorted(set(seeds_a) & set(seeds_b))}
|
||||
outside = {side: {str(seed): seeds[seed]["outside_tree"] for seed in sorted(seeds) if seeds[seed].get("outside_tree")}
|
||||
for side, seeds in (("A", seeds_a), ("B", seeds_b))}
|
||||
warm = {"A": warmup_only(a), "B": warmup_only(b)}
|
||||
both = None
|
||||
if warm["A"] and warm["B"]:
|
||||
both = {"kinds": sorted({k["kind"] for k in warm["A"]["kinds"]} & {k["kind"] for k in warm["B"]["kinds"]}),
|
||||
"files": sorted({f["path"] for f in warm["A"]["files"]} & {f["path"] for f in warm["B"]["files"]})}
|
||||
return {"format": FORMAT, "mode": "a-a" if a_a else "a-b", "verdict": "red" if problems else "green", "problems": problems,
|
||||
"differences": differences, "declared": declared, "ours": OURS, "tab": {"reason": TAB_REASON, "counts": tab},
|
||||
"stale": [e.get("id") for e in stale], "leaves": counts}
|
||||
"outside_tree": outside, "warmup": dict(warm, both=both), "stale": [e.get("id") for e in stale], "leaves": counts}
|
||||
|
||||
|
||||
def print_report(report: dict, a_name: str, b_name: str) -> None:
|
||||
for seed, per in sorted(report["leaves"].items()):
|
||||
print("seed %s leaves: %s" % (seed, ", ".join("%s %d" % kv for kv in sorted(per.items()))))
|
||||
for d in report["differences"][:200]:
|
||||
print("DIFF seed %s %s: %s %s | %s %s" % (d["seed"], d["leaf"], a_name, json.dumps(d["a"], sort_keys=True)[:160],
|
||||
b_name, json.dumps(d["b"], sort_keys=True)[:160]))
|
||||
print("DIFF seed %s %s: %s %s | %s %s%s" % (d["seed"], d["leaf"], a_name, json.dumps(d["a"], sort_keys=True)[:160],
|
||||
b_name, json.dumps(d["b"], sort_keys=True)[:160], _by_text(d)))
|
||||
for side, name in (("A", a_name), ("B", b_name)):
|
||||
warm = (report.get("warmup") or {}).get(side)
|
||||
if warm:
|
||||
for k in warm["kinds"][:50]:
|
||||
print("WARMUP-ONLY %s seed %s proc.%s: warm-up %s, measured %s (spawned by: %s)" % (
|
||||
name, warm["seed"], k["kind"], k["warmup"], k["measured"], ", ".join(k["spawned_by"]) or "-"))
|
||||
for f in warm["files"][:100]:
|
||||
print("WARMUP-ONLY %s seed %s file.%s (touched by: %s)" % (name, warm["seed"], f["path"], ", ".join(f["touched_by"]) or "-"))
|
||||
for side, name in (("A", a_name), ("B", b_name)):
|
||||
for seed, names in sorted(((report.get("outside_tree") or {}).get(side) or {}).items()):
|
||||
print("OUTSIDE THE TREE (not compared) %s seed %s: %s" % (name, seed, ", ".join("%s %d paths" % kv for kv in sorted(names.items()))))
|
||||
for d in report["declared"]:
|
||||
print("DECLARED seed %s %s (%s)" % (d["seed"], d["leaf"], d["id"]))
|
||||
print("OURS (not compared): " + "; ".join("%s: %s" % kv for kv in sorted(report.get("ours", OURS).items())))
|
||||
@@ -824,15 +968,15 @@ def _context(binary: str, windows: bool, work: Path) -> Context:
|
||||
return Context("linux", app=app, temp=temp, cache={os.environ.get("XDG_CACHE_HOME", "")})
|
||||
|
||||
|
||||
def run_seed(binary: str, seed: int, work: Path) -> dict:
|
||||
"""One browser, one journey, one close, one trace. Returns the seed's footprint."""
|
||||
def run_seed(binary: str, seed: int, work: Path, name: str | None = None) -> dict:
|
||||
"""One browser, one journey, one close, one trace. Returns the seed's footprint; `name` is the folder of its work (the warm-up has one of its own)."""
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
from fakeweb import journey_site, profile_p4
|
||||
from invisible_playwright._juggler.remote import launch_server
|
||||
|
||||
windows = sys.platform == "win32"
|
||||
seed_work = work / ("seed%d" % seed)
|
||||
seed_work = work / (name or "seed%d" % seed)
|
||||
seed_work.mkdir(parents=True)
|
||||
exe, log, pidfile, pgid = binary, seed_work / "strace.log", seed_work / "stand-in.pid", None
|
||||
trace = None
|
||||
@@ -921,39 +1065,52 @@ def _seed_result(binary: str, seed: int, seed_work: Path, steps: list, log: Path
|
||||
if windows:
|
||||
got = trace.finish({root_pid})
|
||||
procs = windows_processes(got["tree"], real)
|
||||
raw = {name for _pid, name in got["files"]}
|
||||
pairs = list(got["files"])
|
||||
labels = {pid: p["label"] for pid, p in procs.items()}
|
||||
parents = {e["pid"]: e["ppid"] for e in got["tree"]}
|
||||
label_of = lambda pid: labels.get(pid, "?") # noqa: E731
|
||||
info = {"source": "etw+audit", "events": got["events"], "exited": got["exited"]["exited"], "reads": got["exited"]["reads"]}
|
||||
problems = list(got["problems"])
|
||||
if not got["exited"]["exited"]:
|
||||
problems.append("the tree did not exit within %d s of the close: the trace is cut short" % EXIT_LIMIT_S)
|
||||
detail = sorted(({"label": p["label"], "cmd": p["cmd"][:300]} for p in procs.values()), key=lambda d: (d["label"], d["cmd"]))
|
||||
by = collections.defaultdict(set)
|
||||
for pid, name in got["files"]:
|
||||
c = classify(name, ctx)
|
||||
if c and c[0] == "host" and pid in procs:
|
||||
by[c[1]].add(procs[pid]["label"])
|
||||
touched_by = {path: sorted(kinds) for path, kinds in sorted(by.items())}
|
||||
outside = got["outside"]
|
||||
else:
|
||||
touched_by = None
|
||||
procs = spawned_processes(_read_lines(log), real)
|
||||
raw = touched_paths(_read_lines(log))
|
||||
info, problems = {"source": "strace", "exited": True}, []
|
||||
lines = list(_read_lines(log))
|
||||
procs = spawned_processes(lines, real)
|
||||
owners = thread_owners(lines)
|
||||
by_pid = touched_by_pid(lines)
|
||||
pairs = [(pid, path) for path, pids in by_pid.items() for pid in pids]
|
||||
labels = {pid: p["label"] for pid, p in procs.items()}
|
||||
parents = {pid: owner_of(p["parent"], owners) for pid, p in procs.items() if p["parent"] is not None}
|
||||
label_of = lambda pid: labels.get(owner_of(pid, owners), "?") # noqa: E731
|
||||
info, problems, outside = {"source": "strace", "exited": True}, [], {} # strace follows our tree and nothing else
|
||||
detail = sorted(({"label": p["label"], "exec": (" ".join([os.path.basename(p["exec"][0])] + p["exec"][1][1:6]) if p["exec"] else None),
|
||||
"name": p["name"]} for p in procs.values()), key=lambda d: (d["label"], d["exec"] or ""))
|
||||
raw = {path for _pid, path in pairs}
|
||||
host, ours = classify_paths(raw, ctx)
|
||||
kinds = dict(sorted(collections.Counter(p["label"] for p in procs.values()).items()))
|
||||
info.update({"processes": len(procs), "paths": len(raw)})
|
||||
out = {"seed": seed, "steps": steps, "kinds": kinds, "files": host, "ours": ours, "trace": info, "problems": problems, "processes": detail}
|
||||
if touched_by is not None:
|
||||
out["touched_by"] = touched_by # evidence, not compared: which kinds of process opened each host path
|
||||
return out
|
||||
# touched_by and spawned_by are evidence, never compared: the process to blame for a path or a kind that differs
|
||||
return {"seed": seed, "steps": steps, "kinds": kinds, "files": host, "ours": ours, "trace": info, "problems": problems, "processes": detail,
|
||||
"touched_by": by_kind(pairs, label_of, ctx), "spawned_by": spawners(labels, parents), "outside_tree": outside}
|
||||
|
||||
|
||||
def run_engine(binary: str, leg: str, seeds: list, label: str) -> dict:
|
||||
"""The footprint document of one engine: every seed's journey, one browser at a time."""
|
||||
"""The footprint document of one engine. A discarded WARM-UP launch first, of the first seed, then every seed's journey, one browser at a time.
|
||||
|
||||
The warm-up is a control of the experiment and not an excuse: what a machine does the first time it runs an engine (its files scanned, its caches
|
||||
cold, a first-run behaviour of the engine) is in a launch that is not compared, whose trace is kept in the document (`warmup`) so that what it
|
||||
did and the measured launch did not stays visible, run to run (`warmup_only`). The order is the same in every run: the warm-up of an engine, then its
|
||||
measured launches; the runs of an A/A or an A/B follow one another."""
|
||||
work = Path(tempfile.mkdtemp(prefix="ab-host-"))
|
||||
problems, out_seeds = [], []
|
||||
try:
|
||||
warm = run_seed(binary, seeds[0], work, name="warmup")
|
||||
problems += ["warm-up: %s" % p for p in warm.get("problems", [])]
|
||||
problems += ["warm-up: seed %d: step %d (%s) failed: %s" % (seeds[0], st["n"], st["name"], st.get("error")) for st in warm["steps"] if not st["ok"]]
|
||||
print("warm-up (seed %d, discarded): %s; %d host paths" % (seeds[0], json.dumps(warm["kinds"], sort_keys=True), len(warm["files"])))
|
||||
sys.stdout.flush()
|
||||
for seed in seeds:
|
||||
fp = run_seed(binary, seed, work)
|
||||
out_seeds.append(fp)
|
||||
@@ -965,7 +1122,7 @@ def run_engine(binary: str, leg: str, seeds: list, label: str) -> dict:
|
||||
sys.stdout.flush()
|
||||
finally:
|
||||
shutil.rmtree(work, ignore_errors=True)
|
||||
return {"format": FORMAT, "engine": label, "leg": leg, "platform": sys.platform, "seeds": out_seeds, "problems": problems,
|
||||
return {"format": FORMAT, "engine": label, "leg": leg, "platform": sys.platform, "seeds": out_seeds, "warmup": warm, "problems": problems,
|
||||
"binary": os.path.basename(os.path.dirname(os.path.realpath(binary)))}
|
||||
|
||||
|
||||
|
||||
@@ -704,3 +704,173 @@ def test_the_session_is_recording_when_the_last_start_canary_is_in_the_trace_eve
|
||||
trace, _fake = a_windows_run(tmp_path, monkeypatch, TREE_FILES, canaries=("start1", "start2", "end"))
|
||||
problems = trace.finish({100}, alive=lambda pid: False, sleep=lambda s: None)["problems"]
|
||||
assert len(problems) == 1 and "last start canary" in problems[0]
|
||||
|
||||
|
||||
# -
|
||||
# The warm-up: a discarded launch of each engine before its measured ones, kept as evidence, never an excuse.
|
||||
|
||||
def with_warmup(fp, kinds=None, files=None, touched_by=None, spawned_by=None, seed=11):
|
||||
fp = copy.deepcopy(fp)
|
||||
fp["warmup"] = {"seed": seed, "steps": [], "problems": [], "kinds": dict(KINDS if kinds is None else kinds), "files": list(FILES if files is None else files),
|
||||
"touched_by": touched_by or {}, "spawned_by": spawned_by or {}}
|
||||
return fp
|
||||
|
||||
|
||||
def test_an_engine_run_makes_its_warm_up_launch_first_of_the_first_seed_and_then_its_measured_ones(tmp_path, monkeypatch):
|
||||
calls = []
|
||||
|
||||
def fake_run_seed(binary, seed, work, name=None):
|
||||
calls.append((seed, name))
|
||||
return seed_footprint(seed)
|
||||
|
||||
monkeypatch.setattr(host, "run_seed", fake_run_seed)
|
||||
monkeypatch.setattr(host.os.path, "realpath", lambda p: p)
|
||||
doc = host.run_engine("ff", "linux-x86_64", [11, 12], "firefox-68")
|
||||
assert calls == [(11, "warmup"), (11, None), (12, None)]
|
||||
assert doc["warmup"]["seed"] == 11 and [s["seed"] for s in doc["seeds"]] == [11, 12] and doc["problems"] == []
|
||||
|
||||
|
||||
def test_a_warm_up_that_failed_is_red_in_the_document_like_a_measured_launch(monkeypatch):
|
||||
def fake_run_seed(binary, seed, work, name=None):
|
||||
fp = seed_footprint(seed)
|
||||
if name == "warmup":
|
||||
fp["problems"] = ["the file trace did not see the end canary file of the oracle"]
|
||||
fp["steps"] = [{"n": 2, "name": "hover", "ok": False, "error": "timeout"}]
|
||||
return fp
|
||||
|
||||
monkeypatch.setattr(host, "run_seed", fake_run_seed)
|
||||
monkeypatch.setattr(host.os.path, "realpath", lambda p: p)
|
||||
doc = host.run_engine("ff", "linux-x86_64", [11], "firefox-68")
|
||||
assert doc["problems"] == ["warm-up: the file trace did not see the end canary file of the oracle", "warm-up: seed 11: step 2 (hover) failed: timeout"]
|
||||
report = judge(dict(footprint(), problems=doc["problems"]), footprint(), a_a=True)
|
||||
assert report["verdict"] == "red" and any("side A: warm-up: " in p for p in report["problems"])
|
||||
|
||||
|
||||
def test_the_runs_of_an_ab_follow_one_another_in_the_same_order_each_with_its_own_warm_up(tmp_path, monkeypatch):
|
||||
runs = []
|
||||
monkeypatch.setattr(host.oracle, "fetch_published", lambda tag, work: ("pub-binary", "pub-seal"))
|
||||
monkeypatch.setattr(host, "run_subprocess", lambda exe, seal, leg, out, label, seeds: runs.append((label, exe, list(seeds))) or 1)
|
||||
assert host.ab("cand-binary", Path("cand-seal"), "linux-x86_64", tmp_path / "o1", "firefox-68", [11, 12]) == 2
|
||||
assert [(r[0], r[1]) for r in runs] == [("firefox-68", "pub-binary"), ("firefox-68 again", "pub-binary"), ("candidate", "cand-binary")]
|
||||
runs.clear()
|
||||
assert host.ab(None, None, "linux-x86_64", tmp_path / "o2", "firefox-68", [11, 12]) == 2
|
||||
assert [(r[0], r[1]) for r in runs] == [("firefox-68", "pub-binary"), ("firefox-68 again", "pub-binary")], "the A/A: the published engine twice, in the same order"
|
||||
|
||||
|
||||
def test_what_only_the_warm_up_did_is_listed_with_the_process_that_did_it():
|
||||
kinds = dict(KINDS, **{"backgroundtask/pingsender": 3, "socket": 2})
|
||||
fp = with_warmup(footprint(kinds={**KINDS, "socket": 1}), kinds=kinds, files=FILES + ["/etc/machine-id", "/usr/lib/libx.so"],
|
||||
touched_by={"/etc/machine-id": ["backgroundtask/pingsender"], "/usr/lib/libx.so": ["parent", "tab/isForBrowser"]},
|
||||
spawned_by={"backgroundtask/pingsender": ["parent"], "socket": ["parent"]})
|
||||
listing = host.warmup_only(fp)
|
||||
assert [(k["kind"], k["warmup"], k["measured"], k["spawned_by"]) for k in listing["kinds"]] == [
|
||||
("backgroundtask/pingsender", 3, 0, ["parent"]), ("socket", 2, 1, ["parent"])]
|
||||
assert [(f["path"], f["touched_by"]) for f in listing["files"]] == [("/etc/machine-id", ["backgroundtask/pingsender"]), ("/usr/lib/libx.so", ["parent", "tab/isForBrowser"])]
|
||||
assert host.warmup_only(footprint()) is None, "a footprint with no warm-up lists nothing"
|
||||
|
||||
|
||||
def test_the_count_of_a_tab_kind_in_the_warm_up_is_not_a_first_launch_behaviour():
|
||||
fp = with_warmup(footprint(), kinds=dict(KINDS, **{"tab/isForBrowser": 9}))
|
||||
assert host.warmup_only(fp)["kinds"] == []
|
||||
|
||||
|
||||
def test_the_report_lists_what_is_only_in_the_warm_up_and_says_when_both_engines_have_it(capsys):
|
||||
kinds = dict(KINDS, **{"backgroundtask/pingsender": 3})
|
||||
spawned = {"backgroundtask/pingsender": ["parent"]}
|
||||
a = with_warmup(footprint(), kinds=kinds, spawned_by=spawned, files=FILES + ["/etc/machine-id"], touched_by={"/etc/machine-id": ["backgroundtask/pingsender"]})
|
||||
b = with_warmup(footprint("firefox-68 again"), kinds=kinds, spawned_by=spawned)
|
||||
report = judge(a, b, a_a=True)
|
||||
assert report["verdict"] == "green", "a first-launch-only behaviour that the measured launches do not have is written, not red"
|
||||
assert report["warmup"]["both"] == {"kinds": ["backgroundtask/pingsender"], "files": []}
|
||||
host.print_report(report, "firefox-68", "firefox-68 again")
|
||||
out = capsys.readouterr().out
|
||||
assert "WARMUP-ONLY firefox-68 seed 11 proc.backgroundtask/pingsender: warm-up 3, measured 0 (spawned by: parent)" in out
|
||||
assert "WARMUP-ONLY firefox-68 seed 11 file./etc/machine-id (touched by: backgroundtask/pingsender)" in out
|
||||
assert "WARMUP-ONLY firefox-68 again seed 11 proc.backgroundtask/pingsender" in out
|
||||
|
||||
|
||||
def test_a_pingsender_count_that_differs_after_the_warm_up_is_red_and_names_who_spawned_it():
|
||||
warm = dict(KINDS, **{"backgroundtask/pingsender": 3})
|
||||
a = with_warmup(footprint(kinds=dict(KINDS, **{"backgroundtask/pingsender": 3})), kinds=warm)
|
||||
b = with_warmup(footprint("firefox-68 again"), kinds=warm)
|
||||
for seed in a["seeds"]:
|
||||
seed["spawned_by"] = {"backgroundtask/pingsender": ["parent"]}
|
||||
report = judge(a, b, a_a=True)
|
||||
assert report["verdict"] == "red"
|
||||
assert {(d["leaf"], d["a"], d["b"]) for d in report["differences"]} == {("proc.backgroundtask/pingsender", 3, host.MISSING)}
|
||||
assert all(d["by"] == {"A": ["parent"], "B": []} for d in report["differences"])
|
||||
assert any("proc.backgroundtask/pingsender: A 3 | B \"<missing>\" (by A: parent | B: -)" in p for p in report["problems"])
|
||||
same = judge(a, with_warmup(footprint("again", kinds=dict(KINDS, **{"backgroundtask/pingsender": 3})), kinds=warm), a_a=True)
|
||||
assert same["verdict"] == "green"
|
||||
|
||||
|
||||
def test_a_path_that_differs_names_the_kinds_that_touched_it():
|
||||
a, b = footprint(files=FILES + ["/etc/machine-id"]), footprint("again")
|
||||
for seed in a["seeds"]:
|
||||
seed["touched_by"] = {"/etc/machine-id": ["gpu", "parent"]}
|
||||
report = judge(a, b, a_a=True)
|
||||
assert all(d["by"] == {"A": ["gpu", "parent"], "B": []} for d in report["differences"])
|
||||
assert any("file./etc/machine-id: A 1 | B \"<missing>\" (by A: gpu, parent | B: -)" in p for p in report["problems"])
|
||||
|
||||
|
||||
# -
|
||||
# The tree only: what a process outside the tree of the launch opens is not compared.
|
||||
|
||||
def test_a_path_a_service_opened_is_counted_by_process_name_and_left_out_and_the_trees_stays(tmp_path, monkeypatch):
|
||||
service = TREE_FILES + [(106, "C:\\ProgramData\\Microsoft\\Windows Defender\\Scans\\x.db"), (106, "C:\\Windows\\System32\\catroot2\\y"), (999, "C:\\Windows\\Prefetch\\z.pf")]
|
||||
trace, _fake = a_windows_run(tmp_path, monkeypatch, service)
|
||||
got = trace.finish({100}, alive=lambda pid: False, sleep=lambda s: None, namer=lambda pid: "sysmain.exe")
|
||||
assert got["outside"] == {"svchost.exe": 2, "sysmain.exe": 2}, "pid 106 is named by its audit event, the pid with no event by the machine (999 has the unrelated.dll and the .pf)"
|
||||
assert {pid for pid, _n in got["files"]} == {100, 101, 102, 103, 104, 107}
|
||||
assert not any("Defender" in n or "catroot2" in n for _p, n in got["files"])
|
||||
assert got["problems"] == []
|
||||
|
||||
|
||||
def test_a_process_that_the_tree_made_is_in_the_tree_whatever_it_is_called():
|
||||
tree = host.process_tree(host.parse_audit_events("\n".join(TREE)), {100})
|
||||
assert 101 in {e["pid"] for e in tree} and 106 not in {e["pid"] for e in tree} and 105 not in {e["pid"] for e in tree}
|
||||
|
||||
|
||||
def test_the_report_says_what_was_left_out_of_the_comparison(capsys):
|
||||
a, b = footprint(platform="win32"), footprint("again", platform="win32")
|
||||
a["seeds"][0]["outside_tree"] = {"svchost.exe": 12, "msmpeng.exe": 3}
|
||||
report = judge(a, b, a_a=True)
|
||||
assert report["verdict"] == "green" and report["outside_tree"] == {"A": {"11": {"svchost.exe": 12, "msmpeng.exe": 3}}, "B": {}}
|
||||
host.print_report(report, "firefox-68", "firefox-68 again")
|
||||
assert "OUTSIDE THE TREE (not compared) firefox-68 seed 11: msmpeng.exe 3 paths, svchost.exe 12 paths" in capsys.readouterr().out
|
||||
|
||||
|
||||
STRACE_THREADS = """\
|
||||
100 execve("/e/firefox/firefox", ["/e/firefox/firefox", "-contentproc", "forkserver"], 0x1) = 0
|
||||
100 clone3({flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM, exit_signal=0}, 88) = 150
|
||||
100 fork() = 200
|
||||
200 prctl(PR_SET_NAME, "Web Content") = 0
|
||||
200 clone(child_stack=0x7f, flags=CLONE_VM|CLONE_THREAD|CLONE_SIGHAND <unfinished ...>
|
||||
200 <... clone resumed>, child_tidptr=0x7f) = 250
|
||||
150 openat(AT_FDCWD, "/etc/a", O_RDONLY) = 3
|
||||
250 openat(AT_FDCWD, "/etc/b", O_RDONLY) = 3
|
||||
200 openat(AT_FDCWD, "/etc/b", O_RDONLY) = 3
|
||||
"""
|
||||
|
||||
|
||||
def test_on_linux_the_strace_tree_is_the_tree_and_a_threads_path_is_its_processs():
|
||||
lines = STRACE_THREADS.splitlines()
|
||||
owners = host.thread_owners(lines)
|
||||
assert owners == {150: 100, 250: 200}
|
||||
assert host.touched_by_pid(lines) == {"/e/firefox/firefox": {100}, "/etc/a": {150}, "/etc/b": {250, 200}}
|
||||
procs = host.spawned_processes(lines, REAL)
|
||||
labels = {pid: p["label"] for pid, p in procs.items()}
|
||||
assert labels == {100: "forkserver", 200: "Web Content"}
|
||||
assert host.by_kind([(pid, p) for p, pids in host.touched_by_pid(lines).items() for pid in pids], lambda pid: labels.get(host.owner_of(pid, owners), "?"),
|
||||
host.Context("linux")) == {"/e/firefox/firefox": ["forkserver"], "/etc/a": ["forkserver"], "/etc/b": ["Web Content"]}
|
||||
assert host.spawners(labels, {200: 100}) == {"Web Content": ["forkserver"], "forkserver": ["(oracle)"]}
|
||||
|
||||
|
||||
def test_a_closed_linux_run_keeps_the_kinds_that_touched_each_path_and_nothing_is_outside_its_tree(tmp_path, monkeypatch):
|
||||
log = tmp_path / "strace.log"
|
||||
log.write_text(LOG + '101 openat(AT_FDCWD, "/etc/machine-id", O_RDONLY) = 3\n104 stat("/etc/machine-id", {st_mode=S_IFREG}) = 0\n', encoding="utf-8")
|
||||
monkeypatch.setattr(host.os.path, "realpath", lambda p: p)
|
||||
monkeypatch.setattr(host, "_context", lambda binary, windows, work: host.Context("linux", app=["/e/firefox"], temp=["/tmp/ab-host-tmp-x"]))
|
||||
fp = host._seed_result(REAL, 11, tmp_path, [], log, None, None, False)
|
||||
assert fp["touched_by"]["/etc/machine-id"] == ["glxtest", "lsb_release"]
|
||||
assert fp["spawned_by"]["glxtest"] == ["parent"] and fp["outside_tree"] == {}
|
||||
@@ -8,6 +8,9 @@ counts), and the set of host paths the tree touched, whatever is `ours` (its pac
|
||||
Linux: strace of the whole tree. Windows: the process-creation audit (event 4688, with the command line) and an ETW file trace (Kernel-File), which need an administrator, as the
|
||||
hosted runners are. One browser at a time.
|
||||
|
||||
Each engine run starts with a discarded warm-up launch (the first seed): an experiment control whose trace is kept in the footprint and listed in the report (`WARMUP-ONLY`, with the
|
||||
process that did it), never an excuse. Only the tree of the launch is compared; what a process outside it opened on Windows is counted by process name and left out (`OUTSIDE THE TREE`).
|
||||
|
||||
Two modes, chosen by the environment as the gate chooses it:
|
||||
|
||||
* no candidate (the PR's e2e: INVPW_BINARY_PATH is the published engine, INVISIBLE_SEAL_FILE is not set): the A/A control, the engine twice, on the first two seeds of the
|
||||
|
||||
+35
-7
@@ -599,18 +599,46 @@ def test_the_script_prints_one_variable_per_oracle_with_unix_line_ends_for_the_e
|
||||
assert pr.main([]) == 2
|
||||
|
||||
|
||||
def test_the_e2e_workflow_runs_the_step_on_a_pull_request_in_the_linux_job_and_the_windows_parts_and_the_e2e_tests_read_its_variables():
|
||||
def _job(text, name):
|
||||
"""The text of one job of e2e.yml, from its header to the next one."""
|
||||
import re
|
||||
|
||||
start = text.index("\n %s:\n" % name)
|
||||
following = re.search(r"\n [A-Za-z0-9_-]+:[ ]*\n", text[start + 1:])
|
||||
return text[start:start + 1 + following.start()] if following else text[start:]
|
||||
|
||||
|
||||
def test_the_e2e_workflow_runs_the_step_on_a_pull_request_in_the_jobs_that_run_the_oracles_and_the_e2e_tests_read_its_variables():
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
text = (root / ".github" / "workflows" / "e2e.yml").read_text(encoding="utf-8")
|
||||
control_a, windows = text.index("\n e2e-windows-control-a:\n"), text.index("\n e2e-windows:\n")
|
||||
legs = {"linux": text[text.index("\n e2e:\n"):control_a], "control-a": text[control_a:windows], "windows": text[windows:]}
|
||||
legs = {name: _job(text, name) for name in ("e2e", "e2e-windows-control-a", "e2e-windows", "e2e-network", "e2e-network-windows")}
|
||||
step = (' - name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)\n'
|
||||
" if: github.event_name == 'pull_request'\n shell: bash\n env:\n BASE_SHA: ${{ github.event.pull_request.base.sha }}\n"
|
||||
' run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"\n')
|
||||
assert step in legs["linux"] and step in legs["windows"] and step not in legs["control-a"], "the legs that run the oracles' tests, and only those"
|
||||
for leg in ("linux", "windows"):
|
||||
assert legs[leg].index("actions/setup-python") < legs[leg].index(step) < legs[leg].index("Fetch the published firefox binary")
|
||||
assert text.count("run: python scripts/ci_ab_pr_seeds.py") == 2 and "uses:" not in step
|
||||
assert [name for name, body in legs.items() if step in body] == ["e2e", "e2e-windows", "e2e-network", "e2e-network-windows"], "the jobs that run the oracles' tests, and only those"
|
||||
for name in ("e2e", "e2e-windows", "e2e-network", "e2e-network-windows"):
|
||||
assert legs[name].index("actions/setup-python") < legs[name].index(step) < legs[name].index("Fetch the published firefox binary")
|
||||
assert text.count("run: python scripts/ci_ab_pr_seeds.py") == 4 and "uses:" not in step
|
||||
for variable, source in (("AB_ORACLE_PR_SEEDS", "test_ab_oracle_e2e.py"), ("AB_NETWORK_PR_SEEDS", "test_ab_network_e2e.py"), ("AB_HOST_PR_SEEDS", "test_ab_host_e2e.py")):
|
||||
assert 'pr_seed_count("%s"' % variable in (root / "tests" / source).read_text(encoding="utf-8")
|
||||
assert variable in pr.ORACLES
|
||||
|
||||
|
||||
def test_the_network_oracle_has_a_job_of_its_own_on_each_system_and_the_shared_jobs_leave_its_file_out():
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
text = (root / ".github" / "workflows" / "e2e.yml").read_text(encoding="utf-8")
|
||||
network = "tests/test_ab_network_e2e.py"
|
||||
linux, windows = _job(text, "e2e-network"), _job(text, "e2e-network-windows")
|
||||
assert "runs-on: ubuntu-24.04" in linux and "runs-on: windows-2022" in windows
|
||||
for body in (linux, windows):
|
||||
assert body.count(network) == 1 and "scripts/run_e2e.py" not in body and "timeout-minutes: 40" in body and "needs: core-on-index" in body
|
||||
assert " - name: Run the network oracle's A/A\n" in body and "skipped\": 0" in body, "the job refuses a skipped test: one test, passed"
|
||||
assert "xvfb-run -a" in linux
|
||||
shared_linux, shared_windows = _job(text, "e2e"), _job(text, "e2e-windows")
|
||||
assert "OWN_JOB_FILES: " + network in shared_linux and "$ROOT_FILES $SANDBOX_FILES $OWN_JOB_FILES" in shared_linux
|
||||
assert 'own_job = ["%s"]' % network in shared_windows and "f not in left_out and f not in own_job" in shared_windows
|
||||
assert network not in _job(text, "e2e-windows-control-a")
|
||||
# the budget of the test itself fits the job: 5 seeds, two engine runs, with its own setup
|
||||
import test_ab_network_e2e as network_e2e
|
||||
|
||||
assert network_e2e.budget_s(5, 2) == 1800 and network_e2e.budget_s(5, 2) + 10 * 60 <= 40 * 60
|
||||
@@ -5,6 +5,7 @@ the database (scripts/ci_lab_geoip.py: the same bytes every run, no download) BE
|
||||
gets and is left as it is. publish.yml is the release: it runs the three checks on the REAL database (scripts/ci_real_geoip_check.py) before it uploads, and
|
||||
nothing else touches it.
|
||||
"""
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -18,20 +19,25 @@ RUNS_PYTEST = {
|
||||
"tests.yml": " - name: Run pytest\n",
|
||||
"e2e.yml": " - name: Run the full e2e suite under a virtual display, without the root ones\n",
|
||||
"e2e.yml#windows": " - name: Run this part of the e2e\n",
|
||||
"e2e.yml#network": " - name: Run the network oracle's A/A\n",
|
||||
"e2e.yml#network-windows": " - name: Run the network oracle's A/A\n",
|
||||
}
|
||||
|
||||
|
||||
JOBS = {"e2e.yml": "e2e", "e2e.yml#windows": "e2e-windows", "e2e.yml#control-a": "e2e-windows-control-a", "e2e.yml#network": "e2e-network",
|
||||
"e2e.yml#network-windows": "e2e-network-windows"}
|
||||
|
||||
|
||||
def _scope(name):
|
||||
"""The text of one workflow, or of one leg of it: `e2e.yml` is its Linux job, `e2e.yml#windows` its Windows parts."""
|
||||
file, _, leg = name.partition("#")
|
||||
"""The text of one workflow, or of one job of e2e.yml (`e2e.yml` is its Linux job, `#windows` its Windows parts, `#control-a` the Windows job of the keyboard
|
||||
shortcut, `#network` and `#network-windows` the jobs of the network oracle): a job runs from its header to the next one."""
|
||||
file, _, _leg = name.partition("#")
|
||||
text = (WORKFLOWS / file).read_text(encoding="utf-8")
|
||||
if file != "e2e.yml":
|
||||
return text
|
||||
windows = text.index("\n e2e-windows:\n")
|
||||
if leg == "windows":
|
||||
return text[windows:]
|
||||
ends = [i for i in (text.find("\n e2e-windows-control-a:\n"), windows) if i >= 0]
|
||||
return text[:min(ends)]
|
||||
start = text.index("\n %s:\n" % JOBS[name])
|
||||
following = re.search(r"\n [A-Za-z0-9_-]+:[ ]*\n", text[start + 1:])
|
||||
return text[start:start + 1 + following.start()] if following else text[start:]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name, pytest_step", sorted(RUNS_PYTEST.items()))
|
||||
|
||||
@@ -6,6 +6,7 @@ engine generate the state from them. tests.yml, fakeweb.yml and e2e.yml (its Lin
|
||||
present, so it would be the first to download and generate).
|
||||
user-install.yml proves the installation a user gets and is left as it is.
|
||||
"""
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -20,25 +21,26 @@ RUNS_PYTEST = {
|
||||
"e2e.yml": " - name: Run the full e2e suite under a virtual display, without the root ones\n",
|
||||
"e2e.yml#windows": " - name: Run this part of the e2e\n",
|
||||
"e2e.yml#control-a": " - name: The keyboard shortcut selects all",
|
||||
"e2e.yml#network": " - name: Run the network oracle's A/A\n",
|
||||
"e2e.yml#network-windows": " - name: Run the network oracle's A/A\n",
|
||||
"fakeweb.yml": " - name: Profile P2, stock first and ours second",
|
||||
}
|
||||
|
||||
|
||||
JOBS = {"e2e.yml": "e2e", "e2e.yml#windows": "e2e-windows", "e2e.yml#control-a": "e2e-windows-control-a", "e2e.yml#network": "e2e-network",
|
||||
"e2e.yml#network-windows": "e2e-network-windows"}
|
||||
|
||||
|
||||
def _scope(name):
|
||||
"""The text of one workflow, or of one leg of it: `e2e.yml` is its Linux job, `e2e.yml#windows` its Windows parts, `e2e.yml#control-a` the
|
||||
Windows job of the keyboard shortcut (it fetches and launches too)."""
|
||||
file, _, leg = name.partition("#")
|
||||
"""The text of one workflow, or of one job of e2e.yml (`e2e.yml` is its Linux job, `#windows` its Windows parts, `#control-a` the Windows job of the keyboard
|
||||
shortcut, `#network` and `#network-windows` the jobs of the network oracle): a job runs from its header to the next one."""
|
||||
file, _, _leg = name.partition("#")
|
||||
text = (WORKFLOWS / file).read_text(encoding="utf-8")
|
||||
if file != "e2e.yml":
|
||||
return text
|
||||
windows = text.index("\n e2e-windows:\n")
|
||||
if leg == "windows":
|
||||
return text[windows:]
|
||||
if leg == "control-a":
|
||||
start = text.index("\n e2e-windows-control-a:\n")
|
||||
return text[start:windows] if start < windows else text[start:]
|
||||
ends = [i for i in (text.find("\n e2e-windows-control-a:\n"), windows) if i >= 0]
|
||||
return text[:min(ends)]
|
||||
start = text.index("\n %s:\n" % JOBS[name])
|
||||
following = re.search(r"\n [A-Za-z0-9_-]+:[ ]*\n", text[start + 1:])
|
||||
return text[start:start + 1 + following.start()] if following else text[start:]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name, pytest_step", sorted(RUNS_PYTEST.items()))
|
||||
@@ -49,7 +51,7 @@ def test_the_security_state_is_set_once_before_the_step_that_runs_the_tests(name
|
||||
assert text.index(SET) < text.index(pytest_step), "%s sets the security state after the tests started" % name
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", ["e2e.yml", "e2e.yml#windows", "e2e.yml#control-a", "fakeweb.yml"])
|
||||
@pytest.mark.parametrize("name", ["e2e.yml", "e2e.yml#windows", "e2e.yml#control-a", "e2e.yml#network", "e2e.yml#network-windows", "fakeweb.yml"])
|
||||
def test_the_security_state_is_set_before_the_engine_is_fetched(name):
|
||||
text = _scope(name)
|
||||
assert FETCH in text, "the fetch step of %s moved: update this test with it" % name
|
||||
|
||||
@@ -96,7 +96,7 @@ def test_the_workflow_as_it_was_is_refused():
|
||||
|
||||
|
||||
def test_the_current_workflow_without_the_exclusion_is_refused():
|
||||
text = WORKFLOW.read_text(encoding="utf-8").replace("for f in $ROOT_FILES $SANDBOX_FILES;", "for f in $ROOT_FILES;")
|
||||
text = WORKFLOW.read_text(encoding="utf-8").replace("for f in $ROOT_FILES $SANDBOX_FILES $OWN_JOB_FILES;", "for f in $ROOT_FILES $OWN_JOB_FILES;")
|
||||
assert any("does not ignore" in p for p in problems(text))
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user