In NetBSD’s later stage of bootup, Kernel finds device with root filesystem. this search is assisted with the help of config file of kernel. NetBSD has Testing suite called ATF (Automated testing framework) But this suite does not cover this area of function. We attempt to write test for root device and filesystem selection. Functions we need to test are setroot , it utilizes number of other functions for different scenarios which are documented in my documentation . we will use vnd to use device simulation in userspace.
our goals could be divided into 2 parts
we had to document config file’s constructs for device specifications and types. Functionality and control flow of root device and file system selection. We also had to take note of all the edge cases for which we could make test cases. There are number of global variables that interact with setroot inorder for a final root_device variable to be set. We had to document them and point at which it would change to produce specific scenarios. Finally We have to write ATF based Unit tests for all cases using rump kernels.
We have to move the Tests so that it uses rump kernel and also rewrite/refactor part of kern_subr.c for code quality.
here is my tree for project /src
This function handles wildcard entry in config file else handles specified device Test Cases for setroot_root
this function handles network bootingTest Cases for tftproot_dhcpboot
currently they are these functions run in userspace hence calls mocked functions while running, we intend to move them to use rumpkernel. we will use vnd(8) for setting up neccessary enviroment for running without mocking internal functions. Global Varibles are set outside of kernel space manually.
As part of side quests which will also assits us in future in terms of debugging I Completed printbootinfo function in x86_machdep.c commit 1
This piece of code was immensely knowledage and important for me as a developer. it has many revisions based on reviews from my mentor,this taught me importance of clean code, readability and low level programming concepts.
Here is Documentation for all functions in kern_subr.c Docs
it covers main setroot() and following