Skip to content

Commit a6b5da2

Browse files
authored
Merge pull request #225 from minad/travis/compiler-versions
Test against multiple specific clang/gcc versions
2 parents 6eae00c + e8f56cc commit a6b5da2

File tree

5 files changed

+97
-61
lines changed

5 files changed

+97
-61
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ libtommath.pc
7474
gcc_errors_*.txt
7575
test_*.txt
7676

77+
.#*
78+
*~
7779
*.bak
7880
*.orig
7981
*.asc

.travis.yml

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ branches:
3131
only:
3232
- master
3333
- develop
34-
- /^release\/.*$/
34+
- /^release/
35+
- /^travis/
3536

36-
# Additional installs are Valgrind for the memory-tests
37-
# and gcc-multilib for the compilation of the different
38-
# architectures.
37+
# Additional installs: Valgrind for memory tests.
3938
install:
4039
- sudo apt-get update -qq
4140
- sudo apt-get install valgrind
42-
- sudo apt-get install gcc-multilib
41+
- apt-cache search gcc | grep '^gcc-[0-9\.]* '
42+
- apt-cache search clang | grep compiler
4343

4444
# The language is C and it will load the respective dependencies
4545
language: c
@@ -66,60 +66,90 @@ matrix:
6666
apt:
6767
packages:
6868
- astyle
69-
sudo: required
7069

7170
# GCC for the 32-bit architecture (no valgrind yet)
72-
- env: BUILDOPTIONS='--with-cc=gcc --with-m32'
71+
- env: BUILDOPTIONS='--with-cc=gcc-5 --with-m32'
7372
addons:
7473
apt:
7574
packages:
7675
- libc6-dev-i386
77-
sudo: required
76+
- gcc-multilib
7877

7978
# clang for the 32-bit architecture (no valgrind yet)
80-
- env: BUILDOPTIONS='--with-cc=clang --with-m32'
79+
- env: BUILDOPTIONS='--with-cc=clang-7 --with-m32'
8180
addons:
8281
apt:
8382
packages:
8483
- libc6-dev-i386
85-
sudo: required
84+
- gcc-multilib
8685

8786
# GCC for the x64_32 architecture (32-bit longs and 32-bit pointers)
8887
# TODO: Probably not possible to run anything in x32 in Travis
8988
# but needs to be checked to be sure.
90-
- env: BUILDOPTIONS='--with-cc=gcc --with-mx32'
89+
- env: BUILDOPTIONS='--with-cc=gcc-5 --with-mx32'
9190
addons:
9291
apt:
9392
packages:
9493
- libc6-dev-x32
95-
sudo: required
94+
- gcc-multilib
9695

9796
# GCC for the x86-64 architecture (64-bit longs and 64-bit pointers)
98-
- env: BUILDOPTIONS='--with-cc=gcc --with-m64 --with-valgrind'
97+
- env: BUILDOPTIONS='--with-cc=gcc-5 --with-m64 --with-valgrind'
98+
- env: BUILDOPTIONS='--with-cc=gcc-4.7 --with-m64 --with-valgrind'
99+
addons:
100+
apt:
101+
packages:
102+
- gcc-4.7
103+
- env: BUILDOPTIONS='--with-cc=gcc-4.8 --with-m64 --with-valgrind'
104+
addons:
105+
apt:
106+
packages:
107+
- gcc-4.8
108+
- env: BUILDOPTIONS='--with-cc=gcc-4.9 --with-m64 --with-valgrind'
109+
addons:
110+
apt:
111+
packages:
112+
- gcc-4.9
113+
99114
# clang for x86-64 architecture (64-bit longs and 64-bit pointers)
100-
- env: BUILDOPTIONS='--with-cc=clang --with-m64 --with-valgrind'
115+
- env: CONV_WARNINGS=1 BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-valgrind'
116+
- env: BUILDOPTIONS='--with-cc=clang-6.0 --with-m64 --with-valgrind'
117+
addons:
118+
apt:
119+
packages:
120+
- clang-6.0
121+
- env: BUILDOPTIONS='--with-cc=clang-5.0 --with-m64 --with-valgrind'
122+
addons:
123+
apt:
124+
packages:
125+
- clang-5.0
126+
- env: BUILDOPTIONS='--with-cc=clang-4.0 --with-m64 --with-valgrind'
127+
addons:
128+
apt:
129+
packages:
130+
- clang-4.0
101131

