[PATCH 13/16] efi_selftest: Add selftest for counting EFI netdevices
Ilias Apalodimas
ilias.apalodimas at linaro.org
Sat Apr 12 09:40:07 CEST 2025
On Tue, 11 Mar 2025 at 18:48, Adriano Cordova <adrianox at gmail.com> wrote:
>
> Signed-off-by: Adriano Cordova <adriano.cordova at canonical.com>
Please add a proper commit message
> ---
> lib/efi_selftest/Makefile | 2 +-
> lib/efi_selftest/efi_selftest_net_device.c | 65 ++++++++++++++++++++++
> 2 files changed, 66 insertions(+), 1 deletion(-)
> create mode 100644 lib/efi_selftest/efi_selftest_net_device.c
>
> diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
> index 17fbfad116f..f7e8f02cb20 100644
> --- a/lib/efi_selftest/Makefile
> +++ b/lib/efi_selftest/Makefile
> @@ -51,7 +51,7 @@ efi_selftest_variables_runtime.o \
> efi_selftest_watchdog.o
>
> obj-$(CONFIG_EFI_ECPT) += efi_selftest_ecpt.o
> -obj-$(CONFIG_NETDEVICES) += efi_selftest_snp.o
> +obj-$(CONFIG_NETDEVICES) += efi_selftest_snp.o efi_selftest_net_device.o
> obj-$(CONFIG_EFI_HTTP_PROTOCOL) += efi_selftest_http.o
> obj-$(CONFIG_EFI_HTTP_PROTOCOL) += efi_selftest_ipconfig.o
>
> diff --git a/lib/efi_selftest/efi_selftest_net_device.c b/lib/efi_selftest/efi_selftest_net_device.c
> new file mode 100644
> index 00000000000..51963eb328c
> --- /dev/null
> +++ b/lib/efi_selftest/efi_selftest_net_device.c
> @@ -0,0 +1,65 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * efi_selftest_net_device
> + *
> + */
> +
> +#include <efi_selftest.h>
> +#include <net.h>
> +
> +static struct efi_boot_services *boottime;
> +
> +/*
> + * Setup unit test.
> + *
> + * @handle: handle of the loaded image
> + * @systable: system table
> + * Return: EFI_ST_SUCCESS for success
> + */
> +static int setup(const efi_handle_t handle,
> + const struct efi_system_table *systable)
> +{
> + efi_uintn_t num_handles;
> + efi_handle_t *handles;
> +
> + boottime = systable->boottime;
> +
> + num_handles = 0;
> + boottime->locate_handle_buffer(BY_PROTOCOL, &efi_net_guid,
> + NULL, &num_handles, &handles);
> + efi_st_printf("Detected %u active EFI net devices\n", (unsigned int)num_handles);
Shouldn't this be moved to 'execute'?
> +
> + return EFI_ST_SUCCESS;
> +}
> +
> +/*
> + * Execute unit test.
> + *
> + *
> + * Return: EFI_ST_SUCCESS for success
> + */
> +static int execute(void)
> +{
> + return EFI_ST_SUCCESS;
> +}
> +
> +/*
> + * Tear down unit test.
> + *
> + * Return: EFI_ST_SUCCESS for success
> + */
> +static int teardown(void)
> +{
> + int exit_status = EFI_ST_SUCCESS;
> +
> + return exit_status;
> +}
> +
> +EFI_UNIT_TEST(netdevices) = {
> + .name = "netdevices",
> + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
> + .setup = setup,
> + .execute = execute,
> + .teardown = teardown,
> + .on_request = true,
> +};
> --
> 2.48.1
>
Thanks
/Ilias
More information about the U-Boot
mailing list