mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-04 04:32:24 -05:00 
			
		
		
		
	Adds check to avoid overwriting files
Adds check to avoid accidental overwriting of config.h or the yotta module, as well as a force option to override any changes.
This commit is contained in:
		
							parent
							
								
									3f5c875654
								
							
						
					
					
						commit
						2e23c82753
					
				@ -2,20 +2,24 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# all.sh
 | 
					# all.sh
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					# This file is part of mbed TLS (https://tls.mbed.org)
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
# Copyright (c) 2014-2016, ARM Limited, All Rights Reserved
 | 
					# Copyright (c) 2014-2016, ARM Limited, All Rights Reserved
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Purpose
 | 
					# Purpose
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Run all available tests (mostly).
 | 
					# To run all tests possible or available on the platform.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Warning: includes various build modes, so it will mess with the current
 | 
					# Warning: the test is destructive. It includes various build modes and
 | 
				
			||||||
# CMake configuration. After this script is run, the CMake cache is lost and
 | 
					# configurations, and can and will arbitrarily change the current CMake
 | 
				
			||||||
# CMake is not initialised any more!
 | 
					# configuration. After this script has been run, the CMake cache will be lost
 | 
				
			||||||
 | 
					# and CMake will no longer be initialised.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Assumes gcc and clang (recent enough for using ASan with gcc and MemSan with
 | 
					# The script assumes the presence of gcc and clang (recent enough for using
 | 
				
			||||||
# clang, or valgrind) are available, as well as cmake and a "good" find.
 | 
					# ASan with gcc and MemSan with clang, or valgrind) are available, as well as
 | 
				
			||||||
 | 
					# cmake and a "good" find.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Abort on errors (and uninitiliased variables)
 | 
					# Abort on errors (and uninitialised variables)
 | 
				
			||||||
set -eu
 | 
					set -eu
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -d library -a -d include -a -d tests ]; then :; else
 | 
					if [ -d library -a -d include -a -d tests ]; then :; else
 | 
				
			||||||
@ -28,23 +32,16 @@ CONFIG_BAK="$CONFIG_H.bak"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
MEMORY=0
 | 
					MEMORY=0
 | 
				
			||||||
SHORT=0
 | 
					SHORT=0
 | 
				
			||||||
 | 
					FORCE=0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while [ $# -gt 0 ]; do
 | 
					usage()
 | 
				
			||||||
    case "$1" in
 | 
					{
 | 
				
			||||||
        -m*)
 | 
					    echo "Usage: $0"
 | 
				
			||||||
            MEMORY=${1#-m}
 | 
					    echo -e "  -h|--help\t\tPrint this help."
 | 
				
			||||||
            ;;
 | 
					    echo -e "  -m|--memory\t\tAdditional optional memory tests."
 | 
				
			||||||
        -s)
 | 
					    echo -e "  -s|--short\t\tSubset of tests."
 | 
				
			||||||
            SHORT=1
 | 
					    echo -e "  -f|--force\t\tForce the tests to overwrite any modified files."
 | 
				
			||||||
            ;;
 | 
					}
 | 
				
			||||||
        *)
 | 
					 | 
				
			||||||
            echo "Unknown argument: '$1'" >&2
 | 
					 | 
				
			||||||
            echo "Use the source, Luke!" >&2
 | 
					 | 
				
			||||||
            exit 1
 | 
					 | 
				
			||||||
            ;;
 | 
					 | 
				
			||||||
    esac
 | 
					 | 
				
			||||||
    shift
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# remove built files as well as the cmake cache/config
 | 
					# remove built files as well as the cmake cache/config
 | 
				
			||||||
cleanup()
 | 
					cleanup()
 | 
				
			||||||
@ -72,6 +69,50 @@ msg()
 | 
				
			|||||||
    echo "******************************************************************"
 | 
					    echo "******************************************************************"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					while [ $# -gt 0 ]; do
 | 
				
			||||||
 | 
					    case "$1" in
 | 
				
			||||||
 | 
					        --memory|-m*)
 | 
				
			||||||
 | 
					            MEMORY=${1#-m}
 | 
				
			||||||
 | 
					            ;;
 | 
				
			||||||
 | 
					        --short|-s)
 | 
				
			||||||
 | 
					            SHORT=1
 | 
				
			||||||
 | 
					            ;;
 | 
				
			||||||
 | 
					        --force|-f)
 | 
				
			||||||
 | 
					            FORCE=1
 | 
				
			||||||
 | 
					            ;;
 | 
				
			||||||
 | 
					        --help|-h|*)
 | 
				
			||||||
 | 
					            usage()
 | 
				
			||||||
 | 
					            exit 1
 | 
				
			||||||
 | 
					            ;;
 | 
				
			||||||
 | 
					    esac
 | 
				
			||||||
 | 
					    shift
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ $FORCE -eq 1 ]; then
 | 
				
			||||||
 | 
					    rm -rf yotta/module
 | 
				
			||||||
 | 
					    git checkout-index -f -q $CONFIG_H
 | 
				
			||||||
 | 
					    cleanup
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if [ -d yotta/module ]; then
 | 
				
			||||||
 | 
					        echo "Warning - there is an existing yotta module in the directory 'yotta/module'" >&2
 | 
				
			||||||
 | 
					        echo "You can either delete your work and retry, or force the test to overwrite the"
 | 
				
			||||||
 | 
					        echo "test by rerunning the script as: $0 --force"
 | 
				
			||||||
 | 
					        exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ! git diff-files --quiet include/mbedtls/config.h; then
 | 
				
			||||||
 | 
					        echo $?
 | 
				
			||||||
 | 
					        echo "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " >&2
 | 
				
			||||||
 | 
					        echo "You can either delete or preserve your work, or force the test by rerunning the"
 | 
				
			||||||
 | 
					        echo "script as: $0 --force"
 | 
				
			||||||
 | 
					        exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Test Suites to be executed
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
# The test ordering tries to optimize for the following criteria:
 | 
					# The test ordering tries to optimize for the following criteria:
 | 
				
			||||||
# 1. Catch possible problems early, by running first tests that run quickly
 | 
					# 1. Catch possible problems early, by running first tests that run quickly
 | 
				
			||||||
#    and/or are more likely to fail than others (eg I use Clang most of the
 | 
					#    and/or are more likely to fail than others (eg I use Clang most of the
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user