Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

進階建置與測試說明

使用者模式單元測試

Asterinas 由許多軟體箱組成,其中部分不需要 VM 環境,即可使用標準的 cargo test 進行測試。這些軟體箱已列在根目錄的 Makefile 中,並可透過以下 Make 命令進行統一測試。

make test

若要測試單個軟體箱,請進入該軟體箱的目錄並執行 cargo test

內核模式單元測試

Asterinas 中的許多軟體箱都需要虛擬機環境才能進行測試。這些軟體箱的單元測試是由 OSDK 提供支援的。

make ktest

若要在內核模式下測試單個軟體箱,請進入該軟體箱的目錄並執行 cargo osdk test

cd asterinas/ostd
cargo osdk test

整合測試

Regression Test

The following command builds and runs the regression test in test/initramfs/src/regression on Asterinas.

make run_kernel AUTO_TEST=regression

Conformance Test

The following command builds and runs the conformance test on Asterinas.

make run_kernel AUTO_TEST=conformance

To run conformance test interactively, start an instance of Asterinas with the conformance tests built and installed.

make run_kernel ENABLE_CONFORMANCE_TEST=true

Then, in the interactive shell, run the following script to start the conformance test.

/opt/run_conformance_test.sh

除錯

使用 GDB 進行除錯

To debug Asterinas via QEMU GDB support, you can compile Asterinas in the debug profile, start an Asterinas instance and run the GDB interactive shell in another terminal.

Start a GDB-enabled VM of Asterinas with OSDK and wait for debugging connection:

make gdb_server

The server will listen at the default address specified in Makefile, i.e., a local TCP port :1234. Change the address in Makefile for your convenience, and check cargo osdk run -h for more details about the address.

Two options are provided to interact with the debug server.

  • GDB 客戶端:在另一個終端機啟動 GDB 客戶端。

    make gdb_client
    
  • VS Code: CodeLLDB extension is required. After starting a debug server with OSDK from the shell with make gdb_server, a temporary launch.json is generated under .vscode. Your previous launch configs will be restored after the server is down. Press F5(Run and Debug) to start a debug session via VS Code. Click Continue(or, press F5) at the first break to resume the paused server instance, then it will continue until reaching your first breakpoint.

Note that if debugging with KVM enabled, you must use hardware assisted breakpoints. See “hbreak” in the GDB manual for details.