build-prevail

作者: microsoft

独立构建并测试 PREVAIL 验证器(external/ebpf-verifier)。当被要求构建、测试或迭代 PREVAIL 验证器、运行 YAML… 时,使用此技能。

npx skills add https://github.com/microsoft/ebpf-for-windows --skill build-prevail

Build and Test PREVAIL Verifier

Build and test the PREVAIL eBPF verifier (external/ebpf-verifier) independently from the main eBPF for Windows solution.

When to Use

  • Working on verifier changes in external/ebpf-verifier/
  • Running or debugging YAML verification tests
  • Building run_yaml.exe or tests.exe for the verifier
  • Iterating on verifier fixes with faster feedback than full MSBuild

Prerequisites

The verifier's cmake build directory must exist. If external/ebpf-verifier/build/ is missing, run from the solution root:

.\scripts\initialize_ebpf_repo.ps1

This generates cmake projects for the verifier (and other submodules). You only need to do this once, or after resetting submodules.

Building Standalone

cd external\ebpf-verifier

# Build the YAML test runner (most common during development)
cmake --build build --config Release --target run_yaml

# Build the full Catch2 test binary
cmake --build build --config Release --target tests

# Clean build (rebuild everything from scratch)
cmake --build build --config Release --clean-first

Enabling Standalone Tests

When built as a submodule, prevail_ENABLE_TESTS defaults to OFF. To enable standalone tests:

cmake -B build -Dprevail_ENABLE_TESTS=ON
cmake --build build --config Release

Note: The initialize_ebpf_repo.ps1 script does NOT enable tests. You need to reconfigure with -Dprevail_ENABLE_TESTS=ON if you want to build tests.exe standalone.

Running YAML Tests

