1# Test framework for git. See t/README for usage. 2# 3# Copyright (c) 2005 Junio C Hamano 4# 5# This program is free software: you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation, either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see http://www.gnu.org/licenses/ . 17 18# Test the binaries we have just built. The tests are kept in 19# t/ subdirectory and are run in 'trash directory' subdirectory. 20iftest -z"$TEST_DIRECTORY" 21then 22# We allow tests to override this, in case they want to run tests 23# outside of t/, e.g. for running tests on the test library 24# itself. 25 TEST_DIRECTORY=$(pwd) 26else 27# ensure that TEST_DIRECTORY is an absolute path so that it 28# is valid even if the current working directory is changed 29 TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd)||exit1 30fi 31iftest -z"$TEST_OUTPUT_DIRECTORY" 32then 33# Similarly, override this to store the test-results subdir 34# elsewhere 35 TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY 36fi 37GIT_BUILD_DIR="$TEST_DIRECTORY"/.. 38 39# If we were built with ASAN, it may complain about leaks 40# of program-lifetime variables. Disable it by default to lower 41# the noise level. This needs to happen at the start of the script, 42# before we even do our "did we build git yet" check (since we don't 43# want that one to complain to stderr). 44:${ASAN_OPTIONS=detect_leaks=0:abort_on_error=1} 45export ASAN_OPTIONS 46 47# If LSAN is in effect we _do_ want leak checking, but we still 48# want to abort so that we notice the problems. 49:${LSAN_OPTIONS=abort_on_error=1} 50export LSAN_OPTIONS 51 52iftest!-f"$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS 53then 54echo>&2'error: GIT-BUILD-OPTIONS missing (has Git been built?).' 55exit1 56fi 57. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS 58export PERL_PATH SHELL_PATH 59 60################################################################ 61# It appears that people try to run tests without building... 62"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X">/dev/null 63iftest $? !=1 64then 65iftest -n"$GIT_TEST_INSTALLED" 66then 67echo>&2"error: there is no working Git at '$GIT_TEST_INSTALLED'" 68else 69echo>&2'error: you do not seem to have built git yet.' 70fi 71exit1 72fi 73 74# Parse options while taking care to leave $@ intact, so we will still 75# have all the original command line options when executing the test 76# script again for '--tee' and '--verbose-log' below. 77store_arg_to= 78prev_opt= 79for opt 80do 81iftest -n"$store_arg_to" 82then 83eval$store_arg_to=\$opt 84 store_arg_to= 85 prev_opt= 86continue 87fi 88 89case"$opt"in 90-d|--d|--de|--deb|--debu|--debug) 91 debug=t ;; 92-i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate) 93 immediate=t ;; 94-l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests) 95 GIT_TEST_LONG=t;export GIT_TEST_LONG ;; 96-r) 97 store_arg_to=run_list 98;; 99--run=*) 100 run_list=${opt#--*=};; 101-h|--h|--he|--hel|--help) 102help=t ;; 103-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) 104 verbose=t ;; 105--verbose-only=*) 106 verbose_only=${opt#--*=} 107;; 108-q|--q|--qu|--qui|--quie|--quiet) 109# Ignore --quiet under a TAP::Harness. Saying how many tests 110# passed without the ok/not ok details is always an error. 111test -z"$HARNESS_ACTIVE"&& quiet=t ;; 112--with-dashes) 113 with_dashes=t ;; 114--no-bin-wrappers) 115 no_bin_wrappers=t ;; 116--no-color) 117 color= ;; 118--va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind) 119 valgrind=memcheck 120tee=t 121;; 122--valgrind=*) 123 valgrind=${opt#--*=} 124tee=t 125;; 126--valgrind-only=*) 127 valgrind_only=${opt#--*=} 128tee=t 129;; 130--tee) 131tee=t ;; 132--root=*) 133 root=${opt#--*=};; 134--chain-lint) 135 GIT_TEST_CHAIN_LINT=1;; 136--no-chain-lint) 137 GIT_TEST_CHAIN_LINT=0;; 138-x) 139 trace=t ;; 140-V|--verbose-log) 141 verbose_log=t 142tee=t 143;; 144--write-junit-xml) 145 write_junit_xml=t 146;; 147--stress) 148 stress=t ;; 149--stress=*) 150 stress=${opt#--*=} 151case"$stress"in 152*[!0-9]*|0*|"") 153echo"error: --stress=<N> requires the number of jobs to run">&2 154exit1 155;; 156*)# Good. 157;; 158esac 159;; 160--stress-limit=*) 161 stress=t; 162 stress_limit=${opt#--*=} 163case"$stress_limit"in 164*[!0-9]*|0*|"") 165echo"error: --stress-limit=<N> requires the number of repetitions">&2 166exit1 167;; 168*)# Good. 169;; 170esac 171;; 172*) 173echo"error: unknown test option '$opt'">&2;exit1;; 174esac 175 176 prev_opt=$opt 177done 178iftest -n"$store_arg_to" 179then 180echo"error:$prev_optrequires an argument">&2 181exit1 182fi 183 184iftest -n"$valgrind_only" 185then 186test -z"$valgrind"&& valgrind=memcheck 187test -z"$verbose"&& verbose_only="$valgrind_only" 188eliftest -n"$valgrind" 189then 190test -z"$verbose_log"&& verbose=t 191fi 192 193iftest -n"$stress" 194then 195 verbose=t 196 trace=t 197 immediate=t 198fi 199 200TEST_STRESS_JOB_SFX="${GIT_TEST_STRESS_JOB_NR:+.stress-$GIT_TEST_STRESS_JOB_NR}" 201TEST_NAME="$(basename "$0" .sh)" 202TEST_RESULTS_DIR="$TEST_OUTPUT_DIRECTORY/test-results" 203TEST_RESULTS_BASE="$TEST_RESULTS_DIR/$TEST_NAME$TEST_STRESS_JOB_SFX" 204TRASH_DIRECTORY="trash directory.$TEST_NAME$TEST_STRESS_JOB_SFX" 205test -n"$root"&& TRASH_DIRECTORY="$root/$TRASH_DIRECTORY" 206case"$TRASH_DIRECTORY"in 207/*) ;;# absolute path is good 208*) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY";; 209esac 210 211# If --stress was passed, run this test repeatedly in several parallel loops. 212iftest"$GIT_TEST_STRESS_STARTED"="done" 213then 214:# Don't stress test again. 215eliftest -n"$stress" 216then 217iftest"$stress"!= t 218then 219 job_count=$stress 220eliftest -n"$GIT_TEST_STRESS_LOAD" 221then 222 job_count="$GIT_TEST_STRESS_LOAD" 223elif job_count=$(getconf _NPROCESSORS_ONLN 2>/dev/null)&& 224test -n"$job_count" 225then 226 job_count=$((2 * $job_count)) 227else 228 job_count=8 229fi 230 231mkdir-p"$TEST_RESULTS_DIR" 232 stressfail="$TEST_RESULTS_BASE.stress-failed" 233rm-f"$stressfail" 234 235 stress_exit=0 236trap' 237 kill$job_pids2>/dev/null 238 wait 239 stress_exit=1 240 ' TERM INT HUP 241 242 job_pids= 243 job_nr=0 244whiletest$job_nr-lt"$job_count" 245do 246( 247 GIT_TEST_STRESS_STARTED=done 248 GIT_TEST_STRESS_JOB_NR=$job_nr 249export GIT_TEST_STRESS_STARTED GIT_TEST_STRESS_JOB_NR 250 251trap' 252 kill$test_pid2>/dev/null 253 wait 254 exit 1 255 ' TERM INT 256 257 cnt=1 258while!test -e"$stressfail"&& 259{test -z"$stress_limit"|| 260test$cnt-le$stress_limit; } 261do 262$TEST_SHELL_PATH"$0""$@">"$TEST_RESULTS_BASE.stress-$job_nr.out"2>&1& 263 test_pid=$! 264 265ifwait$test_pid 266then 267printf"OK %2d.%d\n"$GIT_TEST_STRESS_JOB_NR $cnt 268else 269echo$GIT_TEST_STRESS_JOB_NR>>"$stressfail" 270printf"FAIL %2d.%d\n"$GIT_TEST_STRESS_JOB_NR $cnt 271fi 272 cnt=$(($cnt + 1)) 273done 274) & 275 job_pids="$job_pids$!" 276 job_nr=$(($job_nr + 1)) 277done 278 279wait 280 281iftest -f"$stressfail" 282then 283 stress_exit=1 284echo"Log(s) of failed test run(s):" 285for failed_job_nr in$(sort -n "$stressfail") 286do 287echo"Contents of '$TEST_RESULTS_BASE.stress-$failed_job_nr.out':" 288cat"$TEST_RESULTS_BASE.stress-$failed_job_nr.out" 289done 290rm-rf"$TRASH_DIRECTORY.stress-failed" 291# Move the last one. 292mv"$TRASH_DIRECTORY.stress-$failed_job_nr""$TRASH_DIRECTORY.stress-failed" 293fi 294 295exit$stress_exit 296fi 297 298# if --tee was passed, write the output not only to the terminal, but 299# additionally to the file test-results/$BASENAME.out, too. 300iftest"$GIT_TEST_TEE_STARTED"="done" 301then 302:# do not redirect again 303eliftest -n"$tee" 304then 305mkdir-p"$TEST_RESULTS_DIR" 306 307# Make this filename available to the sub-process in case it is using 308# --verbose-log. 309 GIT_TEST_TEE_OUTPUT_FILE=$TEST_RESULTS_BASE.out 310export GIT_TEST_TEE_OUTPUT_FILE 311 312# Truncate before calling "tee -a" to get rid of the results 313# from any previous runs. 314>"$GIT_TEST_TEE_OUTPUT_FILE" 315 316(GIT_TEST_TEE_STARTED=done${TEST_SHELL_PATH}"$0""$@"2>&1; 317echo $? >"$TEST_RESULTS_BASE.exit") |tee-a"$GIT_TEST_TEE_OUTPUT_FILE" 318test"$(cat "$TEST_RESULTS_BASE.exit")"=0 319exit 320fi 321 322iftest -n"$trace"&&test -n"$test_untraceable" 323then 324# '-x' tracing requested, but this test script can't be reliably 325# traced, unless it is run with a Bash version supporting 326# BASH_XTRACEFD (introduced in Bash v4.1). 327# 328# Perform this version check _after_ the test script was 329# potentially re-executed with $TEST_SHELL_PATH for '--tee' or 330# '--verbose-log', so the right shell is checked and the 331# warning is issued only once. 332iftest -n"$BASH_VERSION"&&eval' 333 test${BASH_VERSINFO[0]}-gt 4 || { 334 test${BASH_VERSINFO[0]}-eq 4 && 335 test${BASH_VERSINFO[1]}-ge 1 336 } 337 ' 338then 339: Executed by a Bash version supporting BASH_XTRACEFD. Good. 340else 341echo>&2"warning: ignoring -x; '$0' is untraceable without BASH_XTRACEFD" 342 trace= 343fi 344fi 345iftest -n"$trace"&&test -z"$verbose_log" 346then 347 verbose=t 348fi 349 350# For repeatability, reset the environment to known value. 351# TERM is sanitized below, after saving color control sequences. 352LANG=C 353LC_ALL=C 354PAGER=cat 355TZ=UTC 356export LANG LC_ALL PAGER TZ 357EDITOR=: 358 359# GIT_TEST_GETTEXT_POISON should not influence git commands executed 360# during initialization of test-lib and the test repo. Back it up, 361# unset and then restore after initialization is finished. 362iftest -n"$GIT_TEST_GETTEXT_POISON" 363then 364 GIT_TEST_GETTEXT_POISON_ORIG=$GIT_TEST_GETTEXT_POISON 365unset GIT_TEST_GETTEXT_POISON 366fi 367 368# A call to "unset" with no arguments causes at least Solaris 10 369# /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets 370# deriving from the command substitution clustered with the other 371# ones. 372unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH"-e' 373 my @env = keys %ENV; 374 my$ok= join("|", qw( 375 TRACE 376 DEBUG 377 TEST 378 .*_TEST 379 PROVE 380 VALGRIND 381 UNZIP 382 PERF_ 383 CURL_VERBOSE 384 TRACE_CURL 385 )); 386 my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env); 387 print join("\n", @vars); 388') 389unset XDG_CACHE_HOME 390unset XDG_CONFIG_HOME 391unset GITPERLLIB 392GIT_AUTHOR_EMAIL=author@example.com 393GIT_AUTHOR_NAME='A U Thor' 394GIT_COMMITTER_EMAIL=committer@example.com 395GIT_COMMITTER_NAME='C O Mitter' 396GIT_MERGE_VERBOSITY=5 397GIT_MERGE_AUTOEDIT=no 398export GIT_MERGE_VERBOSITY GIT_MERGE_AUTOEDIT 399export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME 400export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME 401export EDITOR 402 403# Tests using GIT_TRACE typically don't want <timestamp> <file>:<line> output 404GIT_TRACE_BARE=1 405export GIT_TRACE_BARE 406 407check_var_migration () { 408# the warnings and hints given from this helper depends 409# on end-user settings, which will disrupt the self-test 410# done on the test framework itself. 411case"$GIT_TEST_FRAMEWORK_SELFTEST"in 412 t)return;; 413esac 414 415 old_name=$1 new_name=$2 416eval"old_isset=\${${old_name}:+isset}" 417eval"new_isset=\${${new_name}:+isset}" 418 419case"$old_isset,$new_isset"in 420 isset,) 421echo>&2"warning:$old_nameis now$new_name" 422echo>&2"hint: set$new_nametoo during the transition period" 423eval"$new_name=\$$old_name" 424;; 425 isset,isset) 426# do this later 427# echo >&2 "warning: $old_name is now $new_name" 428# echo >&2 "hint: remove $old_name" 429;; 430esac 431} 432 433check_var_migration GIT_FSMONITOR_TEST GIT_TEST_FSMONITOR 434check_var_migration TEST_GIT_INDEX_VERSION GIT_TEST_INDEX_VERSION 435check_var_migration GIT_FORCE_PRELOAD_TEST GIT_TEST_PRELOAD_INDEX 436 437# Use specific version of the index file format 438iftest -n"${GIT_TEST_INDEX_VERSION:+isset}" 439then 440 GIT_INDEX_VERSION="$GIT_TEST_INDEX_VERSION" 441export GIT_INDEX_VERSION 442fi 443 444# Add libc MALLOC and MALLOC_PERTURB test 445# only if we are not executing the test with valgrind 446iftest -n"$valgrind"|| 447test -n"$TEST_NO_MALLOC_CHECK" 448then 449 setup_malloc_check () { 450: nothing 451} 452 teardown_malloc_check () { 453: nothing 454} 455else 456 setup_malloc_check () { 457 MALLOC_CHECK_=3 MALLOC_PERTURB_=165 458export MALLOC_CHECK_ MALLOC_PERTURB_ 459} 460 teardown_malloc_check () { 461unset MALLOC_CHECK_ MALLOC_PERTURB_ 462} 463fi 464 465# Protect ourselves from common misconfiguration to export 466# CDPATH into the environment 467unset CDPATH 468 469unset GREP_OPTIONS 470unset UNZIP 471 472case$(echo $GIT_TRACE |tr "[A-Z]" "[a-z]")in 4731|2|true) 474 GIT_TRACE=4 475;; 476esac 477 478# Convenience 479# 480# A regexp to match 5, 35 and 40 hexdigits 481_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' 482_x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05" 483_x40="$_x35$_x05" 484 485# Zero SHA-1 486_z40=0000000000000000000000000000000000000000 487 488OID_REGEX="$_x40" 489ZERO_OID=$_z40 490EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904 491EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 492 493# Line feed 494LF=' 495' 496 497# UTF-8 ZERO WIDTH NON-JOINER, which HFS+ ignores 498# when case-folding filenames 499u200c=$(printf '\342\200\214') 500 501export _x05 _x35 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID OID_REGEX 502 503# Each test should start with something like this, after copyright notices: 504# 505# test_description='Description of this test... 506# This test checks if command xyzzy does the right thing... 507# ' 508# . ./test-lib.sh 509test"x$TERM"!="xdumb"&& ( 510test -t1&& 511tput bold >/dev/null 2>&1&& 512tput setaf 1>/dev/null 2>&1&& 513tput sgr0 >/dev/null 2>&1 514) && 515 color=t 516 517iftest -n"$color" 518then 519# Save the color control sequences now rather than run tput 520# each time say_color() is called. This is done for two 521# reasons: 522# * TERM will be changed to dumb 523# * HOME will be changed to a temporary directory and tput 524# might need to read ~/.terminfo from the original HOME 525# directory to get the control sequences 526# Note: This approach assumes the control sequences don't end 527# in a newline for any terminal of interest (command 528# substitutions strip trailing newlines). Given that most 529# (all?) terminals in common use are related to ECMA-48, this 530# shouldn't be a problem. 531 say_color_error=$(tput bold; tput setaf 1)# bold red 532 say_color_skip=$(tput setaf 4)# blue 533 say_color_warn=$(tput setaf 3)# brown/yellow 534 say_color_pass=$(tput setaf 2)# green 535 say_color_info=$(tput setaf 6)# cyan 536 say_color_reset=$(tput sgr0) 537 say_color_=""# no formatting for normal text 538 say_color () { 539test -z"$1"&&test -n"$quiet"&&return 540eval"say_color_color=\$say_color_$1" 541shift 542printf"%s\\n""$say_color_color$*$say_color_reset" 543} 544else 545 say_color() { 546test -z"$1"&&test -n"$quiet"&&return 547shift 548printf"%s\n""$*" 549} 550fi 551 552TERM=dumb 553export TERM 554 555error () { 556 say_color error "error: $*" 557 GIT_EXIT_OK=t 558exit1 559} 560 561BUG () { 562 error >&7"bug in the test script: $*" 563} 564 565say () { 566 say_color info "$*" 567} 568 569iftest -n"$HARNESS_ACTIVE" 570then 571iftest"$verbose"= t ||test -n"$verbose_only" 572then 573printf'Bail out! %s\n' \ 574'verbose mode forbidden under TAP harness; try --verbose-log' 575exit1 576fi 577fi 578 579test"${test_description}"!=""|| 580error "Test script did not set test_description." 581 582iftest"$help"="t" 583then 584printf'%s\n'"$test_description" 585exit0 586fi 587 588exec5>&1 589exec6<&0 590exec7>&2 591iftest"$verbose_log"="t" 592then 593exec3>>"$GIT_TEST_TEE_OUTPUT_FILE"4>&3 594eliftest"$verbose"="t" 595then 596exec4>&2 3>&1 597else 598exec4>/dev/null 3>/dev/null 599fi 600 601# Send any "-x" output directly to stderr to avoid polluting tests 602# which capture stderr. We can do this unconditionally since it 603# has no effect if tracing isn't turned on. 604# 605# Note that this sets up the trace fd as soon as we assign the variable, so it 606# must come after the creation of descriptor 4 above. Likewise, we must never 607# unset this, as it has the side effect of closing descriptor 4, which we 608# use to show verbose tests to the user. 609# 610# Note also that we don't need or want to export it. The tracing is local to 611# this shell, and we would not want to influence any shells we exec. 612BASH_XTRACEFD=4 613 614test_failure=0 615test_count=0 616test_fixed=0 617test_broken=0 618test_success=0 619 620test_external_has_tap=0 621 622die () { 623 code=$? 624iftest -n"$GIT_EXIT_OK" 625then 626exit$code 627else 628echo>&5"FATAL: Unexpected exit with code$code" 629exit1 630fi 631} 632 633GIT_EXIT_OK= 634trap'die' EXIT 635trap'exit $?' INT TERM HUP 636 637# The user-facing functions are loaded from a separate file so that 638# test_perf subshells can have them too 639. "$TEST_DIRECTORY/test-lib-functions.sh" 640 641# You are not expected to call test_ok_ and test_failure_ directly, use 642# the test_expect_* functions instead. 643 644test_ok_ () { 645iftest -n"$write_junit_xml" 646then 647 write_junit_xml_testcase "$*" 648fi 649 test_success=$(($test_success + 1)) 650 say_color """ok$test_count- $@" 651} 652 653test_failure_ () { 654iftest -n"$write_junit_xml" 655then 656 junit_insert="<failure message=\"not ok$test_count-" 657 junit_insert="$junit_insert$(xml_attr_encode "$1")\">" 658 junit_insert="$junit_insert$(xml_attr_encode \ 659 "$(iftest -n"$GIT_TEST_TEE_OUTPUT_FILE" 660then 661test-tool path-utils skip-n-bytes \ 662"$GIT_TEST_TEE_OUTPUT_FILE"$GIT_TEST_TEE_OFFSET 663else 664printf'%s\n'"$@"|sed1d 665fi)")" 666 junit_insert="$junit_insert</failure>" 667iftest -n"$GIT_TEST_TEE_OUTPUT_FILE" 668then 669 junit_insert="$junit_insert<system-err>$(xml_attr_encode \ 670 "$(cat "$GIT_TEST_TEE_OUTPUT_FILE")")</system-err>" 671fi 672 write_junit_xml_testcase "$1""$junit_insert" 673fi 674 test_failure=$(($test_failure + 1)) 675 say_color error "not ok$test_count-$1" 676shift 677printf'%s\n'"$*"|sed-e's/^/# /' 678test"$immediate"=""|| { GIT_EXIT_OK=t;exit1; } 679} 680 681test_known_broken_ok_ () { 682iftest -n"$write_junit_xml" 683then 684 write_junit_xml_testcase "$* (breakage fixed)" 685fi 686 test_fixed=$(($test_fixed+1)) 687 say_color error "ok$test_count- $@ # TODO known breakage vanished" 688} 689 690test_known_broken_failure_ () { 691iftest -n"$write_junit_xml" 692then 693 write_junit_xml_testcase "$* (known breakage)" 694fi 695 test_broken=$(($test_broken+1)) 696 say_color warn "not ok$test_count- $@ # TODO known breakage" 697} 698 699test_debug () { 700test"$debug"=""||eval"$1" 701} 702 703match_pattern_list () { 704 arg="$1" 705shift 706test -z"$*"&&return1 707for pattern_ 708do 709case"$arg"in 710$pattern_) 711return0 712esac 713done 714return1 715} 716 717match_test_selector_list () { 718 title="$1" 719shift 720 arg="$1" 721shift 722test -z"$1"&&return0 723 724# Both commas and whitespace are accepted as separators. 725 OLDIFS=$IFS 726 IFS=' ,' 727set --$1 728 IFS=$OLDIFS 729 730# If the first selector is negative we include by default. 731 include= 732case"$1"in 733!*) include=t ;; 734esac 735 736for selector 737do 738 orig_selector=$selector 739 740 positive=t 741case"$selector"in 742!*) 743 positive= 744 selector=${selector##?} 745;; 746esac 747 748test -z"$selector"&&continue 749 750case"$selector"in 751*-*) 752ifexpr"z${selector%%-*}":"z[0-9]*[^0-9]">/dev/null 753then 754echo"error:$title: invalid non-numeric in range" \ 755"start: '$orig_selector'">&2 756exit1 757fi 758ifexpr"z${selector#*-}":"z[0-9]*[^0-9]">/dev/null 759then 760echo"error:$title: invalid non-numeric in range" \ 761"end: '$orig_selector'">&2 762exit1 763fi 764;; 765*) 766ifexpr"z$selector":"z[0-9]*[^0-9]">/dev/null 767then 768echo"error:$title: invalid non-numeric in test" \ 769"selector: '$orig_selector'">&2 770exit1 771fi 772esac 773 774# Short cut for "obvious" cases 775test -z"$include"&&test -z"$positive"&&continue 776test -n"$include"&&test -n"$positive"&&continue 777 778case"$selector"in 779-*) 780iftest$arg-le${selector#-} 781then 782 include=$positive 783fi 784;; 785*-) 786iftest$arg-ge${selector%-} 787then 788 include=$positive 789fi 790;; 791*-*) 792iftest${selector%%-*}-le$arg \ 793&&test$arg-le${selector#*-} 794then 795 include=$positive 796fi 797;; 798*) 799iftest$arg-eq$selector 800then 801 include=$positive 802fi 803;; 804esac 805done 806 807test -n"$include" 808} 809 810maybe_teardown_verbose () { 811test -z"$verbose_only"&&return 812exec4>/dev/null 3>/dev/null 813 verbose= 814} 815 816last_verbose=t 817maybe_setup_verbose () { 818test -z"$verbose_only"&&return 819if match_pattern_list $test_count $verbose_only 820then 821exec4>&2 3>&1 822# Emit a delimiting blank line when going from 823# non-verbose to verbose. Within verbose mode the 824# delimiter is printed by test_expect_*. The choice 825# of the initial $last_verbose is such that before 826# test 1, we do not print it. 827test -z"$last_verbose"&&echo>&3"" 828 verbose=t 829else 830exec4>/dev/null 3>/dev/null 831 verbose= 832fi 833 last_verbose=$verbose 834} 835 836maybe_teardown_valgrind () { 837test -z"$GIT_VALGRIND"&&return 838 GIT_VALGRIND_ENABLED= 839} 840 841maybe_setup_valgrind () { 842test -z"$GIT_VALGRIND"&&return 843iftest -z"$valgrind_only" 844then 845 GIT_VALGRIND_ENABLED=t 846return 847fi 848 GIT_VALGRIND_ENABLED= 849if match_pattern_list $test_count $valgrind_only 850then 851 GIT_VALGRIND_ENABLED=t 852fi 853} 854 855want_trace () { 856test"$trace"= t && { 857test"$verbose"= t ||test"$verbose_log"= t 858} 859} 860 861# This is a separate function because some tests use 862# "return" to end a test_expect_success block early 863# (and we want to make sure we run any cleanup like 864# "set +x"). 865test_eval_inner_ () { 866# Do not add anything extra (including LF) after '$*' 867eval" 868 want_trace && set -x 869 $*" 870} 871 872test_eval_ () { 873# If "-x" tracing is in effect, then we want to avoid polluting stderr 874# with non-test commands. But once in "set -x" mode, we cannot prevent 875# the shell from printing the "set +x" to turn it off (nor the saving 876# of $? before that). But we can make sure that the output goes to 877# /dev/null. 878# 879# There are a few subtleties here: 880# 881# - we have to redirect descriptor 4 in addition to 2, to cover 882# BASH_XTRACEFD 883# 884# - the actual eval has to come before the redirection block (since 885# it needs to see descriptor 4 to set up its stderr) 886# 887# - likewise, any error message we print must be outside the block to 888# access descriptor 4 889# 890# - checking $? has to come immediately after the eval, but it must 891# be _inside_ the block to avoid polluting the "set -x" output 892# 893 894 test_eval_inner_ "$@"</dev/null >&3 2>&4 895{ 896 test_eval_ret_=$? 897if want_trace 898then 899set+x 900fi 901}2>/dev/null 4>&2 902 903iftest"$test_eval_ret_"!=0&& want_trace 904then 905 say_color error >&4"error: last command exited with \$?=$test_eval_ret_" 906fi 907return$test_eval_ret_ 908} 909 910test_run_ () { 911 test_cleanup=: 912 expecting_failure=$2 913 914iftest"${GIT_TEST_CHAIN_LINT:-1}"!=0;then 915# turn off tracing for this test-eval, as it simply creates 916# confusing noise in the "-x" output 917 trace_tmp=$trace 918 trace= 919# 117 is magic because it is unlikely to match the exit 920# code of other programs 921if$(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!')|| 922test"OK-117"!="$(test_eval_ "(exit 117)&&$1${LF}${LF}echo OK-\$?"3>&1)" 923 then 924 BUG "broken &&-chain or run-away HERE-DOC:$1" 925 fi 926 trace=$trace_tmp 927 fi 928 929 setup_malloc_check 930 test_eval_ "$1" 931 eval_ret=$? 932 teardown_malloc_check 933 934 if test -z "$immediate" || test$eval_ret= 0 || 935 test -n "$expecting_failure" && test "$test_cleanup" != ":" 936 then 937 setup_malloc_check 938 test_eval_ "$test_cleanup" 939 teardown_malloc_check 940 fi 941 if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE" 942 then 943 echo "" 944 fi 945 return "$eval_ret" 946} 947 948test_start_ () { 949 test_count=$(($test_count+1)) 950 maybe_setup_verbose 951 maybe_setup_valgrind 952 if test -n "$write_junit_xml" 953 then 954 junit_start=$(test-tool date getnanos) 955 fi 956} 957 958test_finish_ () { 959 echo >&3 "" 960 maybe_teardown_valgrind 961 maybe_teardown_verbose 962 if test -n "$GIT_TEST_TEE_OFFSET" 963 then 964 GIT_TEST_TEE_OFFSET=$(test-tool path-utils file-size \ 965 "$GIT_TEST_TEE_OUTPUT_FILE") 966 fi 967} 968 969test_skip () { 970 to_skip= 971 skipped_reason= 972 if match_pattern_list$this_test.$test_count$GIT_SKIP_TESTS 973 then 974 to_skip=t 975 skipped_reason="GIT_SKIP_TESTS" 976 fi 977 if test -z "$to_skip" && test -n "$test_prereq" && 978 ! test_have_prereq "$test_prereq" 979 then 980 to_skip=t 981 982 of_prereq= 983 if test "$missing_prereq" != "$test_prereq" 984 then 985 of_prereq=" of $test_prereq" 986 fi 987 skipped_reason="missing $missing_prereq${of_prereq}" 988 fi 989 if test -z "$to_skip" && test -n "$run_list" && 990 ! match_test_selector_list '--run'$test_count"$run_list" 991 then 992 to_skip=t 993 skipped_reason="--run" 994 fi 995 996 case "$to_skip" in 997 t) 998 if test -n "$write_junit_xml" 999 then1000 message="$(xml_attr_encode "$skipped_reason")"1001 write_junit_xml_testcase "$1" \1002 "<skipped message=\"$message\"/>"1003 fi10041005 say_color skip >&3 "skipping test: $@"1006 say_color skip "ok $test_count# skip $1 ($skipped_reason)"1007: true1008;;1009*)1010 false1011;;1012esac1013}10141015# stub; perf-lib overrides it1016test_at_end_hook_ () {1017:1018}10191020write_junit_xml () {1021case"$1"in1022--truncate)1023>"$junit_xml_path"1024 junit_have_testcase=1025shift1026;;1027esac1028printf'%s\n'"$@">>"$junit_xml_path"1029}10301031xml_attr_encode () {1032printf'%s\n'"$@"|test-tool xml-encode1033}10341035write_junit_xml_testcase () {1036 junit_attrs="name=\"$(xml_attr_encode "$this_test.$test_count $1")\""1037shift1038 junit_attrs="$junit_attrsclassname=\"$this_test\""1039 junit_attrs="$junit_attrstime=\"$(test-tool \1040 date getnanos$junit_start)\""1041 write_junit_xml "$(printf '%s\n' \1042 "<testcase $junit_attrs>" "$@" "</testcase>")"1043 junit_have_testcase=t1044}10451046test_done () {1047 GIT_EXIT_OK=t10481049iftest -n"$write_junit_xml"&&test -n"$junit_xml_path"1050then1051test -n"$junit_have_testcase"|| {1052 junit_start=$(test-tool date getnanos)1053 write_junit_xml_testcase "all tests skipped"1054}10551056# adjust the overall time1057 junit_time=$(test-tool date getnanos $junit_suite_start)1058sed"s/<testsuite [^>]*/& time=\"$junit_time\"/" \1059<"$junit_xml_path">"$junit_xml_path.new"1060mv"$junit_xml_path.new""$junit_xml_path"10611062 write_junit_xml " </testsuite>""</testsuites>"1063fi10641065iftest -z"$HARNESS_ACTIVE"1066then1067mkdir-p"$TEST_RESULTS_DIR"10681069cat>"$TEST_RESULTS_BASE.counts"<<-EOF1070 total$test_count1071 success$test_success1072 fixed$test_fixed1073 broken$test_broken1074 failed$test_failure10751076 EOF1077fi10781079iftest"$test_fixed"!=01080then1081 say_color error "#$test_fixedknown breakage(s) vanished; please update test(s)"1082fi1083iftest"$test_broken"!=01084then1085 say_color warn "# still have$test_brokenknown breakage(s)"1086fi1087iftest"$test_broken"!=0||test"$test_fixed"!=01088then1089 test_remaining=$(( $test_count - $test_broken - $test_fixed ))1090 msg="remaining$test_remainingtest(s)"1091else1092 test_remaining=$test_count1093 msg="$test_counttest(s)"1094fi1095case"$test_failure"in10960)1097iftest$test_external_has_tap-eq01098then1099iftest$test_remaining-gt01100then1101 say_color pass "# passed all$msg"1102fi11031104# Maybe print SKIP message1105test -z"$skip_all"|| skip_all="# SKIP$skip_all"1106case"$test_count"in11070)1108 say "1..$test_count${skip_all:+ $skip_all}"1109;;1110*)1111test -z"$skip_all"||1112 say_color warn "$skip_all"1113 say "1..$test_count"1114;;1115esac1116fi11171118iftest -z"$debug"1119then1120test -d"$TRASH_DIRECTORY"||1121 error "Tests passed but trash directory already removed before test cleanup; aborting"11221123cd"$TRASH_DIRECTORY/.."&&1124rm-fr"$TRASH_DIRECTORY"|| {1125# try again in a bit1126sleep5;1127rm-fr"$TRASH_DIRECTORY"1128} ||1129 error "Tests passed but test cleanup failed; aborting"1130fi1131 test_at_end_hook_11321133exit0;;11341135*)1136iftest$test_external_has_tap-eq01137then1138 say_color error "# failed$test_failureamong$msg"1139 say "1..$test_count"1140fi11411142exit1;;11431144esac1145}11461147iftest -n"$valgrind"1148then1149 make_symlink () {1150test -h"$2"&&1151test"$1"="$(readlink "$2")"|| {1152# be super paranoid1153ifmkdir"$2".lock1154then1155rm-f"$2"&&1156ln-s"$1""$2"&&1157rm-r"$2".lock1158else1159whiletest -d"$2".lock1160do1161 say "Waiting for lock on$2."1162sleep11163done1164fi1165}1166}11671168 make_valgrind_symlink () {1169# handle only executables, unless they are shell libraries that1170# need to be in the exec-path.1171test -x"$1"||1172test"# "="$(test_copy_bytes 2 <"$1")"||1173return;11741175 base=$(basename "$1")1176case"$base"in1177test-*)1178 symlink_target="$GIT_BUILD_DIR/t/helper/$base"1179;;1180*)1181 symlink_target="$GIT_BUILD_DIR/$base"1182;;1183esac1184# do not override scripts1185iftest -x"$symlink_target"&&1186test!-d"$symlink_target"&&1187test"#!"!="$(test_copy_bytes 2 <"$symlink_target")"1188then1189 symlink_target=../valgrind.sh1190fi1191case"$base"in1192*.sh|*.perl)1193 symlink_target=../unprocessed-script1194esac1195# create the link, or replace it if it is out of date1196 make_symlink "$symlink_target""$GIT_VALGRIND/bin/$base"||exit1197}11981199# override all git executables in TEST_DIRECTORY/..1200 GIT_VALGRIND=$TEST_DIRECTORY/valgrind1201mkdir-p"$GIT_VALGRIND"/bin1202forfilein$GIT_BUILD_DIR/git*$GIT_BUILD_DIR/t/helper/test-*1203do1204 make_valgrind_symlink $file1205done1206# special-case the mergetools loadables1207 make_symlink "$GIT_BUILD_DIR"/mergetools "$GIT_VALGRIND/bin/mergetools"1208 OLDIFS=$IFS1209 IFS=:1210for path in$PATH1211do1212ls"$path"/git-*2> /dev/null |1213whilereadfile1214do1215 make_valgrind_symlink "$file"1216done1217done1218 IFS=$OLDIFS1219 PATH=$GIT_VALGRIND/bin:$PATH1220 GIT_EXEC_PATH=$GIT_VALGRIND/bin1221export GIT_VALGRIND1222 GIT_VALGRIND_MODE="$valgrind"1223export GIT_VALGRIND_MODE1224 GIT_VALGRIND_ENABLED=t1225test -n"$valgrind_only"&& GIT_VALGRIND_ENABLED=1226export GIT_VALGRIND_ENABLED1227eliftest -n"$GIT_TEST_INSTALLED"1228then1229 GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path)||1230 error "Cannot run git from$GIT_TEST_INSTALLED."1231 PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR/t/helper:$PATH1232 GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}1233else# normal case, use ../bin-wrappers only unless $with_dashes:1234iftest -n"$no_bin_wrappers"1235then1236 with_dashes=t1237else1238 git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"1239if!test -x"$git_bin_dir/git"1240then1241iftest -z"$with_dashes"1242then1243 say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"1244fi1245 with_dashes=t1246fi1247 PATH="$git_bin_dir:$PATH"1248fi1249 GIT_EXEC_PATH=$GIT_BUILD_DIR1250iftest -n"$with_dashes"1251then1252 PATH="$GIT_BUILD_DIR:$GIT_BUILD_DIR/t/helper:$PATH"1253fi1254fi1255GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt1256GIT_CONFIG_NOSYSTEM=11257GIT_ATTR_NOSYSTEM=11258export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM12591260iftest -z"$GIT_TEST_CMP"1261then1262iftest -n"$GIT_TEST_CMP_USE_COPIED_CONTEXT"1263then1264 GIT_TEST_CMP="$DIFF-c"1265else1266 GIT_TEST_CMP="$DIFF-u"1267fi1268fi12691270GITPERLLIB="$GIT_BUILD_DIR"/perl/build/lib1271export GITPERLLIB1272test -d"$GIT_BUILD_DIR"/templates/blt || {1273 error "You haven't built things yet, have you?"1274}12751276if!test -x"$GIT_BUILD_DIR"/t/helper/test-tool$X1277then1278echo>&2'You need to build test-tool:'1279echo>&2'Run "make t/helper/test-tool" in the source (toplevel) directory'1280exit11281fi12821283# Test repository1284rm-fr"$TRASH_DIRECTORY"|| {1285 GIT_EXIT_OK=t1286echo>&5"FATAL: Cannot prepare test area"1287exit11288}12891290HOME="$TRASH_DIRECTORY"1291GNUPGHOME="$HOME/gnupg-home-not-used"1292export HOME GNUPGHOME12931294iftest -z"$TEST_NO_CREATE_REPO"1295then1296 test_create_repo "$TRASH_DIRECTORY"1297else1298mkdir-p"$TRASH_DIRECTORY"1299fi13001301# Use -P to resolve symlinks in our working directory so that the cwd1302# in subprocesses like git equals our $PWD (for pathname comparisons).1303cd -P"$TRASH_DIRECTORY"||exit113041305this_test=${0##*/}1306this_test=${this_test%%-*}1307if match_pattern_list "$this_test"$GIT_SKIP_TESTS1308then1309 say_color info >&3"skipping test$this_testaltogether"1310 skip_all="skip all tests in$this_test"1311 test_done1312fi13131314iftest -n"$write_junit_xml"1315then1316 junit_xml_dir="$TEST_OUTPUT_DIRECTORY/out"1317mkdir-p"$junit_xml_dir"1318 junit_xml_base=${0##*/}1319 junit_xml_path="$junit_xml_dir/TEST-${junit_xml_base%.sh}.xml"1320 junit_attrs="name=\"${junit_xml_base%.sh}\""1321 junit_attrs="$junit_attrstimestamp=\"$(TZ=UTC \1322 date +%Y-%m-%dT%H:%M:%S)\""1323 write_junit_xml --truncate"<testsuites>"" <testsuite$junit_attrs>"1324 junit_suite_start=$(test-tool date getnanos)1325iftest -n"$GIT_TEST_TEE_OUTPUT_FILE"1326then1327 GIT_TEST_TEE_OFFSET=01328fi1329fi13301331# Provide an implementation of the 'yes' utility1332yes() {1333iftest$#=01334then1335 y=y1336else1337 y="$*"1338fi13391340 i=01341whiletest$i-lt991342do1343echo"$y"1344 i=$(($i+1))1345done1346}13471348# Fix some commands on Windows1349uname_s=$(uname -s)1350case$uname_sin1351*MINGW*)1352# Windows has its own (incompatible) sort and find1353sort() {1354/usr/bin/sort"$@"1355}1356find() {1357/usr/bin/find"$@"1358}1359# git sees Windows-style pwd1360pwd() {1361builtin pwd -W1362}1363# no POSIX permissions1364# backslashes in pathspec are converted to '/'1365# exec does not inherit the PID1366 test_set_prereq MINGW1367 test_set_prereq NATIVE_CRLF1368 test_set_prereq SED_STRIPS_CR1369 test_set_prereq GREP_STRIPS_CR1370 GIT_TEST_CMP=mingw_test_cmp1371;;1372*CYGWIN*)1373 test_set_prereq POSIXPERM1374 test_set_prereq EXECKEEPSPID1375 test_set_prereq CYGWIN1376 test_set_prereq SED_STRIPS_CR1377 test_set_prereq GREP_STRIPS_CR1378;;1379*)1380 test_set_prereq POSIXPERM1381 test_set_prereq BSLASHPSPEC1382 test_set_prereq EXECKEEPSPID1383;;1384esac13851386( COLUMNS=1&&test$COLUMNS=1) && test_set_prereq COLUMNS_CAN_BE_11387test -z"$NO_PERL"&& test_set_prereq PERL1388test -z"$NO_PTHREADS"&& test_set_prereq PTHREADS1389test -z"$NO_PYTHON"&& test_set_prereq PYTHON1390test -n"$USE_LIBPCRE1$USE_LIBPCRE2"&& test_set_prereq PCRE1391test -n"$USE_LIBPCRE1"&& test_set_prereq LIBPCRE11392test -n"$USE_LIBPCRE2"&& test_set_prereq LIBPCRE21393test -z"$NO_GETTEXT"&& test_set_prereq GETTEXT13941395iftest -n"$GIT_TEST_GETTEXT_POISON_ORIG"1396then1397 GIT_TEST_GETTEXT_POISON=$GIT_TEST_GETTEXT_POISON_ORIG1398unset GIT_TEST_GETTEXT_POISON_ORIG1399fi14001401# Can we rely on git's output in the C locale?1402iftest -z"$GIT_TEST_GETTEXT_POISON"1403then1404 test_set_prereq C_LOCALE_OUTPUT1405fi14061407iftest -z"$GIT_TEST_CHECK_CACHE_TREE"1408then1409 GIT_TEST_CHECK_CACHE_TREE=true1410export GIT_TEST_CHECK_CACHE_TREE1411fi14121413test_lazy_prereq PIPE '1414 # test whether the filesystem supports FIFOs1415 test_have_prereq !MINGW,!CYGWIN &&1416 rm -f testfifo && mkfifo testfifo1417'14181419test_lazy_prereq SYMLINKS '1420 # test whether the filesystem supports symbolic links1421 ln -s x y && test -h y1422'14231424test_lazy_prereq FILEMODE '1425 test "$(git config --bool core.filemode)" = true1426'14271428test_lazy_prereq CASE_INSENSITIVE_FS '1429 echo good >CamelCase &&1430 echo bad >camelcase &&1431 test "$(cat CamelCase)" != good1432'14331434test_lazy_prereq FUNNYNAMES '1435 test_have_prereq !MINGW &&1436 touch -- \1437 "FUNNYNAMES tab embedded" \1438 "FUNNYNAMES\"quote embedded\"" \1439 "FUNNYNAMES newline1440embedded" 2>/dev/null &&1441 rm -- \1442 "FUNNYNAMES tab embedded" \1443 "FUNNYNAMES\"quote embedded\"" \1444 "FUNNYNAMES newline1445embedded" 2>/dev/null1446'14471448test_lazy_prereq UTF8_NFD_TO_NFC '1449 # check whether FS converts nfd unicode to nfc1450 auml=$(printf "\303\244")1451 aumlcdiar=$(printf "\141\314\210")1452 >"$auml" &&1453 test -f "$aumlcdiar"1454'14551456test_lazy_prereq AUTOIDENT '1457 sane_unset GIT_AUTHOR_NAME &&1458 sane_unset GIT_AUTHOR_EMAIL &&1459 git var GIT_AUTHOR_IDENT1460'14611462test_lazy_prereq EXPENSIVE '1463 test -n "$GIT_TEST_LONG"1464'14651466test_lazy_prereq EXPENSIVE_ON_WINDOWS '1467 test_have_prereq EXPENSIVE || test_have_prereq !MINGW,!CYGWIN1468'14691470test_lazy_prereq USR_BIN_TIME '1471 test -x /usr/bin/time1472'14731474test_lazy_prereq NOT_ROOT '1475 uid=$(id -u)&&1476 test "$uid" != 01477'14781479test_lazy_prereq JGIT '1480 type jgit1481'14821483# SANITY is about "can you correctly predict what the filesystem would1484# do by only looking at the permission bits of the files and1485# directories?" A typical example of !SANITY is running the test1486# suite as root, where a test may expect "chmod -r file && cat file"1487# to fail because file is supposed to be unreadable after a successful1488# chmod. In an environment (i.e. combination of what filesystem is1489# being used and who is running the tests) that lacks SANITY, you may1490# be able to delete or create a file when the containing directory1491# doesn't have write permissions, or access a file even if the1492# containing directory doesn't have read or execute permissions.14931494test_lazy_prereq SANITY '1495 mkdir SANETESTD.1 SANETESTD.2 &&14961497 chmod +w SANETESTD.1 SANETESTD.2 &&1498 >SANETESTD.1/x 2>SANETESTD.2/x &&1499 chmod -w SANETESTD.1 &&1500 chmod -r SANETESTD.1/x &&1501 chmod -rx SANETESTD.2 ||1502 BUG "cannot prepare SANETESTD"15031504 ! test -r SANETESTD.1/x &&1505 ! rm SANETESTD.1/x && ! test -f SANETESTD.2/x1506 status=$?15071508 chmod +rwx SANETESTD.1 SANETESTD.2 &&1509 rm -rf SANETESTD.1 SANETESTD.2 ||1510 BUG "cannot clean SANETESTD"1511 return$status1512'15131514test FreeBSD !=$uname_s|| GIT_UNZIP=${GIT_UNZIP:-/usr/local/bin/unzip}1515GIT_UNZIP=${GIT_UNZIP:-unzip}1516test_lazy_prereq UNZIP '1517 "$GIT_UNZIP" -v1518 test $? -ne 1271519'15201521run_with_limited_cmdline () {1522(ulimit -s128&&"$@")1523}15241525test_lazy_prereq CMDLINE_LIMIT '1526 test_have_prereq !MINGW,!CYGWIN &&1527 run_with_limited_cmdline true1528'15291530run_with_limited_stack () {1531(ulimit -s128&&"$@")1532}15331534test_lazy_prereq ULIMIT_STACK_SIZE '1535 test_have_prereq !MINGW,!CYGWIN &&1536 run_with_limited_stack true1537'15381539build_option () {1540 git version --build-options|1541sed-ne"s/^$1: //p"1542}15431544test_lazy_prereq LONG_IS_64BIT '1545 test 8 -le "$(build_option sizeof-long)"1546'15471548test_lazy_prereq TIME_IS_64BIT 'test-tool date is64bit'1549test_lazy_prereq TIME_T_IS_64BIT 'test-tool date time_t-is64bit'15501551test_lazy_prereq CURL '1552 curl --version1553'15541555# SHA1 is a test if the hash algorithm in use is SHA-1. This is both for tests1556# which will not work with other hash algorithms and tests that work but don't1557# test anything meaningful (e.g. special values which cause short collisions).1558test_lazy_prereq SHA1 '1559 test$(git hash-object /dev/null)= e69de29bb2d1d6434b8b29ae775ad8c2e48c53911560'15611562test_lazy_prereq REBASE_P '1563 test -z "$GIT_TEST_SKIP_REBASE_P"1564'