Skip to content

Commit 608953e

Browse files
Back up and restore config.h systematically
In all.sh, always save config.h before running a component, instead of doing it manually in each component that requires it (except when we forget, which has happened). This would break a script that requires config.h.bak not to exist, but we don't have any of those.
1 parent ffcdeff commit 608953e

File tree

1 file changed

+3
-34
lines changed

1 file changed

+3
-34
lines changed

tests/scripts/all.sh

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ component_test_ref_configs () {
529529

530530
component_test_sslv3 () {
531531
msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
532-
cp "$CONFIG_H" "$CONFIG_BAK"
533532
scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3
534533
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
535534
make
@@ -547,7 +546,6 @@ component_test_sslv3 () {
547546

548547
component_test_no_renegotiation () {
549548
msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
550-
cp "$CONFIG_H" "$CONFIG_BAK"
551549
scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
552550
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
553551
make
@@ -561,7 +559,6 @@ component_test_no_renegotiation () {
561559

562560
component_test_rsa_no_crt () {
563561
msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
564-
cp "$CONFIG_H" "$CONFIG_BAK"
565562
scripts/config.pl set MBEDTLS_RSA_NO_CRT
566563
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
567564
make
@@ -578,7 +575,6 @@ component_test_rsa_no_crt () {
578575

579576
component_test_small_ssl_out_content_len () {
580577
msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
581-
cp "$CONFIG_H" "$CONFIG_BAK"
582578
scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384
583579
scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
584580
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
@@ -590,7 +586,6 @@ component_test_small_ssl_out_content_len () {
590586

591587
component_test_small_ssl_in_content_len () {
592588
msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
593-
cp "$CONFIG_H" "$CONFIG_BAK"
594589
scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 4096
595590
scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
596591
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
@@ -602,7 +597,6 @@ component_test_small_ssl_in_content_len () {
602597

603598
component_test_small_ssl_dtls_max_buffering () {
604599
msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
605-
cp "$CONFIG_H" "$CONFIG_BAK"
606600
scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
607601
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
608602
make
@@ -613,7 +607,6 @@ component_test_small_ssl_dtls_max_buffering () {
613607

614608
component_test_small_mbedtls_ssl_dtls_max_buffering () {
615609
msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
616-
cp "$CONFIG_H" "$CONFIG_BAK"
617610
scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 240
618611
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
619612
make
@@ -624,7 +617,6 @@ component_test_small_mbedtls_ssl_dtls_max_buffering () {
624617

625618
component_test_full_cmake_clang () {
626619
msg "build: cmake, full config, clang" # ~ 50s
627-
cp "$CONFIG_H" "$CONFIG_BAK"
628620
scripts/config.pl full
629621
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
630622
CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
@@ -645,7 +637,6 @@ component_test_full_cmake_clang () {
645637

646638
component_build_deprecated () {
647639
msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s
648-
cp "$CONFIG_H" "$CONFIG_BAK"
649640
scripts/config.pl full
650641
scripts/config.pl set MBEDTLS_DEPRECATED_WARNING
651642
# Build with -O -Wextra to catch a maximum of issues.
@@ -699,7 +690,6 @@ component_test_no_platform () {
699690
# This should catch missing mbedtls_printf definitions, and by disabling file
700691
# IO, it should catch missing '#include <stdio.h>'
701692
msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
702-
cp "$CONFIG_H" "$CONFIG_BAK"
703693
scripts/config.pl full
704694
scripts/config.pl unset MBEDTLS_PLATFORM_C
705695
scripts/config.pl unset MBEDTLS_NET_C
@@ -721,7 +711,6 @@ component_test_no_platform () {
721711
component_build_no_std_function () {
722712
# catch compile bugs in _uninit functions
723713
msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
724-
cp "$CONFIG_H" "$CONFIG_BAK"
725714
scripts/config.pl full
726715
scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
727716
scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
@@ -730,15 +719,13 @@ component_build_no_std_function () {
730719

731720
component_build_no_ssl_srv () {
732721
msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
733-
cp "$CONFIG_H" "$CONFIG_BAK"
734722
scripts/config.pl full
735723
scripts/config.pl unset MBEDTLS_SSL_SRV_C
736724
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
737725
}
738726

739727
component_build_no_ssl_cli () {
740728
msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
741-
cp "$CONFIG_H" "$CONFIG_BAK"
742729
scripts/config.pl full
743730
scripts/config.pl unset MBEDTLS_SSL_CLI_C
744731
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
@@ -748,7 +735,6 @@ component_build_no_sockets () {
748735
# Note, C99 compliance can also be tested with the sockets support disabled,
749736
# as that requires a POSIX platform (which isn't the same as C99).
750737
msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
751-
cp "$CONFIG_H" "$CONFIG_BAK"
752738
scripts/config.pl full
753739
scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
754740
scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
@@ -758,7 +744,6 @@ component_build_no_sockets () {
758744
component_test_no_max_fragment_length () {
759745
# Run max fragment length tests with MFL disabled
760746
msg "build: default config except MFL extension (ASan build)" # ~ 30s
761-
cp "$CONFIG_H" "$CONFIG_BAK"
762747
scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
763748
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
764749
make
@@ -769,7 +754,6 @@ component_test_no_max_fragment_length () {
769754

770755
component_test_no_max_fragment_length_small_ssl_out_content_len () {
771756
msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
772-
cp "$CONFIG_H" "$CONFIG_BAK"
773757
scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
774758
scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384
775759
scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
@@ -782,7 +766,6 @@ component_test_no_max_fragment_length_small_ssl_out_content_len () {
782766

783767
component_test_null_entropy () {
784768
msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
785-
cp "$CONFIG_H" "$CONFIG_BAK"
786769
scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY
787770
scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
788771
scripts/config.pl set MBEDTLS_ENTROPY_C
@@ -798,7 +781,6 @@ component_test_null_entropy () {
798781

799782
component_test_platform_calloc_macro () {
800783
msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
801-
cp "$CONFIG_H" "$CONFIG_BAK"
802784
scripts/config.pl set MBEDTLS_PLATFORM_MEMORY
803785
scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
804786
scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free
@@ -811,7 +793,6 @@ component_test_platform_calloc_macro () {
811793

812794
component_test_aes_fewer_tables () {
813795
msg "build: default config with AES_FEWER_TABLES enabled"
814-
cp "$CONFIG_H" "$CONFIG_BAK"
815796
scripts/config.pl set MBEDTLS_AES_FEWER_TABLES
816797
make CC=gcc CFLAGS='-Werror -Wall -Wextra'
817798

@@ -821,7 +802,6 @@ component_test_aes_fewer_tables () {
821802

822803
component_test_aes_rom_tables () {
823804
msg "build: default config with AES_ROM_TABLES enabled"
824-
cp "$CONFIG_H" "$CONFIG_BAK"
825805
scripts/config.pl set MBEDTLS_AES_ROM_TABLES
826806
make CC=gcc CFLAGS='-Werror -Wall -Wextra'
827807

@@ -831,7 +811,6 @@ component_test_aes_rom_tables () {
831811

832812
component_test_aes_fewer_tables_and_rom_tables () {
833813
msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
834-
cp "$CONFIG_H" "$CONFIG_BAK"
835814
scripts/config.pl set MBEDTLS_AES_FEWER_TABLES
836815
scripts/config.pl set MBEDTLS_AES_ROM_TABLES
837816
make CC=gcc CFLAGS='-Werror -Wall -Wextra'
@@ -848,7 +827,6 @@ component_test_make_shared () {
848827
component_test_m32_o0 () {
849828
# Build once with -O0, to compile out the i386 specific inline assembly
850829
msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
851-
cp "$CONFIG_H" "$CONFIG_BAK"
852830
scripts/config.pl full
853831
make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address'
854832

@@ -859,7 +837,6 @@ component_test_m32_o0 () {
859837
component_test_m32_o1 () {
860838
# Build again with -O1, to compile in the i386 specific inline assembly
861839
msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
862-
cp "$CONFIG_H" "$CONFIG_BAK"
863840
scripts/config.pl full
864841
make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address'
865842

@@ -869,7 +846,6 @@ component_test_m32_o1 () {
869846

870847
component_test_mx32 () {
871848
msg "build: 64-bit ILP32, make, gcc" # ~ 30s
872-
cp "$CONFIG_H" "$CONFIG_BAK"
873849
scripts/config.pl full
874850
make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
875851

@@ -879,7 +855,6 @@ component_test_mx32 () {
879855

880856
component_test_have_int32 () {
881857
msg "build: gcc, force 32-bit bignum limbs"
882-
cp "$CONFIG_H" "$CONFIG_BAK"
883858
scripts/config.pl unset MBEDTLS_HAVE_ASM
884859
scripts/config.pl unset MBEDTLS_AESNI_C
885860
scripts/config.pl unset MBEDTLS_PADLOCK_C
@@ -891,7 +866,6 @@ component_test_have_int32 () {
891866

892867
component_test_have_int64 () {
893868
msg "build: gcc, force 64-bit bignum limbs"
894-
cp "$CONFIG_H" "$CONFIG_BAK"
895869
scripts/config.pl unset MBEDTLS_HAVE_ASM
896870
scripts/config.pl unset MBEDTLS_AESNI_C
897871
scripts/config.pl unset MBEDTLS_PADLOCK_C
@@ -903,7 +877,6 @@ component_test_have_int64 () {
903877

904878
component_test_no_udbl_division () {
905879
msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
906-
cp "$CONFIG_H" "$CONFIG_BAK"
907880
scripts/config.pl full
908881
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
909882
scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
@@ -915,7 +888,6 @@ component_test_no_udbl_division () {
915888

916889
component_test_no_64bit_multiplication () {
917890
msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
918-
cp "$CONFIG_H" "$CONFIG_BAK"
919891
scripts/config.pl full
920892
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
921893
scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION
@@ -927,7 +899,6 @@ component_test_no_64bit_multiplication () {
927899

928900
component_build_arm_none_eabi_gcc () {
929901
msg "build: arm-none-eabi-gcc, make" # ~ 10s
930-
cp "$CONFIG_H" "$CONFIG_BAK"
931902
scripts/config.pl full
932903
scripts/config.pl unset MBEDTLS_NET_C
933904
scripts/config.pl unset MBEDTLS_TIMING_C
@@ -945,7 +916,6 @@ component_build_arm_none_eabi_gcc () {
945916

946917
component_build_arm_none_eabi_gcc_no_udbl_division () {
947918
msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
948-
cp "$CONFIG_H" "$CONFIG_BAK"
949919
scripts/config.pl full
950920
scripts/config.pl unset MBEDTLS_NET_C
951921
scripts/config.pl unset MBEDTLS_TIMING_C
@@ -966,7 +936,6 @@ component_build_arm_none_eabi_gcc_no_udbl_division () {
966936

967937
component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
968938
msg "build: arm-none-eabi-gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
969-
cp "$CONFIG_H" "$CONFIG_BAK"
970939
scripts/config.pl full
971940
scripts/config.pl unset MBEDTLS_NET_C
972941
scripts/config.pl unset MBEDTLS_TIMING_C
@@ -987,7 +956,6 @@ component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
987956

988957
component_build_armcc () {
989958
msg "build: ARM Compiler 5, make"
990-
cp "$CONFIG_H" "$CONFIG_BAK"
991959
scripts/config.pl full
992960
scripts/config.pl unset MBEDTLS_NET_C
993961
scripts/config.pl unset MBEDTLS_TIMING_C
@@ -1028,7 +996,6 @@ component_build_armcc () {
1028996

1029997
component_test_allow_sha1 () {
1030998
msg "build: allow SHA1 in certificates by default"
1031-
cp "$CONFIG_H" "$CONFIG_BAK"
1032999
scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
10331000
make CFLAGS='-Werror -Wall -Wextra'
10341001
msg "test: allow SHA1 in certificates by default"
@@ -1052,7 +1019,6 @@ component_build_mingw () {
10521019

10531020
component_test_memsan () {
10541021
msg "build: MSan (clang)" # ~ 1 min 20s
1055-
cp "$CONFIG_H" "$CONFIG_BAK"
10561022
scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
10571023
CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
10581024
make
@@ -1242,6 +1208,9 @@ run_component () {
12421208
if [ $ALL_EXCEPT -ne 0 ] && component_is_excluded "$1"; then
12431209
return
12441210
fi
1211+
# Back up the configuration in case the component modifies it.
1212+
# The cleanup function will restore it.
1213+
cp -p "$CONFIG_H" "$CONFIG_BAK"
12451214
current_component="$1"
12461215
"$@"
12471216
cleanup

0 commit comments

Comments
 (0)