aboutsummaryrefslogtreecommitdiff
path: root/src/usr
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2015-08-21 15:41:35 +0100
committerMichael Brown <mcb30@ipxe.org>2015-08-21 15:46:28 +0100
commitf58ebbdfb5f48089bb3df088654d5bf735dab2c2 (patch)
treef8b476c798df160482773c9d6ac68eb8f02c88e4 /src/usr
parentfb4ce72e64f14576f51d652ad949dabaced7b45e (diff)
downloadipxe-f58ebbdfb5f48089bb3df088654d5bf735dab2c2.zip
ipxe-f58ebbdfb5f48089bb3df088654d5bf735dab2c2.tar.gz
ipxe-f58ebbdfb5f48089bb3df088654d5bf735dab2c2.tar.bz2
[test] Allow self-tests to report exit status when running under Linux
Allow the return status from an embedded image to propagate out to the eventual return status from main(). When running under Linux, this allows the pass/fail result of unit tests to be observable without having to visually inspect the console output. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/autoboot.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
index ccafeae..6dbe25c 100644
--- a/src/usr/autoboot.c
+++ b/src/usr/autoboot.c
@@ -542,11 +542,13 @@ static int shell_banner ( void ) {
* Main iPXE flow of execution
*
* @v netdev Network device, or NULL
+ * @ret rc Return status code
*/
-void ipxe ( struct net_device *netdev ) {
+int ipxe ( struct net_device *netdev ) {
struct feature *feature;
struct image *image;
char *scriptlet;
+ int rc;
/*
* Print welcome banner
@@ -570,28 +572,30 @@ void ipxe ( struct net_device *netdev ) {
/* Boot system */
if ( ( image = first_image() ) != NULL ) {
/* We have an embedded image; execute it */
- image_exec ( image );
+ return image_exec ( image );
} else if ( shell_banner() ) {
/* User wants shell; just give them a shell */
- shell();
+ return shell();
} else {
fetch_string_setting_copy ( NULL, &scriptlet_setting,
&scriptlet );
if ( scriptlet ) {
/* User has defined a scriptlet; execute it */
- system ( scriptlet );
+ rc = system ( scriptlet );
free ( scriptlet );
+ return rc;
} else {
/* Try booting. If booting fails, offer the
* user another chance to enter the shell.
*/
if ( netdev ) {
- netboot ( netdev );
+ rc = netboot ( netdev );
} else {
- autoboot();
+ rc = autoboot();
}
if ( shell_banner() )
- shell();
+ rc = shell();
+ return rc;
}
}
}