Write a few tests in assembly language. The first one, which should run in an infinite loop, should set all of its registers to a known values, then test that the registers have those values. For example:
top:
cmp rax_v(%rip), %rax
jne rax_error
cmp rbx_v(%rip), %rbx
jne rbx_error
....
jmp top
running this at a low priority should give you a pretty good coverage that interrupt handlers and interrupt -> context switch saves and restores the registers properly. Remember to use a wide variety of values in the registers to minimize false matches.
Following this pattern, make one which invokes system calls. Of course it cannot check all the registers, since the system call is free to use the ABI, but it can check the others. Also, if you intend your system to make guarantees about register leaking, you can check this here.
Run a set of the processes, maybe a few of them as threads too.
Next, you will want to increase your interrupt load, with the goal being to hit the maximum possible interrupt nesting. If you have real serial ports, they can be a great source of them -- hook up a noise source (function generator or antennae) to the Carrier Detect pin of the uart, and enable modem status interrupts. Most uarts do not gate these status pins on the baud clock, so you can get a maximal interrupt storm from this. Try and set the uarts to the lowest interrupt priority.
Good luck, you should have lots of fun ahead!
sched_yieldsystem call if you want to trigger it synchronously.) - Peter Cordes