Fix potential nil ptr seg fault and CI test issue
[ric-plt/lib/rmr.git] / test / app_test / rebuild.sh
1 #!/usr/bin/env ksh
2 # vim: ts=4 sw=4 noet :
3 #==================================================================================
4 #    Copyright (c) 2019 Nokia
5 #    Copyright (c) 2018-2019 AT&T Intellectual Property.
6 #
7 #   Licensed under the Apache License, Version 2.0 (the "License");
8 #   you may not use this file except in compliance with the License.
9 #   You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #   Unless required by applicable law or agreed to in writing, software
14 #   distributed under the License is distributed on an "AS IS" BASIS,
15 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #   See the License for the specific language governing permissions and
17 #   limitations under the License.
18 #==================================================================================
19 #
20
21 # ---------------------------------------------------------------------------------
22 #       Mnemonic:       rebuild.ksh
23 #       Abstract:       This is a simple script that will cause RMR to be rebuilt. It
24 #                               may be invoked by any of the run_* scripts in this directory.
25 #
26 #                               NOTE:
27 #                               The build path is echod onto stdout so that the caller is able
28 #                               to reference build items for compile/linking. All other communication
29 #                               should be directed to stderr.
30 #
31 #       Date:           24 April 2019
32 #       Author:         E. Scott Daniels
33 # ---------------------------------------------------------------------------------
34
35
36 parent=${PWD%/*}                                        # allow us to step up gracefully
37 gparent=${parent%/*}
38 build_path=${BUILD_PATH:-${gparent}/.build}     # where we should build; .build by default
39
40 echo "$(date) build starts" >&2
41 (
42         set -e
43         mkdir -p $build_path
44         cd $gparent
45         if [[ $1 != "nopull" ]]                         # pull by default, but for local dev testing this needs to be avoided
46         then
47                 git pull                                                # get the up to date code so if run from an old image it's a good test
48         fi
49         cd $build_path
50         make package install
51 ) >/tmp/PID$$.log
52 if (( $? != 0 ))
53 then
54         cat /tmp/PID$$>log
55         echo "$(date) build failed" >&2
56         exit 1
57 fi
58
59 echo "$(date) build completed" >&2
60 echo "$build_path"
61