Print this page
11838 secflag tests are racy

Split Close
Expand all
Collapse all
          --- old/usr/src/test/os-tests/tests/secflags/secflags_core.sh
          +++ new/usr/src/test/os-tests/tests/secflags/secflags_core.sh
↓ open down ↓ 5 lines elided ↑ open up ↑
   6    6  # You may only use this file in accordance with the terms of version
   7    7  # 1.0 of the CDDL.
   8    8  #
   9    9  # A full copy of the text of the CDDL should have accompanied this
  10   10  # source.  A copy of the CDDL is also available via the Internet at
  11   11  # http://www.illumos.org/license/CDDL.
  12   12  #
  13   13  
  14   14  #
  15   15  # Copyright 2015, Richard Lowe.
       16 +# Copyright 2019 Joyent, Inc.
  16   17  #
  17   18  
  18   19  mkdir /tmp/secflags-test.$$
  19   20  cd /tmp/secflags-test.$$
  20   21  
  21   22  /usr/bin/psecflags -s aslr -e sleep 100000 &
  22   23  pid=$!
  23      -coreadm -p core $pid # We need to be able to reliably find the core
       24 +# Make sure we generate a kernel core we can find
       25 +coreadm -p core $pid
       26 +enabled=$(/usr/bin/svcprop -p config_params/process_enabled coreadm)
       27 +coreadm_restore=""
       28 +if [[ "$enabled" = "false" ]]; then
       29 +    coreadm_restore="/usr/bin/coreadm -d process"
       30 +    coreadm -e process
       31 +fi
  24   32  
  25   33  cleanup() {
  26   34      kill $pid >/dev/null 2>&1
  27   35      cd /
  28   36      rm -fr /tmp/secflags-test.$$
       37 +
       38 +    $coreadm_restore
  29   39  }
  30   40  
  31   41  trap cleanup EXIT
  32   42  
       43 +sleep 1
  33   44  ## gcore-produced core
  34   45  gcore $pid >/dev/null
  35   46  
  36   47  cat > gcore-expected.$$ <<EOF
  37   48  core 'core.$pid' of $pid:       sleep 100000
  38   49          E:      aslr
  39   50          I:      aslr
  40   51  EOF
  41   52  
  42   53  /usr/bin/psecflags core.${pid} | grep -v '[LU]:' > gcore-output.$$
  43   54  
  44   55  if ! diff -u gcore-expected.$$ gcore-output.$$; then
       56 +    $coreadm_restore
  45   57      exit 1;
  46   58  fi
  47   59  
  48   60  ## kernel-produced core
  49   61  kill -SEGV $pid
  50   62  wait $pid >/dev/null 2>&1
       63 +$coreadm_restore
  51   64  
  52   65  cat > core-expected.$$ <<EOF
  53   66  core 'core' of $pid:    sleep 100000
  54   67          E:      aslr
  55   68          I:      aslr
  56   69  EOF
  57   70  
  58   71  /usr/bin/psecflags core | grep -v '[LU]:' > core-output.$$
  59   72  
  60   73  if ! diff -u core-expected.$$ core-output.$$; then
  61   74      exit 1;
  62   75  fi
  63   76  
  64   77  exit 0
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX