Normally, if you want to run something after the compilation has finished, you add it to the compilation command. For example, instead of
M-x compile RET make RET
You might type
M-x compile RET make && ./test RET
or you might add the program to some appropriate target in your makefile, so you can do
M-x compile RET make test RET
Maybe if you can explain why you want to run the compiled program in eshell, I could offer you better advice.
However, if you insist on using eshell, you might be able to use compilation-finish-functions:
Functions to call when a compilation process finishes. Each function is called with two arguments: the compilation buffer, and a string describing how the process finished.
This isn't all that well documented, but the string is "finished\n" if the process finished successfully. So you might do something like this:
(defun run-compilation-output-in-eshell (buf msg)
"If compilation finished successfully, switch to eshell and execute a command."
(when (string= msg "finished\n")
(eshell)
(goto-char (point-max))
(eshell-kill-input)
(insert "echo command goes here")
(eshell-send-input)))
(add-hook 'compilation-finish-functions #'run-compilation-output-in-eshell)
This seems rather rude, though: if you happen to be typing into the eshell buffer when the compilation finishes, then this deletes your input. As I said above, a bit more context might be helpful.