#define ERRFILE_null_sanboot ( ERRFILE_CORE | 0x00140000 )
#define ERRFILE_edd ( ERRFILE_CORE | 0x00150000 )
#define ERRFILE_parseopt ( ERRFILE_CORE | 0x00160000 )
+#define ERRFILE_test ( ERRFILE_CORE | 0x00170000 )
#define ERRFILE_eisa ( ERRFILE_DRIVER | 0x00000000 )
#define ERRFILE_isa ( ERRFILE_DRIVER | 0x00010000 )
#include <stddef.h>
#include <stdio.h>
+#include <errno.h>
#include <assert.h>
#include <ipxe/test.h>
#include <ipxe/init.h>
+#include <ipxe/image.h>
/** Current self-test set */
static struct self_test *current_tests;
/**
* Run all self-tests
*
+ * @ret rc Return status code
*/
-static void test_init ( void ) {
+static int run_all_tests ( void ) {
struct self_test *tests;
unsigned int failures = 0;
unsigned int assertions = 0;
printf ( " with %d assertion failures", assertions );
}
printf ( "\n" );
+ return -EINPROGRESS;
} else {
printf ( "OK: all %d tests passed\n", total );
+ return 0;
}
+}
+
+static int test_image_probe ( struct image *image __unused ) {
+ return -ENOTTY;
+}
+
+static int test_image_exec ( struct image *image __unused ) {
+ return run_all_tests();
+}
+
+static struct image_type test_image_type = {
+ .name = "self-tests",
+ .probe = test_image_probe,
+ .exec = test_image_exec,
+};
+
+static void test_image_free ( struct refcnt *refcnt __unused ) {
+ /* Do nothing */
+}
- /* Lock system */
- while ( 1 ) {}
+static struct image test_image = {
+ .refcnt = REF_INIT ( test_image_free ),
+ .name = "<TESTS>",
+ .type = &test_image_type,
+};
+
+static void test_init ( void ) {
+ int rc;
+
+ /* Register self-tests image */
+ if ( ( rc = register_image ( &test_image ) ) != 0 ) {
+ DBG ( "Could not register self-test image: %s\n",
+ strerror ( rc ) );
+ /* No way to report failure */
+ return;
+ }
}
/** Self-test initialisation function */
-struct init_fn test_init_fn __init_fn ( INIT_NORMAL ) = {
+struct init_fn test_init_fn __init_fn ( INIT_EARLY ) = {
.initialise = test_init,
};