Page 1 of 1

How do you test your code?

Posted: Tue Jan 30, 2007 5:13 pm
by alehel
I was just wondering how various experienced OS hobby coders go about testing their code. Obviously, putting it on floppy and booting on it is a bit of a long process just to test some code, but using bochs, I would think, could potentially give misleading results, as it's not a genuin machine.

Could someone explain to me how network booting works. This seems to be the simplest and most sure way of testing an OS. Can you just connect two computers together using an ethernet cable and have it boot of files from you development computer?

Posted: Tue Jan 30, 2007 5:32 pm
by Alboin
I use QEMU for testing as I don't like to have to play with Boch's configuration files. Moreover, I just use an image on local disk instead of actually writing it to a floppy.

On network booting: Does this help?

Toodles!

Posted: Tue Jan 30, 2007 5:40 pm
by frank
I use Bochs and QEMU. I haven't noticed any major differences between the emulators and a real computer. Sometimes it will work on one and not the other, but that usually signals a problem in your code.

Also, the Bochs debugger is a very nice thing to have.

Posted: Wed Jan 31, 2007 3:11 am
by AJ
Hi,

I use Bochs, MS VPC and now VirtualBox too. I have found the Bochs emulator very useful for initial debugging, but the VM's have always given me a clearer idea about what happens on real hardware.

The main problem I have found with Bochs is when I have assumed that uninitialised memory is set to zero. Of course, on a real machine you should initialise everything by hand and the VM's generally pick this up. Of course, if you want to check that your OS really works, there is no substitute for a real PC!

Oh - one thing about VPC too - the main reason I have switched more to virtualbox now is that my kernel uses task gates in the IDT. VPC does not seem to support this (see the official forums for more information). Currently I only do this for the double fault exception handler, but it is still annoying! Unfortunately, VirtualBox does not seem to have the same serial port virtualisation as VPC though.

All this really goes to show is that different emu's are better at assessing different parts of your OS...

Cheers,
Adam

Posted: Wed Jan 31, 2007 4:15 am
by Combuster
I use Bochs mainly for initial testing, and after that i move to qemu, VirtualPC, and real machines, depending on what i have plugged in at that moment. (if i have a second computer connected i generally go straight to it, otherwise i run tests on other emulators first).
Also, i have 8 different copies of bochs to test processor configuration (a 386, a 686, a multiprocessor box, and an amd64, in both debug and non-debug mode) to make sure my os works on the entire range of target processors.

On more general testing, i keep some test drivers that can test specific functionality, to check that specific things actually work.

And yes, bochs can be misleading. So far i have not been able to get multiprocessor code to work outside of it, and there are some issues with the hardware emulation.
Alboin wrote:I use QEMU for testing as I don't like to have to play with Boch's configuration files.
You only need to create the configuration once, and the default is usually pretty good.
AJ wrote:The main problem I have found with Bochs is when I have assumed that uninitialised memory is set to zero. Of course, on a real machine you should initialise everything by hand and the VM's generally pick this up.
I have a debug option in my kernel that fills the memory between 1M-4M to garbage for just that reason. Those 5 lines of assembly revealed a lot of bugs when i first added it...

Posted: Wed Jan 31, 2007 5:55 am
by Otter
In general, I use bochs to test my code. But if I want to test my OS on a real machine, I do not need to put it on a floppy because I use grub.

My makefile also generates a multiboot kernel so I only need to reboot and to select my OS in the grub menu.