Add check for LED support in x52test

This commit uses the new `libx52_check_feature` API to check if the
device supports LED control. If not, it prints an error message and
exits the LED tests gracefully.

This also reverts commit 45f009ac90, which
had moved the LED tests to the end. Since this is no longer necessary,
it is moved back to avoid any issues with anything that may have relied
on the old order.
debian-packaging
nirenjan 2020-05-22 11:14:01 -07:00
parent 482943e7a3
commit d89cce807b
4 changed files with 36 additions and 15 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: x52pro-linux 0.2.1\n"
"Report-Msgid-Bugs-To: https://github.com/nirenjan/x52pro-linux/issues\n"
"POT-Creation-Date: 2020-05-20 03:17-0700\n"
"POT-Creation-Date: 2020-05-22 10:45-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -246,26 +246,30 @@ msgid ""
"Testing LED %s\n"
msgstr ""
#: utils/test/x52_test_led.c:40
#: utils/test/x52_test_led.c:41
msgid "LEDs"
msgstr ""
#: utils/test/x52_test_led.c:41
#: utils/test/x52_test_led.c:46
msgid "Skipping LED tests since the device does not support LED control"
msgstr ""
#: utils/test/x52_test_led.c:52
msgid "This cycles the LEDs through all possible states"
msgstr ""
#: utils/test/x52_test_led.c:59
#: utils/test/x52_test_led.c:70
#, c-format
msgid ""
"\n"
"Testing %s\n"
msgstr ""
#: utils/test/x52_test_led.c:70
#: utils/test/x52_test_led.c:81
msgid "Blink & Shift"
msgstr ""
#: utils/test/x52_test_led.c:71
#: utils/test/x52_test_led.c:82
msgid "This tests the blink indicator and shift functionality"
msgstr ""

View File

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: x52pro-linux 0.2.1\n"
"Report-Msgid-Bugs-To: https://github.com/nirenjan/x52pro-linux/issues\n"
"POT-Creation-Date: 2020-05-20 03:17-0700\n"
"PO-Revision-Date: 2020-05-19 17:03-0700\n"
"POT-Creation-Date: 2020-05-22 10:45-0700\n"
"PO-Revision-Date: 2020-05-22 11:15-0700\n"
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n"
"Language-Team: Dummy Language for testing i18n\n"
"Language: xx_PL\n"
@ -274,15 +274,21 @@ msgstr ""
"\n"
"Estingtay EDLay %s\n"
#: utils/test/x52_test_led.c:40
#: utils/test/x52_test_led.c:41
msgid "LEDs"
msgstr "EDsLay"
#: utils/test/x52_test_led.c:41
#: utils/test/x52_test_led.c:46
msgid "Skipping LED tests since the device does not support LED control"
msgstr ""
"Ippingskay EDLay eststay incesay ethay eviceday oesday otnay\n"
"upportsay EDLay ontrolcay"
#: utils/test/x52_test_led.c:52
msgid "This cycles the LEDs through all possible states"
msgstr "Histay yclescay hetay EDsLay hroughtay allay ossiblepay tatessay"
#: utils/test/x52_test_led.c:59
#: utils/test/x52_test_led.c:70
#, c-format
msgid ""
"\n"
@ -291,11 +297,11 @@ msgstr ""
"\n"
"Estingtay %s\n"
#: utils/test/x52_test_led.c:70
#: utils/test/x52_test_led.c:81
msgid "Blink & Shift"
msgstr "Linkbay & Hiftsay"
#: utils/test/x52_test_led.c:71
#: utils/test/x52_test_led.c:82
msgid "This tests the blink indicator and shift functionality"
msgstr "Histay eststay hetay linkbay indicatoray anday hiftsay unctionalityfay"

View File

@ -85,11 +85,11 @@ static void signal_handler(int sig)
#define TESTS \
X(brightness, bri, gettext_noop("Test brightness scale (~ 1m)")) \
X(leds, led, gettext_noop("Test LED states (~ 45s)")) \
X(mfd_text, mfd1, gettext_noop("Test MFD string display (~ 30s)")) \
X(mfd_display, mfd2, gettext_noop("Test MFD displays all characters (~ 2m 15s)")) \
X(blink_n_shift, blink, gettext_noop("Test the blink and shift commands (< 10s)")) \
X(clock, clock, gettext_noop("Test the clock commands (~1m)")) \
X(leds, led, gettext_noop("Test LED states (~ 45s)"))
X(clock, clock, gettext_noop("Test the clock commands (~1m)"))
enum {
#define X(en, kw, desc) TEST_BIT_ ## en,

View File

@ -37,7 +37,18 @@
int test_leds(void)
{
int rc;
print_banner(_("LEDs"));
/* Check if the connected device supports individual LED control */
rc = libx52_check_feature(dev, LIBX52_FEATURE_LED);
if (rc == LIBX52_ERROR_NOT_SUPPORTED) {
puts(_("Skipping LED tests since the device does not support LED control"));
return 0;
} else if (rc != LIBX52_SUCCESS) {
return rc;
}
puts(_("This cycles the LEDs through all possible states"));
TEST_LED_MONO(FIRE);