ACK: [PATCH] ac_adapter: skip tests when no power supply exists

ivanhu ivan.hu at canonical.com
Thu Aug 16 09:22:51 UTC 2018



On 08/16/2018 03:03 PM, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
>  src/acpi/ac_adapter/ac_adapter.c |  6 ++----
>  src/lib/src/fwts_ac_adapter.c    | 12 ++++++++++++
>  2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/src/acpi/ac_adapter/ac_adapter.c b/src/acpi/ac_adapter/ac_adapter.c
> index 1b21b4e..e7d2082 100644
> --- a/src/acpi/ac_adapter/ac_adapter.c
> +++ b/src/acpi/ac_adapter/ac_adapter.c
> @@ -31,10 +31,8 @@ static int ac_adapter_init(fwts_framework *fw)
>  	int not_matching = 0;
>
>  	if (fwts_ac_adapter_get_state(FWTS_AC_ADAPTER_ANY, &matching, &not_matching) != FWTS_OK) {
> -		fwts_failed(fw, LOG_LEVEL_LOW, "NoACAdapterEntry",
> -			"No %s or %s directory available: cannot test.",
> -			FWTS_SYS_CLASS_POWER_SUPPLY, FWTS_PROC_ACPI_AC_ADAPTER);
> -		return FWTS_ERROR;
> +		fwts_log_error(fw, "Power Supply does not exist, skipping test");
> +		return FWTS_SKIP;
>  	}
>  	return FWTS_OK;
>  }
> diff --git a/src/lib/src/fwts_ac_adapter.c b/src/lib/src/fwts_ac_adapter.c
> index 42e2025..9dd828f 100644
> --- a/src/lib/src/fwts_ac_adapter.c
> +++ b/src/lib/src/fwts_ac_adapter.c
> @@ -78,6 +78,18 @@ int fwts_ac_adapter_get_state(const int state, int *matching, int *not_matching)
>
>  	/* Try to user newer /sys interface first */
>  	if ((ac_power_dir = opendir(FWTS_SYS_CLASS_POWER_SUPPLY))) {
> +		struct dirent *ac_entry;
> +		int count = 0;
> +
> +		while ((ac_entry = readdir(ac_power_dir)) != NULL)
> +			count++;
> +
> +		/* no power supply dir exists */
> +		if (count == 2) {
> +			(void)closedir(ac_power_dir);
> +			return FWTS_ERROR;
> +		}
> +
>  		ac_interface = &fwts_ac_interfaces[SYS_INTERFACE];
>  	/* then try older /proc interface  */
>  	} else if ((ac_power_dir = opendir(FWTS_PROC_ACPI_AC_ADAPTER))) {

Acked-by: Ivan Hu <ivan.hu at canonical.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20180816/7bbd7514/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20180816/7bbd7514/attachment-0001.sig>


More information about the fwts-devel mailing list