Skip to content

Commit 9661f8a

Browse files
authored
Merge pull request #7968 from gowthamsk-arm/use_earliest_latest_compilers
Use earliest latest compilers
2 parents 895074e + 9da40b8 commit 9661f8a

File tree

9 files changed

+95
-21
lines changed

9 files changed

+95
-21
lines changed

library/ecp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3641,7 +3641,7 @@ int mbedtls_ecp_self_test(int verbose)
36413641
#if defined(MBEDTLS_TEST_HOOKS)
36423642

36433643
MBEDTLS_STATIC_TESTABLE
3644-
mbedtls_ecp_variant mbedtls_ecp_get_variant()
3644+
mbedtls_ecp_variant mbedtls_ecp_get_variant(void)
36453645
{
36463646
return MBEDTLS_ECP_VARIANT_WITH_MPI_STRUCT;
36473647
}

programs/fuzz/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mbedtls_time_t dummy_constant_time(mbedtls_time_t *time)
1313
}
1414
#endif
1515

16-
void dummy_init()
16+
void dummy_init(void)
1717
{
1818
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
1919
mbedtls_platform_set_time(dummy_constant_time);

programs/fuzz/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ typedef struct fuzzBufferOffset {
1515
#if defined(MBEDTLS_HAVE_TIME)
1616
mbedtls_time_t dummy_constant_time(mbedtls_time_t *time);
1717
#endif
18-
void dummy_init();
18+
void dummy_init(void);
1919

2020
int dummy_send(void *ctx, const unsigned char *buf, size_t len);
2121
int fuzz_recv(void *ctx, unsigned char *buf, size_t len);

programs/ssl/ssl_context_info.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ const char buf_ln_err[] = "Buffer does not have enough data to complete the pars
125125
/*
126126
* Basic printing functions
127127
*/
128-
void print_version()
128+
void print_version(void)
129129
{
130130
printf("%s v%d.%d\n", PROG_NAME, VER_MAJOR, VER_MINOR);
131131
}
132132

133-
void print_usage()
133+
void print_usage(void)
134134
{
135135
print_version();
136136
printf("\nThis program is used to deserialize an Mbed TLS SSL session from the base64 code provided\n"
@@ -179,7 +179,7 @@ void printf_err(const char *str, ...)
179179
/*
180180
* Exit from the program in case of error
181181
*/
182-
void error_exit()
182+
void error_exit(void)
183183
{
184184
if (NULL != b64_file) {
185185
fclose(b64_file);

programs/test/udp_proxy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ void delay_packet(packet *delay)
644644
memcpy(&prev[prev_len++], delay, sizeof(packet));
645645
}
646646

647-
int send_delayed()
647+
int send_delayed(void)
648648
{
649649
uint8_t offset;
650650
int ret;

scripts/output_env.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,37 @@ echo
105105
print_version "gcc" "--version" "" "head -n 1"
106106
echo
107107

108+
if [ -n "${GCC_EARLIEST+set}" ]; then
109+
print_version "${GCC_EARLIEST}" "--version" "" "head -n 1"
110+
else
111+
echo " GCC_EARLIEST : Not configured."
112+
fi
113+
echo
114+
115+
if [ -n "${GCC_LATEST+set}" ]; then
116+
print_version "${GCC_LATEST}" "--version" "" "head -n 1"
117+
else
118+
echo " GCC_LATEST : Not configured."
119+
fi
120+
echo
121+
108122
print_version "clang" "--version" "" "head -n 2"
109123
echo
110124

125+
if [ -n "${CLANG_EARLIEST+set}" ]; then
126+
print_version "${CLANG_EARLIEST}" "--version" "" "head -n 2"
127+
else
128+
echo " CLANG_EARLIEST : Not configured."
129+
fi
130+
echo
131+
132+
if [ -n "${CLANG_LATEST+set}" ]; then
133+
print_version "${CLANG_LATEST}" "--version" "" "head -n 2"
134+
else
135+
echo " CLANG_LATEST : Not configured."
136+
fi
137+
echo
138+
111139
print_version "ldd" "--version" "" "head -n 1"
112140
echo
113141

tests/scripts/all.sh

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ pre_initialize_variables () {
176176
: ${ARMC6_BIN_DIR:=/usr/bin}
177177
: ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
178178
: ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-}
179-
179+
: ${CLANG_LATEST:="clang-latest"}
180+
: ${CLANG_EARLIEST:="clang-earliest"}
181+
: ${GCC_LATEST:="gcc-latest"}
182+
: ${GCC_EARLIEST:="gcc-earliest"}
180183
# if MAKEFLAGS is not set add the -j option to speed up invocations of make
181184
if [ -z "${MAKEFLAGS+set}" ]; then
182185
export MAKEFLAGS="-j$(all_sh_nproc)"
@@ -191,9 +194,7 @@ pre_initialize_variables () {
191194

192195
# Gather the list of available components. These are the functions
193196
# defined in this script whose name starts with "component_".
194-
# Parse the script with sed. This way we get the functions in the order
195-
# they are defined.
196-
ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0")
197+
ALL_COMPONENTS=$(compgen -A function component_ | sed 's/component_//')
197198
198199
# Exclude components that are not supported on this platform.
199200
SUPPORTED_COMPONENTS=
@@ -275,6 +276,10 @@ General options:
275276
Tool path options:
276277
--armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
277278
--armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
279+
--clang-earliest=<Clang_earliest_path> Earliest version of clang available
280+
--clang-latest=<Clang_latest_path> Latest version of clang available
281+
--gcc-earliest=<GCC_earliest_path> Earliest version of GCC available
282+
--gcc-latest=<GCC_latest_path> Latest version of GCC available
278283
--gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
279284
--gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
280285
--gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
@@ -441,9 +446,13 @@ pre_parse_command_line () {
441446
--armcc) no_armcc=;;
442447
--armc5-bin-dir) shift; ;; # assignment to ARMC5_BIN_DIR done in pre_parse_command_line_for_dirs
443448
--armc6-bin-dir) shift; ;; # assignment to ARMC6_BIN_DIR done in pre_parse_command_line_for_dirs
449+
--clang-earliest) shift; CLANG_EARLIEST="$1";;
450+
--clang-latest) shift; CLANG_LATEST="$1";;
444451
--error-test) error_test=$((error_test + 1));;
445452
--except) all_except=1;;
446453
--force|-f) FORCE=1;;
454+
--gcc-earliest) shift; GCC_EARLIEST="$1";;
455+
--gcc-latest) shift; GCC_LATEST="$1";;
447456
--gnutls-cli) shift; GNUTLS_CLI="$1";;
448457
--gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
449458
--gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
@@ -4023,6 +4032,7 @@ component_test_cmake_shared () {
40234032
40244033
test_build_opt () {
40254034
info=$1 cc=$2; shift 2
4035+
$cc --version
40264036
for opt in "$@"; do
40274037
msg "build/test: $cc $opt, $info" # ~ 30s
40284038
make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror"
@@ -4035,14 +4045,45 @@ test_build_opt () {
40354045
done
40364046
}
40374047
4038-
component_test_clang_opt () {
4048+
# For FreeBSD we invoke the function by name so this condition is added
4049+
# to disable the existing test_clang_opt function for linux.
4050+
if [[ $(uname) != "Linux" ]]; then
4051+
component_test_clang_opt () {
4052+
scripts/config.py full
4053+
test_build_opt 'full config' clang -O0 -Os -O2
4054+
}
4055+
fi
4056+
4057+
component_test_clang_latest_opt () {
4058+
scripts/config.py full
4059+
test_build_opt 'full config' "$CLANG_LATEST" -O0 -Os -O2
4060+
}
4061+
support_test_clang_latest_opt () {
4062+
type "$CLANG_LATEST" >/dev/null 2>/dev/null
4063+
}
4064+
4065+
component_test_clang_earliest_opt () {
40394066
scripts/config.py full
4040-
test_build_opt 'full config' clang -O0 -Os -O2
4067+
test_build_opt 'full config' "$CLANG_EARLIEST" -O0
4068+
}
4069+
support_test_clang_earliest_opt () {
4070+
type "$CLANG_EARLIEST" >/dev/null 2>/dev/null
40414071
}
40424072
4043-
component_test_gcc_opt () {
4073+
component_test_gcc_latest_opt () {
40444074
scripts/config.py full
4045-
test_build_opt 'full config' gcc -O0 -Os -O2
4075+
test_build_opt 'full config' "$GCC_LATEST" -O0 -Os -O2
4076+
}
4077+
support_test_gcc_latest_opt () {
4078+
type "$GCC_LATEST" >/dev/null 2>/dev/null
4079+
}
4080+
4081+
component_test_gcc_earliest_opt () {
4082+
scripts/config.py full
4083+
test_build_opt 'full config' "$GCC_EARLIEST" -O0
4084+
}
4085+
support_test_gcc_earliest_opt () {
4086+
type "$GCC_EARLIEST" >/dev/null 2>/dev/null
40464087
}
40474088
40484089
component_build_mbedtls_config_file () {

tests/scripts/generate_test_code.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,11 @@ def parse_function_code(funcs_f, dependencies, suite_dependencies):
667667
code = code.replace(name, 'test_' + name, 1)
668668
name = 'test_' + name
669669

670+
# If a test function has no arguments then add 'void' argument to
671+
# avoid "-Wstrict-prototypes" warnings from clang
672+
if len(args) == 0:
673+
code = code.replace('()', '(void)', 1)
674+
670675
for line in funcs_f:
671676
if re.search(END_CASE_REGEX, line):
672677
break

tests/scripts/test_generate_test_code.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ def test_return(self, parse_function_arguments_mock,
647647
self.assertEqual(arg, [])
648648
expected = '''#line 1 "test_suite_ut.function"
649649
650-
void test_func()
650+
void test_func(void)
651651
{
652652
ba ba black sheep
653653
have you any wool
@@ -690,7 +690,7 @@ def test_with_exit_label(self, parse_function_arguments_mock,
690690

691691
expected = '''#line 1 "test_suite_ut.function"
692692
693-
void test_func()
693+
void test_func(void)
694694
{
695695
ba ba black sheep
696696
have you any wool
@@ -750,7 +750,7 @@ def test_function_name_on_newline(self, parse_function_arguments_mock,
750750
void
751751
752752
753-
test_func()
753+
test_func(void)
754754
{
755755
ba ba black sheep
756756
have you any wool
@@ -803,7 +803,7 @@ def test_case_starting_with_comment(self, parse_function_arguments_mock,
803803
804804
805805
806-
void test_func()
806+
void test_func(void)
807807
{
808808
ba ba black sheep
809809
have you any wool
@@ -1139,7 +1139,7 @@ def test_parsing(self):
11391139
#if defined(MBEDTLS_ENTROPY_NV_SEED)
11401140
#if defined(MBEDTLS_FS_IO)
11411141
#line 13 "test_suite_ut.function"
1142-
void test_func1()
1142+
void test_func1(void)
11431143
{
11441144
exit:
11451145
;
@@ -1156,7 +1156,7 @@ def test_parsing(self):
11561156
#if defined(MBEDTLS_ENTROPY_NV_SEED)
11571157
#if defined(MBEDTLS_FS_IO)
11581158
#line 19 "test_suite_ut.function"
1159-
void test_func2()
1159+
void test_func2(void)
11601160
{
11611161
exit:
11621162
;

0 commit comments

Comments
 (0)