3 #==================================================================================
4 # Copyright (c) 2019 Nokia
5 # Copyright (c) 2018-2019 AT&T Intellectual Property.
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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 #==================================================================================
22 # Mnemonic: run_all_tests.ksh
23 # Abstract: This should allow one stop shopping to run all tests as
24 # follows some are explicit, some are implied (e.g. if nng
25 # doesn't build correctly RMr won't build):
27 # - complete build of RMr code and generation of a .deb with
30 # - complete build of Nanomsg and NNG
32 # - complete execution of the unit test script
35 # - code is cloned, and the PWD is the top level repo directory
36 # - running in a container such that 'make install' can be
37 # executed to install RMr and NNG/Nano libraires in /usr/local
38 # - needed utilities (cmake, make, gcc, ksh) are installed
41 # Author: E. Scott Daniels
42 # -------------------------------------------------------------------------
44 # cat the file if error or verbose
46 if (( $1 > 0 || verbose ))
58 # if $1 (state) is not 0, write message ($2) and abort
59 function abort_on_err {
62 echo "$(date) [FAIL] $2"
72 refresh=1 # use -R to turn off a git pull before we start
86 log_it "[INFO] refreshing RMr code base with git pull"
92 err_cat $rc /tmp/git.log
93 abort_on_err $rc "unable to refresh RMr code base"
96 log_it "[INFO] build starts"
97 # build RMr (and nano/nng)
102 cmake .. -DBUILD_DOC=1
103 make package # build RMr, then put in the .deb
104 ) >/tmp/build.log 2>&1 # capture the reams of output and show only on error
106 err_cat $rc /tmp/build.log
107 abort_on_err $rc "unable to setup cmake or build and install"
109 log_it "[OK] Build successful"
111 log_it "[INFO] validating .deb"
116 if whence dpkg >/dev/null 2>&1
120 log_it "[INFO] Deb installation check skipped. dpkg does not exist; trying make install"
123 ) >/tmp/dpkg.log 2>&1
125 err_cat $rc /tmp/dpkg.log
126 abort_on_err $rc "unable to install from .deb"
128 log_it "[OK] Deb installation successful"
131 export LD_LIBRARY_PATH=/usr/local/lib
132 export C_INCLUDE_PATH=../.build/include # must reference nano/nng from the build tree
134 log_it "[INFO] unit testing starts"
141 ) >/tmp/utest.log 2>&1
143 err_cat $rc /tmp/utest.log
144 abort_on_err $rc "unit tests failed"
145 log_it "[OK] unit testing passes"
148 log_it "[PASS] all testing successful"