Lott, Christopher (cl778h) | b23d04b | 2020-02-13 09:41:21 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | ############################################################################## |
| 3 | # |
| 4 | # Copyright (c) 2020 AT&T Intellectual Property. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | ############################################################################## |
| 19 | |
| 20 | # Installs libraries and builds E2 manager |
| 21 | # Prerequisites: |
| 22 | # Debian distro; e.g., Ubuntu |
Lott, Christopher (cl778h) | cfc3742 | 2020-03-16 08:41:05 -0400 | [diff] [blame] | 23 | # NNG shared library |
| 24 | # golang (go); tested with version 1.12 |
Lott, Christopher (cl778h) | b23d04b | 2020-02-13 09:41:21 -0500 | [diff] [blame] | 25 | # current working directory is E2Manager |
| 26 | # running with sudo privs, which is default in Docker |
| 27 | |
Lott, Christopher (cl778h) | b23d04b | 2020-02-13 09:41:21 -0500 | [diff] [blame] | 28 | # Stop at first error and be verbose |
| 29 | set -eux |
| 30 | |
| 31 | echo "--> e2mgr-build-ubuntu.sh" |
| 32 | |
Lott, Christopher (cl778h) | b23d04b | 2020-02-13 09:41:21 -0500 | [diff] [blame] | 33 | # Install RMR from deb packages at packagecloud.io |
ss412g | a561a01 | 2020-04-28 15:40:31 +0300 | [diff] [blame] | 34 | rmr=rmr_4.0.2_amd64.deb |
idanshal | 80f69b6 | 2020-04-23 12:32:55 +0300 | [diff] [blame] | 35 | wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/$rmr/download.deb |
Lott, Christopher (cl778h) | cfc3742 | 2020-03-16 08:41:05 -0400 | [diff] [blame] | 36 | sudo dpkg -i $rmr |
Lott, Christopher (cl778h) | b23d04b | 2020-02-13 09:41:21 -0500 | [diff] [blame] | 37 | rm $rmr |
ss412g | a561a01 | 2020-04-28 15:40:31 +0300 | [diff] [blame] | 38 | rmrdev=rmr-dev_4.0.2_amd64.deb |
idanshal | 80f69b6 | 2020-04-23 12:32:55 +0300 | [diff] [blame] | 39 | wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/$rmrdev/download.deb |
Lott, Christopher (cl778h) | cfc3742 | 2020-03-16 08:41:05 -0400 | [diff] [blame] | 40 | sudo dpkg -i $rmrdev |
Lott, Christopher (cl778h) | b23d04b | 2020-02-13 09:41:21 -0500 | [diff] [blame] | 41 | rm $rmrdev |
| 42 | |
| 43 | # required to find nng and rmr libs |
| 44 | export LD_LIBRARY_PATH=/usr/local/lib |
| 45 | |
| 46 | # go installs tools like go-acc to $HOME/go/bin |
| 47 | # ubuntu minion path lacks go |
| 48 | export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin |
| 49 | |
| 50 | # install the go coverage tool helper |
| 51 | go get -v github.com/ory/go-acc |
| 52 | |
| 53 | cd 3rdparty/asn1codec \ |
ss412g | 999fe1f | 2020-03-22 21:04:31 +0200 | [diff] [blame] | 54 | && make clobber \ |
Lott, Christopher (cl778h) | b23d04b | 2020-02-13 09:41:21 -0500 | [diff] [blame] | 55 | && make \ |
| 56 | && cd ../.. |
| 57 | |
| 58 | go build -v app/main.go |
| 59 | |
| 60 | # Execute UT and measure coverage |
Lott, Christopher (cl778h) | cfc3742 | 2020-03-16 08:41:05 -0400 | [diff] [blame] | 61 | # cgocheck=2 enables expensive checks that should not miss any errors, |
| 62 | # but will cause your program to run slower. |
| 63 | # clobberfree=1 causes the garbage collector to clobber the memory content |
| 64 | # of an object with bad content when it frees the object. |
| 65 | # gcstoptheworld=1 disables concurrent garbage collection, making every |
| 66 | # garbage collection a stop-the-world event. |
| 67 | # Setting gcstoptheworld=2 also disables concurrent sweeping after the |
| 68 | # garbage collection finishes. |
| 69 | # Setting allocfreetrace=1 causes every allocation to be profiled and a |
| 70 | # stack trace printed on each object's allocation and free. |
Lott, Christopher (cl778h) | b23d04b | 2020-02-13 09:41:21 -0500 | [diff] [blame] | 71 | export GODEBUG=cgocheck=2,clobberfree=1,gcstoptheworld=2,allocfreetrace=0 |
Lott, Christopher (cl778h) | b23d04b | 2020-02-13 09:41:21 -0500 | [diff] [blame] | 72 | # Static route table is provided in git repo |
| 73 | export RMR_SEED_RT=$(pwd)/router_test.txt |
| 74 | # writes to coverage.txt by default |
| 75 | # SonarCloud accepts the text format |
| 76 | go-acc $(go list ./... | grep -vE '(/mocks|/tests|/e2managererrors|/enums)' ) |
| 77 | |
Lott, Christopher (cl778h) | cfc3742 | 2020-03-16 08:41:05 -0400 | [diff] [blame] | 78 | # TODO: drop rewrite of path prefix when SonarScanner is extended |
Lott, Christopher (cl778h) | b23d04b | 2020-02-13 09:41:21 -0500 | [diff] [blame] | 79 | # rewrite the module name to a directory name in the coverage report |
| 80 | # https://jira.sonarsource.com/browse/SONARSLANG-450 |
| 81 | sed -i -e 's/^e2mgr/E2Manager/' coverage.txt |
| 82 | |
| 83 | echo "--> e2mgr-build-ubuntu.sh ends" |