Skip to content

Testing

Levente Santha edited this page May 9, 2026 · 1 revision

Testing

JNode utilizes a combination of standard JUnit testing on the host JVM and full-system boot testing using virtual machines to verify functionality.

Overview

Testing an operating system is challenging because much of the code cannot run in a standard environment. JNode divides testing into two distinct phases:

  1. Unit Testing (Host JVM): Fast, automated tests that run on the standard Java JVM during the build process.
  2. Boot Testing (Target VM): Manual or scripted tests that run the compiled JNode OS inside a virtual machine (QEMU, VirtualBox, VMware) to verify low-level system behavior.

Unit Testing

JNode uses JUnit 4.5, along with JMock and Mockito for mocking dependencies.

  • Location: Test files are located in the src/test/ directory of each subproject (e.g., core/src/test/, fs/src/test/). There are nearly 400 test files across the repository.
  • Execution:
    • To run all tests across the entire project: sh build.sh tests
    • To run tests for a specific subproject: cd <subproject> && ant test

Limitations of Unit Testing

Because unit tests run on the host JVM (the JVM you use to build JNode, usually OpenJDK on Linux/Windows), they cannot test:

  • Classes that use @MagicPermission or org.jnode.vm.Unsafe.
  • Code that relies on the JNode JIT compilers or specific VmProcessor behaviors.
  • Native hardware interactions.

For these, developers use mocks, or rely on Boot Testing.

Boot Testing

Boot testing involves actually building the JNode ISO and booting it.

1. Building the ISO

You must build a "lite" bootable CD-ROM image.

  • x86 (32-bit): sh build.sh cd-x86-lite
  • x86_64 (64-bit): sh build.sh cd-x86_64-lite

This produces all/build/cdroms/jnode-x86-lite.iso.

2. Running in an Emulator

JNode is regularly tested against standard virtual machines.

QEMU

The fastest way to test is using QEMU. The project provides a helper script:

./qemu.sh

This script automatically configures QEMU with the correct memory settings, network cards, and serial ports expected by JNode, and boots the ISO.

VirtualBox / VMware

You can also create a new Virtual Machine in VirtualBox or VMware.

  • OS Type: Other / Unknown
  • Memory: 512MB to 1GB
  • Storage: Mount the generated .iso as the primary CD-ROM drive.

Debugging Boot Crashes

If JNode crashes during early boot, it will usually trigger an exception handler in kernel.asm or ints.asm, which dumps the CPU state (Registers, Stack Trace) to the VGA text console and the serial port.

  • Serial Console: Output is echoed to COM1. In QEMU, this can be redirected to the terminal or a file for easier analysis.
  • Debugger (kdb): JNode has a very rudimentary kernel debugger built in, but it is primarily used for post-mortem analysis of crashes.

Related Pages

  • Build-System — Details on how the tests integrate into the Ant build pipeline.
  • Boot-Sequence — Understanding the boot process helps diagnose boot test failures.

Clone this wiki locally