102132
# GCC for the x86-64 architecture with restricted limb sizes
103133
# formerly started with the option "--with-low-mp" to testme.sh
104134
# but testing all three in one run took to long and timed out.
105-
- env: BUILDOPTIONS='--with-cc=gcc --cflags=-DMP_8BIT --with-valgrind'
106-
- env: BUILDOPTIONS='--with-cc=gcc --cflags=-DMP_16BIT --with-valgrind'
107-
- env: BUILDOPTIONS='--with-cc=gcc --cflags=-DMP_32BIT --with-valgrind'
135+
- env: BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_8BIT --with-valgrind'
136+
- env: BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_16BIT --with-valgrind'
137+
- env: BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_32BIT --with-valgrind'
108138

109139
# clang for the x86-64 architecture with restricted limb sizes
110-
- env: BUILDOPTIONS='--with-cc=clang --cflags=-DMP_8BIT --with-valgrind'
111-
- env: BUILDOPTIONS='--with-cc=clang --cflags=-DMP_16BIT --with-valgrind'
112-
- env: BUILDOPTIONS='--with-cc=clang --cflags=-DMP_32BIT --with-valgrind'
140+
- env: BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_8BIT --with-valgrind'
141+
- env: BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_16BIT --with-valgrind'
142+
- env: BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_32BIT --with-valgrind'
113143

114144
# GCC for the x86-64 architecture testing against a different Bigint-implementation
115145
# with 333333 different inputs.
116-
- env: BUILDOPTIONS='--with-cc=gcc --test-vs-mtest=333333 --with-valgrind'
117-
- env: BUILDOPTIONS='--with-cc=clang --test-vs-mtest=333333 --with-valgrind'
146+
- env: BUILDOPTIONS='--with-cc=gcc-5 --test-vs-mtest=333333 --with-valgrind'
147+
- env: BUILDOPTIONS='--with-cc=clang-7 --test-vs-mtest=333333 --with-valgrind'
118148

119149
# clang for the x86-64 architecture testing against a different Bigint-implementation
120150
# with a better random source.
121-
- env: BUILDOPTIONS='--with-cc=gcc --test-vs-mtest=333333 --mtest-real-rand --with-valgrind'
122-
- env: BUILDOPTIONS='--with-cc=clang --test-vs-mtest=333333 --mtest-real-rand --with-valgrind'
151+
- env: BUILDOPTIONS='--with-cc=gcc-5 --test-vs-mtest=333333 --mtest-real-rand --with-valgrind'
152+
- env: BUILDOPTIONS='--with-cc=clang-7 --test-vs-mtest=333333 --mtest-real-rand --with-valgrind'
123153

124154
# Notifications go to
125155
# An email address is also possible.
@@ -132,5 +162,4 @@ notifications:
132162
# seem to be the max and 20 the default if travis_wait is called without
133163
# any options.
134164
script:
135-
- ./testme.sh ${BUILDOPTIONS}
136-
165+
- ./testme.sh ${BUILDOPTIONS}

demo/opponent.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int mtest_opponent(void)
7979
FGETS(buf, 4095, stdin);
8080
mp_read_radix(&b, buf, 64);
8181

