Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/ecp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3639,7 +3639,7 @@ int mbedtls_ecp_self_test(int verbose)
#if defined(MBEDTLS_TEST_HOOKS)

MBEDTLS_STATIC_TESTABLE
mbedtls_ecp_variant mbedtls_ecp_get_variant()
mbedtls_ecp_variant mbedtls_ecp_get_variant(void)
{
return MBEDTLS_ECP_VARIANT_WITH_MPI_STRUCT;
}
Expand Down
2 changes: 1 addition & 1 deletion programs/fuzz/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mbedtls_time_t dummy_constant_time(mbedtls_time_t *time)
}
#endif

void dummy_init()
void dummy_init(void)
{
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
mbedtls_platform_set_time(dummy_constant_time);
Expand Down
2 changes: 1 addition & 1 deletion programs/fuzz/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ typedef struct fuzzBufferOffset {
#if defined(MBEDTLS_HAVE_TIME)
mbedtls_time_t dummy_constant_time(mbedtls_time_t *time);
#endif
void dummy_init();
void dummy_init(void);

int dummy_send(void *ctx, const unsigned char *buf, size_t len);
int fuzz_recv(void *ctx, unsigned char *buf, size_t len);
Expand Down
6 changes: 3 additions & 3 deletions programs/ssl/ssl_context_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ const char buf_ln_err[] = "Buffer does not have enough data to complete the pars
/*
* Basic printing functions
*/
void print_version()
void print_version(void)
{
printf("%s v%d.%d\n", PROG_NAME, VER_MAJOR, VER_MINOR);
}

void print_usage()
void print_usage(void)
{
print_version();
printf("\nThis program is used to deserialize an Mbed TLS SSL session from the base64 code provided\n"
Expand Down Expand Up @@ -179,7 +179,7 @@ void printf_err(const char *str, ...)
/*
* Exit from the program in case of error
*/
void error_exit()
void error_exit(void)
{
if (NULL != b64_file) {
fclose(b64_file);
Expand Down
2 changes: 1 addition & 1 deletion programs/test/udp_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ void delay_packet(packet *delay)
memcpy(&prev[prev_len++], delay, sizeof(packet));
}

int send_delayed()
int send_delayed(void)
{
uint8_t offset;
int ret;
Expand Down
28 changes: 28 additions & 0 deletions scripts/output_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,37 @@ echo
print_version "gcc" "--version" "" "head -n 1"
echo

if [ -n "${GCC_EARLIEST+set}" ]; then
print_version "${GCC_EARLIEST}" "--version" "" "head -n 1"
else
echo " GCC_EARLIEST : Not configured."
fi
echo

if [ -n "${GCC_LATEST+set}" ]; then
print_version "${GCC_LATEST}" "--version" "" "head -n 1"
else
echo " GCC_LATEST : Not configured."
fi
echo

print_version "clang" "--version" "" "head -n 2"
echo

if [ -n "${CLANG_EARLIEST+set}" ]; then
print_version "${CLANG_EARLIEST}" "--version" "" "head -n 2"
else
echo " CLANG_EARLIEST : Not configured."
fi
echo

if [ -n "${CLANG_LATEST+set}" ]; then
print_version "${CLANG_LATEST}" "--version" "" "head -n 2"
else
echo " CLANG_LATEST : Not configured."
fi
echo

print_version "ldd" "--version" "" "head -n 1"
echo

Expand Down
57 changes: 49 additions & 8 deletions tests/scripts/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ pre_initialize_variables () {
: ${ARMC6_BIN_DIR:=/usr/bin}
: ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
: ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-}

: ${CLANG_LATEST:="clang-16"}
: ${CLANG_EARLIEST:="clang-3.5"}
: ${GCC_LATEST:="gcc-12"}
: ${GCC_EARLIEST:="gcc-4.7"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not to hard-code versions in all.sh, just like we don't hard-code versions of OpenSSL. The CI setup (docker files on Linux) defines the versions we use.

Suggested change
: ${CLANG_LATEST:="clang-16"}
: ${CLANG_EARLIEST:="clang-3.5"}
: ${GCC_LATEST:="gcc-12"}
: ${GCC_EARLIEST:="gcc-4.7"}
: ${CLANG_LATEST:="clang-latest"}
: ${CLANG_EARLIEST:="clang-earlist"}
: ${GCC_LATEST:="gcc-latest"}
: ${GCC_EARLIEST:="gcc-earliest"}

# if MAKEFLAGS is not set add the -j option to speed up invocations of make
if [ -z "${MAKEFLAGS+set}" ]; then
export MAKEFLAGS="-j$(all_sh_nproc)"
Expand All @@ -191,9 +194,7 @@ pre_initialize_variables () {

# Gather the list of available components. These are the functions
# defined in this script whose name starts with "component_".
# Parse the script with sed. This way we get the functions in the order
# they are defined.
ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0")
ALL_COMPONENTS=$(compgen -A function component_ | sed 's/component_//')

# Exclude components that are not supported on this platform.
SUPPORTED_COMPONENTS=
Expand Down Expand Up @@ -275,6 +276,10 @@ General options:
Tool path options:
--armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
--armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
--clang-earliest=<Clang_earliest_path> Earliest version of clang available
--clang-latest=<Clang_latest_path> Latest version of clang available
--gcc-earliest=<GCC_earliest_path> Earliest version of GCC available
--gcc-latest=<GCC_latest_path> Latest version of GCC available
--gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
--gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
--gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
Expand Down Expand Up @@ -441,9 +446,13 @@ pre_parse_command_line () {
--armcc) no_armcc=;;
--armc5-bin-dir) shift; ;; # assignment to ARMC5_BIN_DIR done in pre_parse_command_line_for_dirs
--armc6-bin-dir) shift; ;; # assignment to ARMC6_BIN_DIR done in pre_parse_command_line_for_dirs
--clang-earliest) shift; CLANG_EARLIEST="$1";;
--clang-latest) shift; CLANG_LATEST="$1";;
--error-test) error_test=$((error_test + 1));;
--except) all_except=1;;
--force|-f) FORCE=1;;
--gcc-earliest) shift; GCC_EARLIEST="$1";;
--gcc-latest) shift; GCC_LATEST="$1";;
--gnutls-cli) shift; GNUTLS_CLI="$1";;
--gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
--gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
Expand Down Expand Up @@ -3993,6 +4002,7 @@ component_test_cmake_shared () {

test_build_opt () {
info=$1 cc=$2; shift 2
$cc --version
for opt in "$@"; do
msg "build/test: $cc $opt, $info" # ~ 30s
make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror"
Expand All @@ -4005,14 +4015,45 @@ test_build_opt () {
done
}

component_test_clang_opt () {
# For FreeBSD we invoke the function by name so this condition is added
# to disable the existing test_clang_opt function for linux.
if [[ $(uname) != "Linux" ]]; then
component_test_clang_opt () {
scripts/config.py full
test_build_opt 'full config' clang -O0 -Os -O2
}
fi

component_test_clang_latest_opt () {
scripts/config.py full
test_build_opt 'full config' "$CLANG_LATEST" -O0 -Os -O2
}
support_test_clang_latest_opt () {
type "$CLANG_LATEST" >/dev/null 2>/dev/null
}

component_test_clang_earliest_opt () {
scripts/config.py full
test_build_opt 'full config' clang -O0 -Os -O2
test_build_opt 'full config' "$CLANG_EARLIEST" -O0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why -O0? That's the fastest build, but -O or -O2is faster when doing build and test. Also,-O0` omits some warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I looked into the changes thoroughly and this was supposed to be -O. :(
Its also mentioned in #7891.

For the earliest compilers, just do a -O build.

Shall I create a new PR for this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it in #9286 which is where I noticed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

}
support_test_clang_earliest_opt () {
type "$CLANG_EARLIEST" >/dev/null 2>/dev/null
}

component_test_gcc_opt () {
component_test_gcc_latest_opt () {
scripts/config.py full
test_build_opt 'full config' gcc -O0 -Os -O2
test_build_opt 'full config' "$GCC_LATEST" -O0 -Os -O2
}
support_test_gcc_latest_opt () {
type "$GCC_LATEST" >/dev/null 2>/dev/null
}

component_test_gcc_earliest_opt () {
scripts/config.py full
test_build_opt 'full config' "$GCC_EARLIEST" -O0
}
support_test_gcc_earliest_opt () {
type "$GCC_EARLIEST" >/dev/null 2>/dev/null
}

component_build_mbedtls_config_file () {
Expand Down
5 changes: 5 additions & 0 deletions tests/scripts/generate_test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,11 @@ def parse_function_code(funcs_f, dependencies, suite_dependencies):
code = code.replace(name, 'test_' + name, 1)
name = 'test_' + name

# If a test function has no arguments then add 'void' argument to
# avoid "-Wstrict-prototypes" warnings from clang-16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: not specifically clang-16. That option has been around at least as far back as Clang 3.5.

if len(args) == 0:
code = code.replace('()', '(void)', 1)

for line in funcs_f:
if re.search(END_CASE_REGEX, line):
break
Expand Down
12 changes: 6 additions & 6 deletions tests/scripts/test_generate_test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def test_return(self, parse_function_arguments_mock,
self.assertEqual(arg, [])
expected = '''#line 1 "test_suite_ut.function"

void test_func()
void test_func(void)
{
ba ba black sheep
have you any wool
Expand Down Expand Up @@ -690,7 +690,7 @@ def test_with_exit_label(self, parse_function_arguments_mock,

expected = '''#line 1 "test_suite_ut.function"

void test_func()
void test_func(void)
{
ba ba black sheep
have you any wool
Expand Down Expand Up @@ -750,7 +750,7 @@ def test_function_name_on_newline(self, parse_function_arguments_mock,
void


test_func()
test_func(void)
{
ba ba black sheep
have you any wool
Expand Down Expand Up @@ -803,7 +803,7 @@ def test_case_starting_with_comment(self, parse_function_arguments_mock,



void test_func()
void test_func(void)
{
ba ba black sheep
have you any wool
Expand Down Expand Up @@ -1139,7 +1139,7 @@ def test_parsing(self):
#if defined(MBEDTLS_ENTROPY_NV_SEED)
#if defined(MBEDTLS_FS_IO)
#line 13 "test_suite_ut.function"
void test_func1()
void test_func1(void)
{
exit:
;
Expand All @@ -1156,7 +1156,7 @@ def test_parsing(self):
#if defined(MBEDTLS_ENTROPY_NV_SEED)
#if defined(MBEDTLS_FS_IO)
#line 19 "test_suite_ut.function"
void test_func2()
void test_func2(void)
{
exit:
;
Expand Down