Add ecapture mock, fake sing-box tun bypass, and use /sdcard/Download for AVD pushes#16
Merged
Conversation
Reviewer's Guide更新 fake Magisk smoke 环境,以更好地模拟 sing-box/ecapture 的行为,并调整 AVD 测试脚本,将模块 zip、二进制文件和 fixtures 的临时目录从 /sdcard/Download/MagicNet 下 AVD 临时文件处理流程图flowchart TD
A[install_zip_on_avd / push_x86_core_binaries / prepare_avd_node_fixtures] --> B[adb shell mkdir -p /sdcard/Download/MagicNet]
B --> C[adb push artifacts to /sdcard/Download/MagicNet]
C --> D[adb shell install module zip or copy binaries/fixtures into module paths]
D --> E[adb shell rm /sdcard/Download/MagicNet/module-zip.zip]
D --> F[adb shell rm /sdcard/Download/MagicNet/pushed binaries and fixtures]
E --> G[AVD ready for tests with clean temp dir]
F --> G
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your Experience打开你的 dashboard 以:
Getting HelpOriginal review guide in EnglishReviewer's GuideUpdates the fake Magisk smoke environment to better simulate sing-box/ecapture behavior and adjusts AVD test scripts to use a more reliable, cleaned-up /sdcard/Download/MagicNet temp area instead of /data/local/tmp for module zips, binaries, and fixtures. Flow diagram for AVD temp file handling under /sdcard/Download/MagicNetflowchart TD
A[install_zip_on_avd / push_x86_core_binaries / prepare_avd_node_fixtures] --> B[adb shell mkdir -p /sdcard/Download/MagicNet]
B --> C[adb push artifacts to /sdcard/Download/MagicNet]
C --> D[adb shell install module zip or copy binaries/fixtures into module paths]
D --> E[adb shell rm /sdcard/Download/MagicNet/module-zip.zip]
D --> F[adb shell rm /sdcard/Download/MagicNet/pushed binaries and fixtures]
E --> G[AVD ready for tests with clean temp dir]
F --> G
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我在这里给出了一些高层次的反馈:
/sdcard/Download/MagicNet路径及其相关的设置/清理逻辑现在在kam-test.sh的多个函数中都有重复;可以考虑把这部分逻辑集中到一个共享的辅助函数中(例如device_tmp_dir和ensure_device_tmp_dir),以减少重复,同时将来如果需要修改路径时只需要改一处。- 追加在
__singbox__.sh里的singbox_tun()覆盖实现目前只由MAGICNET_FAKE_LOG来控制;如果这个函数在 fake-smoke 场景之外也会被使用,建议让该覆盖更明确地与 fake 环境绑定(比如检查一个专门的 fake 模式开关,或者仅在 fake 运行时去 source 它),从而降低被意外复用的可能性。
给 AI Agents 的提示
请根据这次代码评审中的评论进行修改:
## 总体评论
- `/sdcard/Download/MagicNet` 路径及其相关的设置/清理逻辑现在在 `kam-test.sh` 的多个函数中都有重复;可以考虑把这部分逻辑集中到一个共享的辅助函数中(例如 `device_tmp_dir` 和 `ensure_device_tmp_dir`),以减少重复,同时将来如果需要修改路径时只需要改一处。
- 追加在 `__singbox__.sh` 里的 `singbox_tun()` 覆盖实现目前只由 `MAGICNET_FAKE_LOG` 来控制;如果这个函数在 fake-smoke 场景之外也会被使用,建议让该覆盖更明确地与 fake 环境绑定(比如检查一个专门的 fake 模式开关,或者仅在 fake 运行时去 source 它),从而降低被意外复用的可能性。帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审质量。
Original comment in English
Hey - I've left some high level feedback:
- The
/sdcard/Download/MagicNetpath and its setup/cleanup logic are now duplicated across several functions inkam-test.sh; consider centralizing this into a shared helper (e.g.,device_tmp_dir+ensure_device_tmp_dir) to reduce repetition and keep future path changes in one place. - The appended
singbox_tun()override in__singbox__.shis guarded only byMAGICNET_FAKE_LOG; if this function is used outside the fake-smoke context, it may be helpful to make the override more explicitly tied to the fake environment (e.g., by checking a dedicated fake-mode flag or sourcing it only for fake runs) to reduce the chance of accidental reuse.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `/sdcard/Download/MagicNet` path and its setup/cleanup logic are now duplicated across several functions in `kam-test.sh`; consider centralizing this into a shared helper (e.g., `device_tmp_dir` + `ensure_device_tmp_dir`) to reduce repetition and keep future path changes in one place.
- The appended `singbox_tun()` override in `__singbox__.sh` is guarded only by `MAGICNET_FAKE_LOG`; if this function is used outside the fake-smoke context, it may be helpful to make the override more explicitly tied to the fake environment (e.g., by checking a dedicated fake-mode flag or sourcing it only for fake runs) to reduce the chance of accidental reuse.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
/sdcard/Download/MagicNet) instead of/data/local/tmp.Description
lib/kamfw/__singbox__.shin the fake Magisk module that definessingbox_tun()to skip host/dev/net/tunchecks whenMAGICNET_FAKE_LOGis set.ecaptureviawrite_mock ecaptureand copy the mock into the module ($MODDIR/bin/ecapture) so the smoke environment can exerciseecapturecalls.ecaptureandpidofmocks into$MODDIR/binand add lightweight PID tracking for the fakesing-boxprocess in mocks.scripts/kam-test.shto use/sdcard/Download/MagicNetfor temporary device files ininstall_zip_on_avd,push_x86_core_binaries, andprepare_avd_node_fixtures, including creating the directory before pushes and removing pushed artifacts after copying into module locations.Testing
Codex Task
Summary by Sourcery
通过在模拟环境中mock更多二进制文件,并在模拟器上使用更可靠的临时路径,提升 fake Magisk 烟雾测试环境的覆盖率并稳定 AVD 文件处理。
新功能:
MAGICNET_FAKE_LOG时,在 Magisk mock 环境中添加一个 fake sing-box tun 覆盖。ecapture二进制文件,并包含基础的子命令处理。增强点:
ecapture和pidof二进制文件复制到模块的 bin 目录中,以在烟雾测试中更好地模拟运行时行为。/sdcard/Download/MagicNet用作模块压缩包、核心二进制文件和夹具配置的稳定临时目录,并在使用后清理临时产物。Original summary in English
Summary by Sourcery
Improve fake Magisk smoke environment coverage and stabilize AVD file handling by mocking additional binaries and using a more reliable temporary path on the emulator.
New Features:
Enhancements: