Repository navigation
加 dataverify 回归项:磁盘读写数据核对(普通写和 O_DIRECT 混写,冷启动后回读) - #20
Merged
Merged
Conversation
在临时实例的客体 /data/unencrypted/ 里写由种子算出的花样文件(默认 1 GiB,单次 4 KiB–1 MiB), sync、正常关机、冷启动后回读比对哈希,不一致就报第一个不同的偏移和错字节数。 客体的 dd 没有 oflag=direct,写入用 items/dataverify-guest.go(宿主 go build)。 带假客体的测试 tests/dataverify.ps1 接进 CI。 Refs ModAVD/ModAVD#138
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.
Refs ModAVD/ModAVD#138
加 ModAVD/ModAVD#138 第 3 条的常驻回归项
dataverify(磁盘读写数据核对,0.39.0 发版回归时手工做过一次)。改了什么
items/dataverify.ps1:用测试根的 modavd 新建一台临时实例(默认 4 号,已有就停),在客体/data/unencrypted/里写一个固定花样的文件,总量默认 1 GiB(-SizeMiB改小),单次写入 4 KiB 到 1 MiB、普通写和O_DIRECT写各占一半左右。写完sync、清页缓存回读一次哈希;再sync、正常关机、冷启动(核对boot_id变了),回读哈希和宿主按种子算的比对;不一致就把文件拉回来,报第一个不同的偏移和错字节数。最后删文件、删实例(-Keep留着实例)。参数:-Sdk(必填)、-Root、-Index、-SizeMiB、-Seed、-DirectPercent、-Keep;开关机、adb、端口都走common.ps1里现有的函数,和别的项一样。items/dataverify-lib.ps1:花样(7 MiB,splitmix64 从种子算出)、写入计划(文件按 1 MiB 分段,每段随机对半劈成 4 KiB–1 MiB 的 2 的幂大小的块,块偏移是自己大小的整数倍)、期望哈希、逐字节比对、核对流程Invoke-DataVerify。碰客体的动作都由调用方以脚本块传进来。items/dataverify-guest.go:客体里的写入小程序。客体自带的 toyboxdd没有oflag=direct(实测报bad oflag=direct),所以写入用它:宿主go build(linux/amd64 静态)后推进去,按计划文件一块一块写,直写的块用O_DIRECT。花样、计划都由宿主算好推进去,哈希用客体的sha256sum。宿主要有 Go。/data/unencrypted/:/data/local/tmp、/sdcard是文件级加密的目录,ext4 在那里会把O_DIRECT悄悄退回普通写(0.39.0 回归时发现的)。suites/release.psd1登记dataverify(Scopes emulator、manager,限时 25 分钟);README.md、README.en.md同步登记、写明要 Go;check.yml加一步跑tests/dataverify.ps1。adb shell "…$VAR…"。怎么跑
跑了什么
tests/dataverify.ps1(不开模拟器,假客体)24 条断言:花样和计划可复现、换种子就不同;计划覆盖整个文件、块对齐、普通写和直写都有;正常通过并清理;冷启动后翻 1 个字节报出偏移和 1 个错字节;截短报出错字节数;文件没了、关机或冷启动失败、boot_id没变、剩余空间不够、清理出错都判失败,失败时也清理。O_DIRECT在客体里真的绕过页缓存(0.39.0 手工做时用写前后的扇区计数核对过,这里没有再做)。