How do you test your code?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
alehel
Posts: 6
Joined: Mon Jan 29, 2007 5:56 am

How do you test your code?

Post 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?
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post 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!
C8H10N4O2 | #446691 | Trust the nodes.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Otter
Member
Member
Posts: 75
Joined: Sun Dec 31, 2006 11:56 am
Location: Germany

Post 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.
Post Reply