views:

63

answers:

2

I have written a daemon in linux for doing dhcp for an embedded system. This platform only has a linux kernel running on it and have no CLI support. What is the best way for me to test my daemon? How do I write a program that will call the main function in this daemon and verify if its working fine?

Appreciate the answers.

+4  A: 

When I've been in a situation like this, I've written a second daemon (or had a second listener in the existing daemon) to take the place of a CLI, listening at a particular port and responding to a very limited command set of your own choosing.

In this case, all you really care about is triggering the function on demand, so you could even have it trigger when you connect to this second port, and then report results back to the socket.

I strongly recommend, by the way, making sure your embedded system has some more generic mechanism for logging information to persistent storage and retrieving that log. It doesn't have to be syslog or anything so complicated. But you will want that ability in the future to enable forensic analysis of problems in the field.

Uncle Mikey
Thanks for that answer. I liked the idea of having a second listener. I will try to have a second listener responding to basic commands from a particular port and then get the results through that.
Ullas
+1 for recommending a logging mechanism.
semaj
Amen to the logging! Given that you've already got an IP stack running, implementing the syslog protocol to export log records isn't very complicated.
bstpierre
Yes, logging is certainly high on my TODO list. I will complete that first and then work on adding the second listener. Thanks for all suggestions
Ullas
A: 

You will want to write and debug your daemon in a full featured environment first, then install it on the embedded system at the end when you are sure it works properly.

If you can build a dhcp server for the embedded system you can surely build a simple shell for it also. Try building BusyBox or ash or dash.

You could also try using GDB remote debugging. I found an article about it.

Zan Lynx
Frankly, I am not really trying to debug my daemon(I know it works on a general platform). I would like to know how it works in this particular platform and thats precisely why it becomes important to have control over this daemon on the system so that I can test other network communications of the hardware. Appreciate the suggestion though. Yes, at some point I will go and write a shell for it but was looking at some easier methods for some quick test.
Ullas
You hardly need to *write* a shell. There are literally hundreds already written to choose from!
Zan Lynx