summaryrefslogtreecommitdiff
path: root/src/pal/tools/preptests.sh
blob: 704f8696258fe53dabc3f8c646525763204505e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# PrepTests.sh
# Initializes our test running environment by setting environment variables appropriately. Already set variables
# are not overwritten.  This is intended for use on unix.
#
# Created 10/28/2014 - mmitche

ExecPrepTestsCore()
{
    unset -f ExecPrepTestsCore

    echo
    echo Preparing this window to run tests
    echo Setting up Exernal Environment Variables
    echo _TGTCPU - Target CPU
    echo BVT_ROOT - Root of tests to run
    echo CORE_RUN - Test host
    echo CORE_ROOT - Root of CLR drop.
    echo
    
    # Set $_TGTCPU based on the processor arch.  In bash on an x64 linux machine, that will show up as x86_x64.
    # If so, then set to AMD64.  Otherwise I386.
    if ! test $_TGTCPU
    then
      export _TGTCPU=`arch`
      if test $_TGTCPU = "x86_x64"
      then
        export _TGTCPU="AMD64"
      else
        export _TGTCPU="i386"
      fi
    fi
    
    # Set $BVT_ROOT based on current directory
    if ! test $BVT_ROOT
    then
      export BVT_ROOT=$PWD
    fi
    
    # Set $CORE_RUN based on current directory
    if ! test $CORE_RUN
    then
      if test -e $BVT_ROOT/Hosting/CoreClr/Activation/Host/TestHost.exe
      then  
        export CORE_RUN=$BVT_ROOT/Hosting/CoreClr/Activation/Host/TestHost.exe
      else
        echo !!!ERROR: $BVT_ROOT/Hosting/CoreClr/Activation/Host/TestHost.exe does not exist. CORE_RUN not set.
        return 1
      fi
    fi
    
    # Set $CORE_ROOT base to $PWD unless otherwise set.
    if ! test "$CORE_ROOT"
    then
      echo Warning. CORE_ROOT is not set at the moment.  Setting it to $PWD
      export CORE_ROOT=$PWD
    fi
    
    # Report the current state of the environment
    echo _TGCPU is set to: $_TGTCPU
    echo BVT_ROOT is set to: $BVT_ROOT
    echo CORE_ROOT is set to: $CORE_ROOT
    echo CORE_RUN is set to $CORE_RUN
    echo

    return 0
}

# This is explicitly so that we can RETURN and not exit this script.
ExecPrepTestsCore $*