mirror of https://github.com/nirenjan/libx52.git
Add tests for blink, shift & clock display
parent
ebf566d9be
commit
cd4fca0d2e
|
@ -11,5 +11,6 @@ bin_PROGRAMS = x52cli x52test
|
|||
x52cli_SOURCES = src/x52_cli.c
|
||||
x52cli_LDADD = libx52.la
|
||||
|
||||
x52test_SOURCES = src/x52_test.c src/x52_test_mfd.c src/x52_test_led.c
|
||||
x52test_SOURCES = src/x52_test.c src/x52_test_mfd.c src/x52_test_led.c \
|
||||
src/x52_test_clock.c
|
||||
x52test_LDADD = libx52.la
|
||||
|
|
|
@ -112,6 +112,8 @@ int main()
|
|||
RUN_TEST(leds)
|
||||
RUN_TEST(mfd_text)
|
||||
RUN_TEST(mfd_display)
|
||||
RUN_TEST(blink_n_shift)
|
||||
RUN_TEST(clock)
|
||||
} while (0);
|
||||
|
||||
if (rc > 0) {
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Saitek X52 Pro MFD & LED driver
|
||||
*
|
||||
* Copyright (C) 2012-2015 Nirenjan Krishnan (nirenjan@nirenjan.org)
|
||||
*
|
||||
* This program 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, version 2.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libx52.h"
|
||||
#include "x52_test_common.h"
|
||||
|
||||
int test_clock(void)
|
||||
{
|
||||
time_t i;
|
||||
time_t start;
|
||||
time_t end;
|
||||
|
||||
print_banner("Clock");
|
||||
puts("This tests the clock display");
|
||||
|
||||
/* Start from midnight Jan 1 2015 GMT */
|
||||
start = 1420070400;
|
||||
|
||||
puts("\nTesting clock time minute display for 1 hour increment");
|
||||
end = start + 3600;
|
||||
TEST(clock_format, LIBX52_CLOCK_1, LIBX52_CLOCK_FORMAT_12HR);
|
||||
for (i = start; i < end; i += 60) {
|
||||
/* Run all minutes, display in GMT */
|
||||
TEST(clock, i, 0);
|
||||
usleep(250000);
|
||||
}
|
||||
|
||||
puts("\nTesting clock time display for 25 hour increments, 12 hour mode");
|
||||
end = start + 86400 + 1440;
|
||||
for (i = start; i < end; i += 3600) {
|
||||
/* Run all hours, display in GMT */
|
||||
TEST(clock, i, 0);
|
||||
usleep(250000);
|
||||
}
|
||||
|
||||
puts("\nTesting clock time display for 25 hour increments, 24 hour mode");
|
||||
TEST(clock_format, LIBX52_CLOCK_1, LIBX52_CLOCK_FORMAT_24HR);
|
||||
for (i = start; i < end; i += 3600) {
|
||||
/* Run all hours, display in GMT */
|
||||
TEST(clock, i, 0);
|
||||
usleep(250000);
|
||||
}
|
||||
}
|
|
@ -40,7 +40,9 @@ void print_banner(const char *message);
|
|||
|
||||
int test_brightness(void);
|
||||
int test_mfd_display(void);
|
||||
int test_mfd_text(void);
|
||||
int test_leds(void);
|
||||
|
||||
int test_blink_n_shift(void);
|
||||
int test_clock(void);
|
||||
|
||||
#endif /* X52_TEST_COMMON_H */
|
||||
|
|
|
@ -57,3 +57,22 @@ int test_leds(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_BLINK_OR_SHIFT(type) do { \
|
||||
puts("\nTesting " #type); \
|
||||
sleep(1); \
|
||||
puts(#type " ON"); \
|
||||
TEST(type, 1); \
|
||||
sleep(2); \
|
||||
puts(#type " OFF"); \
|
||||
TEST(type, 0); \
|
||||
} while (0)
|
||||
|
||||
int test_blink_n_shift(void)
|
||||
{
|
||||
print_banner("Blink & Shift");
|
||||
puts("This tests the blink indicator and shift functionality");
|
||||
|
||||
TEST_BLINK_OR_SHIFT(blink);
|
||||
TEST_BLINK_OR_SHIFT(shift);
|
||||
}
|
||||
|
|
|
@ -92,32 +92,12 @@ int test_mfd_display(void)
|
|||
|
||||
memset(str, i, 16);
|
||||
|
||||
libx52_set_text(dev, 0, str, 16);
|
||||
libx52_set_text(dev, 1, str, 16);
|
||||
libx52_set_text(dev, 2, str, 16);
|
||||
TEST(text, 0, str, 16);
|
||||
TEST(text, 1, str, 16);
|
||||
TEST(text, 2, str, 16);
|
||||
|
||||
/* Try upto 3 times - if it fails, dump an error */
|
||||
for (j = 0; j < 3; j++) {
|
||||
rc = libx52_update(dev);
|
||||
if (rc) {
|
||||
fprintf(stderr, "\tError %d during update\n", rc);
|
||||
sleep(1);
|
||||
} else {
|
||||
puts("OK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (test_exit) {
|
||||
return test_exit;
|
||||
}
|
||||
|
||||
/* usleep(1500000); */
|
||||
sleep(1);
|
||||
puts("OK");
|
||||
usleep(500000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue