Salome HOME
0bb53bc683811b83708abb9682c147cc185eb964
[modules/kernel.git] / src / Launcher / Test / test_stress.sh
1 #! /bin/bash
2 # Copyright (C) 2018-2019  CEA/DEN, EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 # This test launches in parallel a great number of instances of a usual use case
21 WORKDIR=`mktemp -d`
22 echo WORKDIR: $WORKDIR
23 cat > $WORKDIR/command.sh <<< 'echo "OK" > result.txt'
24 chmod 755 $WORKDIR/command.sh
25 pid_launcher=''
26 for i in {1..500}
27 do
28   python launcher_use_case.py $WORKDIR 2> $WORKDIR/log$i.err &
29   pid_launcher=$pid_launcher" "$!
30 done
31 exit_code=0
32 for i in "$pid_launcher"
33 do
34   wait $i
35   ret=$?
36   if [ $ret -ne "0" ]
37   then
38      echo "Error detected!"
39      exit_code=1
40   fi
41 done
42 # list of error files not empty
43 ls -l $WORKDIR/*.err | awk '{if ($5 != "0") print $0}'
44 exit $exit_code