Enhance clock test to test all portions of clock 1

pull/7/head
nirenjan 2015-12-04 19:34:19 -08:00
parent f8a7257b54
commit b7fe3e484c
1 changed files with 31 additions and 20 deletions

View File

@ -12,6 +12,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "libx52.h"
#include "x52_test_common.h"
@ -22,34 +23,44 @@ int test_clock(void)
time_t start;
time_t end;
#define TEST_CLOCK_LOOP(bump) do { \
for (i = start; i < end; i += bump) { \
TEST(clock, i, 0); \
usleep(250000); \
} \
} while (0)
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;
puts("\nTesting clock time minute display for 90 minutes");
end = start + 90 * 60;
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);
}
TEST_CLOCK_LOOP(60);
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);
}
end = start + 36 * 60 * 60;
puts("\nTesting clock time hour display for 36 hours, 12 hour mode");
TEST_CLOCK_LOOP(3600);
puts("\nTesting clock time display for 25 hour increments, 24 hour mode");
puts("\nTesting clock time hour display for 36 hours, 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);
}
TEST_CLOCK_LOOP(3600);
end = start + 31 * 24 * 60 * 60;
puts("\nTesting clock date display for 31 days, dd-mm-yy");
TEST(date_format, LIBX52_DATE_FORMAT_DDMMYY);
TEST_CLOCK_LOOP(86400);
puts("\nTesting clock date display for 31 days, mm-dd-yy");
TEST(date_format, LIBX52_DATE_FORMAT_MMDDYY);
TEST_CLOCK_LOOP(86400);
puts("\nTesting clock date display for 31 days, yy-mm-dd");
TEST(date_format, LIBX52_DATE_FORMAT_YYMMDD);
TEST_CLOCK_LOOP(86400);
return 0;
}