CI: Add silent cmake SonarCloud scan
[ric-plt/lib/rmr.git] / test / vet_logging.sh
1 #!/usr/bin/env bash
2
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 #       Mnemonic:       vet_logging.sh
21 #       Abstract:       Drive the loging test and count the messages we see, and look for
22 #                               messages we don't expect.  Exit good (0)  if all looks good.
23 #       Date:           16 September 2020
24 #       Author:         E. Scott Daniels
25 #-----------------------------------------------------------------------------------
26
27 echo "<INFO> log message vetting starts..."
28
29 expect=14                       # number of good "should be written" messages expected
30
31 ./logging_test >/tmp/PID$$.out 2>&1
32 g=$( grep -c "should be written" /tmp/PID$$.out )
33 b=$( grep -c "should not be written" /tmp/PID$$.out )
34
35 errors=0
36 if (( b != 0 ))
37 then
38         echo "<FAIL> logging test produced $b unexpected to stderr"
39         errors=1
40 else
41         echo "<INFO> no unexpected messages were found"
42 fi
43
44 if (( g != expect ))
45 then
46         echo "<FAIL> logging test did not produce the expected number of messages to stderr"
47         echo "<INFO> expected $expect, saw $g"
48         errors=1
49 else
50         echo "<INFO> logging test produced good message count ($g)"
51 fi
52
53 if (( errors ))
54 then
55         ls -al /tmp/PID$$.out
56         echo "<INFO> --- test output ----"
57         cat /tmp/PID$$.out
58         echo "<INFO> ---------------------"
59 else
60         echo "<PASS> logging tests pass message output validation"
61 fi
62
63 rm -f /tmp/PID$$.*
64 exit $(( !! errors ))