Welcome to mirror list, hosted at ThFree Co, Russian Federation.

RunnerTemplate.Unix.txt « Tools-Override - github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 11177c3ef8cf4af7a151742b0a8434423a1eebe0 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash

export RUNTIME_PATH=$1
export EXECUTION_DIR=$(dirname "$0")

function print_info_from_core_file {
  local core_file_name=$1
  local executable_name=$2

  if ! [ -e $executable_name ]; then
    echo "Unable to find executable $executable_name"
    return
  elif ! [ -e $core_file_name ]; then
    echo "Unable to find core file $core_file_name"
    return
  fi

  # Check for the existence of GDB on the path
  hash gdb 2>/dev/null || { echo >&2 "GDB was not found. Unable to print core file."; return; }

  echo "Printing info from core file $core_file_name"

  # Open the dump in GDB and print the stack from each thread. We can add more
  # commands here if desired.
  gdb --batch -ex "thread apply all bt full" -ex "quit" $executable_name $core_file_name
}

function copy_core_file_to_temp_location {
  local core_file_name=$1

  local storage_location="/tmp/coredumps"

  # Create the directory (this shouldn't fail even if it already exists).
  mkdir -p $storage_location

  # Only copy the file over if the directory is empty. Otherwise, do nothing.
  if [ ! "$(ls -A $storage_location)" ]; then 
    echo "Copying core file $core_file_name to $storage_location"
    cp $core_file_name $storage_location
  fi
}

if [ "$RUNTIME_PATH" == "" ]
then
echo error: RUNTIME_PATH is not defined.  Usage: $0 RUNTIME_PATH
exit -1
fi
echo Using $RUNTIME_DIR as the test runtime folder.

# ========================= BEGIN Core File Setup ============================
if [ "$(uname -s)" == "Darwin" ]; then
  # On OS X, we will enable core dump generation only if there are no core 
  # files already in /cores/ at this point. This is being done to prevent
  # inadvertently flooding the CI machines with dumps.
  if [ ! "$(ls -A /cores)" ]; then 
    ulimit -c unlimited
  fi
elif [ "$(uname -s)" == "Linux" ]; then
  # On Linux, we'll enable core file generation unconditionally, and if a dump
  # is generated, we will print some useful information from it and delete the
  # dump immediately.

  if [ -e /proc/self/coredump_filter ]; then
      # Include memory in private and shared file-backed mappings in the dump.
      # This ensures that we can see disassembly from our shared libraries when
      # inspecting the contents of the dump. See 'man core' for details.
      echo 0x3F > /proc/self/coredump_filter
  fi

  ulimit -c unlimited
fi
# ========================= END Core File Setup ==============================

# ========================= BEGIN Test Execution =============================
echo Running tests... Start time: $(date +"%T")
echo Commands:
[[TestRunCommandsEcho]]
pushd $EXECUTION_DIR
[[TestRunCommands]]
test_exitcode=$?
popd
echo Finished running tests.  End time=$(date +"%T").  Return value was $test_exitcode
# ========================= END Test Execution ===============================
# ======================= BEGIN Core File Inspection =========================
if [ "$(uname -s)" == "Linux" ]; then
  # Depending on distro/configuration, the core files may either be named "core"
  # or "core.<PID>" by default. We read /proc/sys/kernel/core_uses_pid to 
  # determine which it is.
  core_name_uses_pid=0
  if [ -e /proc/sys/kernel/core_uses_pid ] && [ "1" == $(cat /proc/sys/kernel/core_uses_pid) ]; then
    core_name_uses_pid=1
  fi

  if [ $core_name_uses_pid == "1" ]; then
    # We don't know what the PID of the process was, so let's look at all core
    # files whose name matches core.NUMBER
    for f in core.*; do
      [[ $f =~ core.[0-9]+ ]] && print_info_from_core_file "$f" "corerun" && copy_core_file_to_temp_location "$f" && rm "$f"
    done
  elif [ -f core ]; then
    print_info_from_core_file "core" "corerun"
    copy_core_file_to_temp_location "core"
    rm "core"
  fi
fi
# ======================== END Core File Inspection ==========================
exit $test_exitcode