YAML test files are in external/ebpf-verifier/test-data/*.yaml. Each file is a test suite with individual tests separated by ---.

cd external\ebpf-verifier

# Run all tests in a suite
.\bin\run_yaml.exe test-data\loop.yaml

# Run tests matching a substring
.\bin\run_yaml.exe test-data\loop.yaml "while loop with"

# Run a specific test by exact name
.\bin\run_yaml.exe test-data\bitop.yaml "AND with 0xFF preserves relations when value fits"

Exit codes

  • 0 — all tests passed
  • 1 — one or more tests failed

Discovering postconditions for new tests

When writing new YAML tests, use placeholder postconditions and run the test to discover actual values:

post:
  - placeholder
messages:
  - placeholder

The failure output shows "Unexpected properties" (actual values) and "Unseen properties" (your placeholders). Copy the actual values into your test.

Available test suites

SuiteDescription
loop.yamlBounded loop verification (termination checking)
bitop.yamlBitwise operations (AND, OR, XOR)
movsx.yamlSign extension (MOVSX) operations
sext.yamlSign/zero extension relational tests
jump.yamlConditional jumps and branching
packet.yamlPacket access safety
pointer.yamlPointer arithmetic and safety
stack.yamlStack access verification
call.yamlHelper function calls
calllocal.yamlLocal (subprogram) calls
assign.yamlRegister assignment
add.yaml / subtract.yamlArithmetic operations
muldiv.yaml / sdivmod.yaml / udivmod.yamlMultiplication, division, modulo
shift.yamlShift operations
atomic.yamlAtomic operations
full64.yaml64-bit comparison operations
unsigned.yamlUnsigned comparison operations
unop.yamlUnary operations (neg, swap)
observe.yamlObservation/assertion tests
uninit.yamlUninitialized variable detection
map.yamlMap operations
parse.yamlYAML parsing tests
callx.yamlIndirect calls

Running the Full Catch2 Test Binary

cd external\ebpf-verifier

# Run all tests
.\bin\tests.exe

# Run with compact reporter
.\bin\tests.exe --reporter compact

# Abort on first failure
.\bin\tests.exe --abort --reporter compact

# Run specific test sections
.\bin\tests.exe "YAML suite: test-data/loop.yaml"

The tests.exe binary includes YAML tests, ELF verification tests, conformance tests, and unit tests.

YAML Test Format

---
test-case: descriptive test name
options: ["termination"]    # optional; enables loop termination checking

pre: ["r1.type=number", "r1.svalue=[0, 100]", "r1.uvalue=r1.svalue"]

code:
  <start>: |
    r0 = 0
  <loop>: |
    r0 += 1
    if r1 > r0 goto <loop>
  <out>: |
    exit

post:
  - r0.type=number
  - r0.svalue=[1, 100]

messages: []    # expected verifier messages; omit for no messages

Key conventions

  • r prefix for 64-bit registers, w prefix for 32-bit
  • w2 = r2 generates a 32-bit self-MOV (SHL 32 + RSH 32 truncation pattern)
  • r2 &= 255 generates 64-bit AND with immediate
  • svalue = signed value, uvalue = unsigned value
  • r2.svalue=r1.svalue means relational constraint (r2 tracks r1)
  • r1.svalue=[0, 100] means interval [0, 100]
  • pc[N] refers to the loop counter at instruction N
  • post: must list ALL expected properties — unlisted ones cause "Unexpected properties" failure
  • messages: field is optional (defaults to empty)

Building via MSBuild (within the main solution)

When you need to build the verifier as part of the main solution (e.g., to build bpf2c which depends on it):

# From solution root
msbuild ebpf-for-windows.sln /m /p:Configuration=Debug /p:Platform=x64 /t:"tools\bpf2c" /v:q /nologo

The MSBuild target for the verifier library is libs\user\prevail (for Debug/Release configs). The ubpf_fuzzer\ebpfverifier target is a separate copy used only in FuzzerDebug configuration.

Submodule Notes

  • The verifier lives at external/ebpf-verifier/ as a git submodule
  • git stash in the parent repo does NOT affect the submodule working tree — stash separately in the submodule if needed
  • To reset to the committed pointer: git submodule update --init --recursive (from the parent repo root)
  • After resetting submodules, re-run .\scripts\initialize_ebpf_repo.ps1 to regenerate cmake projects

来自 microsoft 的更多技能

oss-growth
microsoft
OSS增长黑客角色
agent-framework-azure-ai-py
microsoft
使用Microsoft Agent Framework Python SDK(agent-framework-azure-ai)构建Azure AI Foundry代理。在创建使用AzureAIAgentsProvider的持久化代理、使用托管工具(代码解释器、文件搜索、网络搜索)、集成MCP服务器、管理对话线程或实现流式响应时使用。涵盖函数工具、结构化输出和多工具代理。
development
airunway-aks-setup
microsoft
在AKS上设置AI Runway——从裸集群到运行模型。涵盖集群验证、控制器安装、GPU评估、提供商设置和首次部署。适用场景:“设置AI Runway”、“接入AKS集群”、“安装AI Runway”、“airunway设置”、“将模型部署到AKS”、“在AKS上进行GPU推理”、“在AKS上配置KAITO”、“在AKS上运行LLM”、“在AKS上使用vLLM”、“在AKS上设置模型服务”、“AI Runway控制器”。
devops
appinsights-instrumentation
microsoft
使用Azure Application Insights对Web应用进行插桩的指南。提供遥测模式、SDK设置和配置参考。适用场景:如何对应用进行插桩、App Insights SDK、遥测模式、什么是App Insights、Application Insights指南、插桩示例、APM最佳实践。
devops
applicationinsights-web-ts
microsoft
使用Application Insights JavaScript SDK(@microsoft/applicationinsights-web)为浏览器/Web应用添加检测。用于真实用户监控(RUM)——页面视图、点击、AJAX/fetch依赖项、异常、自定义事件,以及与后端OpenTelemetry追踪关联的浏览器端GenAI代理追踪。涵盖SDK加载器脚本和npm设置、框架扩展(React、React Native、Angular)、点击分析、遥测初始化器,以及从浏览器发出的代理/工具/模型跨度所遵循的OTel GenAI语义约定。
devops
azure-ai-anomalydetector-java
microsoft
使用适用于 Java 的 Azure AI 异常检测器 SDK 构建异常检测应用程序。在实现单变量/多变量异常检测、时间序列分析或 AI 驱动的监控时使用。
development
azure-ai-language-conversations-py
microsoft
使用azure-ai-language-conversations Python SDK实现对话语言理解(CLU)。当使用ConversationAnalysisClient分析对话意图和实体、构建NLP功能或将语言理解集成到应用程序中时使用。
development
azure-ai-ml-py
microsoft
Azure Machine Learning SDK v2 for Python。用于机器学习工作区、作业、模型、数据集、计算资源和管道。 触发词:“azure-ai-ml”、“MLClient”、“工作区”、“模型注册表”、“训练作业”、“数据集”。
development