-
Notifications
You must be signed in to change notification settings - Fork 0
Testing
JNode utilizes a combination of standard JUnit testing on the host JVM and full-system boot testing using virtual machines to verify functionality.
Testing an operating system is challenging because much of the code cannot run in a standard environment. JNode divides testing into two distinct phases:
- Unit Testing (Host JVM): Fast, automated tests that run on the standard Java JVM during the build process.
- 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.
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
- To run all tests across the entire project:
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
@MagicPermissionororg.jnode.vm.Unsafe. - Code that relies on the JNode JIT compilers or specific
VmProcessorbehaviors. - Native hardware interactions.
For these, developers use mocks, or rely on Boot Testing.
Boot testing involves actually building the JNode ISO and booting it.
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.
JNode is regularly tested against standard virtual machines.
The fastest way to test is using QEMU. The project provides a helper script:
./qemu.shThis script automatically configures QEMU with the correct memory settings, network cards, and serial ports expected by JNode, and boots the ISO.
You can also create a new Virtual Machine in VirtualBox or VMware.
- OS Type: Other / Unknown
- Memory: 512MB to 1GB
-
Storage: Mount the generated
.isoas the primary CD-ROM drive.
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.
- Build-System — Details on how the tests integrate into the Ant build pipeline.
- Boot-Sequence — Understanding the boot process helps diagnose boot test failures.