Testing an Android image built from source
So you just built a new android system from source and you would like to test it first in the emulator before flashing it onto your phone. Or perhaps you would just like to know how the bleeding edge version of android straight from the source repositories looks. Fortunately, the emulator used by android SDK is flexible enough, so you can specify what image it should use for the data, system or the other partitions -- thus you can build your own flavor of android and test it in the emulator easily.
Once you have checked out the android source tree via repo (either the official one, cyanogenmod or some other mod which published its source via a manifest file) apply your changes if any (add a new component to the system, modify the framework etc). Then just pick a build target (it can be for example full-eng, it will work with the emulator) and build it the usual way. By default the qemu-based emulator is also built, and it will be placed toout/host/linux-x86/bin/. When it's done the images will be in out/target/product/(your target device name)/. From now on I'll assume you picked the generic target.
You will also likely need an SD card image that can mounted by the emulator. The SDK contains a tool, mksdcard with which it's simple enough to create one:
$ mksdcard 1024M out/target/product/generic/sdcard.img
The SDK tools/ folder should be in your $PATH for this to work.
Now the only thing left is to fire up the emulator with your newly built images:
$ ./out/host/linux-x86/bin/emulator -sysdir out/target/product/generic -kernel prebuilt/android-arm/kernel/kernel-qemu -data out/target/product/generic/userdata.img -sdcard out/target/product/generic/sdcard.img
That's all, the emulator should start up, and if you are lucky your new android hack will come to light and work. You can use adb to copy files to/from the emulator image, or just fire up a root shell in the emulator via adb shell and take a look what is going on.