Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / mbedtls / repo / tests / scripts / curves.pl
1 #!/usr/bin/env perl
2
3 # curves.pl
4 #
5 # Copyright (c) 2014-2016, ARM Limited, All Rights Reserved
6 #
7 # Purpose
8 #
9 # To test the code dependencies on individual curves in each test suite. This
10 # is a verification step to ensure we don't ship test suites that do not work
11 # for some build options.
12 #
13 # The process is:
14 #       for each possible curve
15 #           build the library and test suites with the curve disabled
16 #           execute the test suites
17 #
18 # And any test suite with the wrong dependencies will fail.
19 #
20 # Usage: tests/scripts/curves.pl
21 #
22 # This script should be executed from the root of the project directory.
23 #
24 # For best effect, run either with cmake disabled, or cmake enabled in a mode
25 # that includes -Werror.
26
27 use warnings;
28 use strict;
29
30 -d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n";
31
32 my $sed_cmd = 's/^#define \(MBEDTLS_ECP_DP.*_ENABLED\)/\1/p';
33 my $config_h = 'include/mbedtls/config.h';
34 my @curves = split( /\s+/, `sed -n -e '$sed_cmd' $config_h` );
35
36 system( "cp $config_h $config_h.bak" ) and die;
37 sub abort {
38     system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
39     # use an exit code between 1 and 124 for git bisect (die returns 255)
40     warn $_[0];
41     exit 1;
42 }
43
44 for my $curve (@curves) {
45     system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n";
46     system( "make clean" ) and die;
47
48     # depends on a specific curve. Also, ignore error if it wasn't enabled
49     system( "scripts/config.pl unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED" );
50
51     print "\n******************************************\n";
52     print "* Testing without curve: $curve\n";
53     print "******************************************\n";
54
55     system( "scripts/config.pl unset $curve" )
56         and abort "Failed to disable $curve\n";
57
58     system( "CFLAGS='-Werror -Wall -Wextra' make lib" )
59         and abort "Failed to build lib: $curve\n";
60     system( "make" ) and abort "Failed to build tests: $curve\n";
61     system( "make test" ) and abort "Failed test suite: $curve\n";
62
63 }
64
65 system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n";
66 system( "make clean" ) and die;
67 exit 0;