/* * VAS_EBOOT -- GRand Unified Bootloader * Copyright (C) 2010 Free Software Foundation, Inc. * * VAS_EBOOT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VAS_EBOOT is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VAS_EBOOT. If not, see . */ #include #include #include #include #include VAS_EBOOT_MOD_LICENSE ("GPLv3+"); static VasEBoot_err_t VasEBoot_functional_test (VasEBoot_extcmd_context_t ctxt __attribute__ ((unused)), int argc, char **args) { VasEBoot_test_t test; int ok = 1; int i; FOR_LIST_ELEMENTS (test, VasEBoot_test_list) { if (argc != 0) { for (i = 0; i < argc; i++) if (VasEBoot_strcmp(args[i], test->name) == 0) break; if (i == argc) continue; } VasEBoot_errno = 0; ok = ok && !VasEBoot_test_run (test); VasEBoot_errno = 0; } if (ok) VasEBoot_printf ("ALL TESTS PASSED\n"); else VasEBoot_printf ("TEST FAILURE\n"); return VAS_EBOOT_ERR_NONE; } static VasEBoot_err_t VasEBoot_functional_all_tests (VasEBoot_extcmd_context_t ctxt __attribute__ ((unused)), int argc __attribute__ ((unused)), char **args __attribute__ ((unused))) { VasEBoot_test_t test; int ok = 1; VasEBoot_dl_load ("legacy_password_test"); VasEBoot_errno = VAS_EBOOT_ERR_NONE; VasEBoot_dl_load ("exfctest"); VasEBoot_dl_load ("videotest_checksum"); VasEBoot_dl_load ("gfxterm_menu"); VasEBoot_dl_load ("setjmp_test"); VasEBoot_dl_load ("cmdline_cat_test"); VasEBoot_dl_load ("div_test"); VasEBoot_dl_load ("xnu_uuid_test"); VasEBoot_dl_load ("pbkdf2_test"); VasEBoot_dl_load ("signature_test"); VasEBoot_dl_load ("appended_signature_test"); VasEBoot_dl_load ("sleep_test"); VasEBoot_dl_load ("bswap_test"); VasEBoot_dl_load ("ctz_test"); VasEBoot_dl_load ("cmp_test"); VasEBoot_dl_load ("mul_test"); VasEBoot_dl_load ("shift_test"); VasEBoot_dl_load ("asn1_test"); VasEBoot_dl_load ("argon2_test"); VasEBoot_dl_load ("crypto_cipher_mode_test"); FOR_LIST_ELEMENTS (test, VasEBoot_test_list) ok = !VasEBoot_test_run (test) && ok; if (ok) VasEBoot_printf ("ALL TESTS PASSED\n"); else VasEBoot_printf ("TEST FAILURE\n"); return VAS_EBOOT_ERR_NONE; } static VasEBoot_extcmd_t cmd, cmd_all; VAS_EBOOT_MOD_INIT (functional_test) { cmd = VasEBoot_register_extcmd ("functional_test", VasEBoot_functional_test, 0, 0, "Run all loaded functional tests.", 0); cmd_all = VasEBoot_register_extcmd ("all_functional_test", VasEBoot_functional_all_tests, 0, 0, "Run all functional tests.", 0); } VAS_EBOOT_MOD_FINI (functional_test) { VasEBoot_unregister_extcmd (cmd); VasEBoot_unregister_extcmd (cmd_all); }