Add 2038 test during build -- make check will fail is there is a 2038 problem

https://github.com/Hamlib/Hamlib/issues/1478
pull/1488/head
Mike Black W9MDB 2024-01-24 10:45:32 -06:00
rodzic a4ff5a3e60
commit 1b5fbc1d8b
2 zmienionych plików z 39 dodań i 2 usunięć

Wyświetl plik

@ -17,7 +17,7 @@ DISTCLEANFILES = rigctl.log rigctl.sum testbcd.log testbcd.sum
bin_PROGRAMS = rigctl rigctld rigmem rigsmtr rigswr rotctl rotctld rigctlcom rigctltcp rigctlsync ampctl ampctld rigtestmcast rigtestmcastrx $(TESTLIBUSB) rigfreqwalk
#check_PROGRAMS = dumpmem testrig testrigopen testrigcaps testtrn testbcd testfreq listrigs testloc rig_bench testcache cachetest cachetest2 testcookie testgrid testsecurity
check_PROGRAMS = dumpmem testrig testrigopen testrigcaps testtrn testbcd testfreq listrigs testloc rig_bench testcache cachetest cachetest2 testcookie testgrid hamlibmodels testmW2power
check_PROGRAMS = dumpmem testrig testrigopen testrigcaps testtrn testbcd testfreq listrigs testloc rig_bench testcache cachetest cachetest2 testcookie testgrid hamlibmodels testmW2power test2038
RIGCOMMONSRC = rigctl_parse.c rigctl_parse.h dumpcaps.c dumpstate.c uthash.h rig_tests.c rig_tests.h dumpcaps.h
ROTCOMMONSRC = rotctl_parse.c rotctl_parse.h dumpcaps_rot.c uthash.h dumpcaps_rot.h
@ -106,7 +106,7 @@ endif
EXTRA_DIST = rigmatrix_head.html rig_split_lst.awk testctld.pl testrotctld.pl
# Support 'make check' target for simple tests
check_SCRIPTS = testrig.sh testfreq.sh testbcd.sh testloc.sh testrigcaps.sh testcache.sh testcookie.sh testgrid.sh
check_SCRIPTS = testrig.sh testfreq.sh testbcd.sh testloc.sh testrigcaps.sh testcache.sh testcookie.sh testgrid.sh test2038.sh
TESTS = $(check_SCRIPTS)
@ -143,4 +143,8 @@ testgrid.sh:
echo './testgrid' > testgrid.sh
chmod +x ./testgrid.sh
test2038.sh:
echo 'LD_LIBRARY_PATH=$(top_builddir)/src/.libs:$(top_builddir)/dummy/.libs ./test2038 1' > test2038.sh
chmod +x ./test2038.sh
CLEANFILES = testrig.sh testfreq.sh testbcd.sh testloc.sh testrigcaps.sh testcache.sh testcookie.sh rigtestlibusb build-w32.sh build-w64.sh build-w64-jtsdk.sh testgrid.sh testrigcaps.sh

33
tests/test2038.c 100644
Wyświetl plik

@ -0,0 +1,33 @@
/* 2038 test
This is OK on 64-bit systems and mingw64
Does fail when compiled with gcc -m32 -o 2038 2038.c
*/
#include <stdio.h>
#include <time.h>
#include <string.h>
int main(void)
{
time_t x;
x = (time_t)((1U << 31) - 1);
char *s = ctime(&x);
//printf("%s", s);
if (!strstr(s, "2038")) { return 1; }
x += 1;
s = ctime(&x);
if (!strstr(s, "2038")) { return 1; }
//printf("%s", s);
x += 1;
s = ctime(&x);
if (!strstr(s, "2038")) { return 1; }
//printf("%s", s);
return 0;
}