a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Copyright (C) 2011 Michael Brown <mbrown@fensystems.co.uk>.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This program is free software; you can redistribute it and/or
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * modify it under the terms of the GNU General Public License as
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * published by the Free Software Foundation; either version 2 of the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * License, or any later version.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This program is distributed in the hope that it will be useful, but
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * WITHOUT ANY WARRANTY; without even the implied warranty of
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * General Public License for more details.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * You should have received a copy of the GNU General Public License
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * along with this program; if not, write to the Free Software
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Self-test infrastructure
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Forcibly enable assertions */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Current self-test set */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Report test result
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v success Test succeeded
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v file Test code file
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v line Test code line
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncvoid test_ok ( int success, const char *file, unsigned int line ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Sanity check */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Increment test counter */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Report failure if applicable */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync printf ( "FAILURE: \"%s\" test failed at %s line %d\n",
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Run self-test set
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync unsigned int old_assertion_failures = assertion_failures;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Sanity check */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Record current test set */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Run tests */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Clear current test set */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Record number of assertion failures */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Print test set summary */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( tests->failures || tests->assertion_failures ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Run all self-tests
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @ret rc Return status code
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Run all compiled-in self-tests */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Print overall summary */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync printf ( " with %d assertion failures", assertions );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic int test_image_probe ( struct image *image __unused ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic int test_image_exec ( struct image *image __unused ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* Register self-tests image */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( ( rc = register_image ( &test_image ) ) != 0 ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /* No way to report failure */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Self-test initialisation function */