82-
mp_mul_2d(&a, rr, &a);
82+
mp_mul_2d(&a, (int)rr, &a);
8383
a.sign = b.sign;
8484
if (mp_cmp(&a, &b) != MP_EQ) {
8585
printf("mul2d failed, rr == %u\n", rr);
@@ -96,7 +96,7 @@ int mtest_opponent(void)
9696
FGETS(buf, 4095, stdin);
9797
mp_read_radix(&b, buf, 64);
9898

99-
mp_div_2d(&a, rr, &a, &e);
99+
mp_div_2d(&a, (int)rr, &a, &e);
100100
a.sign = b.sign;
101101
if ((a.used == b.used) && (a.used == 0)) {
102102
a.sign = b.sign = MP_ZPOS;
@@ -128,10 +128,10 @@ int mtest_opponent(void)
128128

129129
/* test the sign/unsigned storage functions */
130130

131-
rr = mp_signed_bin_size(&c);
131+
rr = (unsigned)mp_signed_bin_size(&c);
132132
mp_to_signed_bin(&c, (unsigned char *) cmd);
133-
memset(cmd + rr, rand() & 0xFFu, sizeof(cmd) - rr);
134-
mp_read_signed_bin(&d, (unsigned char *) cmd, rr);
133+
memset(cmd + rr, rand() & 0xFF, sizeof(cmd) - rr);
134+
mp_read_signed_bin(&d, (unsigned char *) cmd, (int)rr);
135135
if (mp_cmp(&c, &d) != MP_EQ) {
136136
printf("mp_signed_bin failure!\n");
137137
draw(&c);
@@ -140,10 +140,10 @@ int mtest_opponent(void)
140140
}
141141

142142

143-
rr = mp_unsigned_bin_size(&c);
143+
rr = (unsigned)mp_unsigned_bin_size(&c);
144144
mp_to_unsigned_bin(&c, (unsigned char *) cmd);
145-
memset(cmd + rr, rand() & 0xFFu, sizeof(cmd) - rr);
146-
mp_read_unsigned_bin(&d, (unsigned char *) cmd, rr);
145+
memset(cmd + rr, rand() & 0xFF, sizeof(cmd) - rr);
146+
mp_read_unsigned_bin(&d, (unsigned char *) cmd, (int)rr);
147147
if (mp_cmp_mag(&c, &d) != MP_EQ) {
148148
printf("mp_unsigned_bin failure!\n");
149149
draw(&c);
@@ -343,7 +343,7 @@ int mtest_opponent(void)
343343
sscanf(buf, "%d", &ix);
344344
FGETS(buf, 4095, stdin);
345345
mp_read_radix(&b, buf, 64);
346-
mp_add_d(&a, ix, &c);
346+
mp_add_d(&a, (mp_digit)ix, &c);
347347
if (mp_cmp(&b, &c) != MP_EQ) {
348348
printf("add_d %lu failure\n", add_d_n);
349349
draw(&a);
@@ -360,7 +360,7 @@ int mtest_opponent(void)
360360
sscanf(buf, "%d", &ix);
361361
FGETS(buf, 4095, stdin);
362362
mp_read_radix(&b, buf, 64);
363-
mp_sub_d(&a, ix, &c);
363+
mp_sub_d(&a, (mp_digit)ix, &c);
364364
if (mp_cmp(&b, &c) != MP_EQ) {
365365
printf("sub_d %lu failure\n", sub_d_n);
366366
draw(&a);

demo/test.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static int test_mp_jacobi(void)
103103
mp_set_int(&b, jacobi[cnt].n);
104104
/* only test positive values of a */
105105
for (n = -5; n <= 10; ++n) {
106-
mp_set_int(&a, abs(n));
106+
mp_set_int(&a, (unsigned int)abs(n));
107107
should = MP_OKAY;
108108
if (n < 0) {
109109
mp_neg(&a, &a);
@@ -221,14 +221,14 @@ static int test_mp_complement(void)
221221
}
222222

223223
for (i = 0; i < 1000; ++i) {
224-
int l = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
225-
mp_set_int(&a, labs(l));
224+
long l = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
225+
mp_set_long(&a, (unsigned long)labs(l));
226226
if (l < 0)
227227
mp_neg(&a, &a);
228228
mp_complement(&a, &b);
229229

230230
l = ~l;
231-
mp_set_int(&c, labs(l));
231+
mp_set_long(&c, (unsigned long)labs(l));
232232
if (l < 0)
233233
mp_neg(&c, &c);
234234

@@ -255,16 +255,17 @@ static int test_mp_tc_div_2d(void)
255255
}
256256

257257
for (i = 0; i < 1000; ++i) {
258-
int l, em;
258+
long l;
259+
int em;
259260

260261
l = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
261-
mp_set_int(&a, labs(l));
262+
mp_set_long(&a, (unsigned long)labs(l));
262263
if (l < 0)
263264
mp_neg(&a, &a);
264265

265266
em = rand() % 32;
266267

267-
mp_set_int(&d, labs(l >> em));
268+
mp_set_long(&d, (unsigned long)labs(l >> em));
268269
if ((l >> em) < 0)
269270
mp_neg(&d, &d);
270271

@@ -296,16 +297,16 @@ static int test_mp_tc_xor(void)
296297
int l, em;
297298

298299
l = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
299-
mp_set_int(&a, labs(l));
300+
mp_set_int(&a, (unsigned long)labs(l));
300301
if (l < 0)
301302
mp_neg(&a, &a);
302303

303304
em = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
304-
mp_set_int(&b, labs(em));
305+
mp_set_int(&b, (unsigned long)labs(em));
305306
if (em < 0)
306307
mp_neg(&b, &b);
307308

308-
mp_set_int(&d, labs(l ^ em));
309+
mp_set_int(&d, (unsigned long)labs(l ^ em));
309310
if ((l ^ em) < 0)
310311
mp_neg(&d, &d);
311312

@@ -334,19 +335,19 @@ static int test_mp_tc_or(void)
334335
}
335336

336337
for (i = 0; i < 1000; ++i) {
337-
int l, em;
338+
long l, em;
338339

339340
l = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
340-
mp_set_int(&a, labs(l));
341+
mp_set_long(&a, (unsigned long)labs(l));
341342
if (l < 0)
342343
mp_neg(&a, &a);
343344

344345
em = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
345-
mp_set_int(&b, labs(em));
346+
mp_set_long(&b, (unsigned long)labs(em));
346347
if (em < 0)
347348
mp_neg(&b, &b);
348349

349-
mp_set_int(&d, labs(l | em));
350+
mp_set_long(&d, (unsigned long)labs(l | em));
350351
if ((l | em) < 0)
351352
mp_neg(&d, &d);
352353

@@ -374,19 +375,19 @@ static int test_mp_tc_and(void)
374375
}
375376

376377
for (i = 0; i < 1000; ++i) {
377-
int l, em;
378+
long l, em;
378379

379380
l = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
380-
mp_set_int(&a, labs(l));
381+
mp_set_long(&a, (unsigned long)labs(l));
381382
if (l < 0)
382383
mp_neg(&a, &a);
383384

384385
em = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
385-
mp_set_int(&b, labs(em));
386+
mp_set_long(&b, (unsigned long)labs(em));
386387
if (em < 0)
387388
mp_neg(&b, &b);
388389

389-
mp_set_int(&d, labs(l & em));
390+
mp_set_long(&d, (unsigned long)labs(l & em));
390391
if ((l & em) < 0)
391392
mp_neg(&d, &d);
392393

@@ -554,9 +555,9 @@ static int test_mp_get_long(void)
554555
}
555556

556557
for (i = 0; i < ((int)(sizeof(unsigned long)*CHAR_BIT) - 1); ++i) {
557-
t = (1ULL << (i+1)) - 1;
558+
t = (1UL << (i+1)) - 1;
558559
if (!t)
559-
t = -1;
560+
t = ~0UL;
560561
printf(" t = 0x%lx i = %d\r", t, i);
561562
do {
562563
if (mp_set_long(&a, t) != MP_OKAY) {
@@ -592,7 +593,7 @@ static int test_mp_get_long_long(void)
592593
for (i = 0; i < ((int)(sizeof(unsigned long long)*CHAR_BIT) - 1); ++i) {
593594
r = (1ULL << (i+1)) - 1;
594595
if (!r)
595-
r = -1;
596+
r = ~0ULL;
596597
printf(" r = 0x%llx i = %d\r", r, i);
597598
do {
598599
if (mp_set_long_long(&a, r) != MP_OKAY) {
@@ -1345,7 +1346,7 @@ static int test_mp_ilogb(void)
13451346
}
13461347
/* radix_size includes the memory needed for '\0', too*/
13471348
size -= 2;
1348-
if (mp_cmp_d(&lb, size) != MP_EQ) {
1349+
if (mp_cmp_d(&lb, (mp_digit)size) != MP_EQ) {
13491350
goto LBL_ERR;
13501351
}
13511352
}
@@ -1365,7 +1366,7 @@ static int test_mp_ilogb(void)
13651366
goto LBL_ERR;
13661367
}
13671368
size -= 2;
1368-
if (mp_cmp_d(&lb, size) != MP_EQ) {
1369+
if (mp_cmp_d(&lb, (mp_digit)size) != MP_EQ) {
13691370
goto LBL_ERR;
13701371
}
13711372
}

makefile_include.mk

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow
5151

5252
ifndef NO_ADDTL_WARNINGS
5353
# additional warnings
54-
CFLAGS += -Wsystem-headers
5554
CFLAGS += -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align
5655
CFLAGS += -Wstrict-prototypes -Wpointer-arith
57-
#CFLAGS += -Wconversion -Wsign-conversion
56+
endif
57+
58+
ifdef CONV_WARNINGS
59+
CFLAGS += -Wconversion -Wsign-conversion
60+
else
61+
CFLAGS += -Wsystem-headers
5862
endif
5963

6064
ifdef COMPILE_DEBUG

0 commit comments

Comments
 (0)