blob: 693ca847d17a1c2ddca3f687eef4a5a0003f32a6 [file] [log] [blame]
Lott, Christopher (cl778h)b23d04b2020-02-13 09:41:21 -05001#!/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
23# cmake (version?)
24# gcc/g++ compiler (version?)
25# golang (go), tested with version 1.12.0
26# current working directory is E2Manager
27# running with sudo privs, which is default in Docker
28
29# TODO:
30# 1) drop go from $PATH when build minion is extended
31# 2) drop rewrite of path prefix when SonarScanner is extended
32
33# Stop at first error and be verbose
34set -eux
35
36echo "--> e2mgr-build-ubuntu.sh"
37
38# Build and install NNG, which requires ninja
39apt-get install ninja-build
40git clone https://github.com/nanomsg/nng.git \
41 && cd nng \
42 && git checkout e618abf8f3db2a94269a79c8901a51148d48fcc2 \
43 && mkdir build \
44 && cd build \
45 && cmake -DBUILD_SHARED_LIBS=1 -G Ninja .. \
46 && ninja \
47 && ninja install \
48 && cd ../.. \
49 && rm -r nng
50
51# Install RMR from deb packages at packagecloud.io
52rmr=rmr_1.13.0_amd64.deb
53wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/$rmr/download.deb
54dpkg -i $rmr
55rm $rmr
56rmrdev=rmr-dev_1.13.0_amd64.deb
57wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/$rmrdev/download.deb
58dpkg -i $rmrdev
59rm $rmrdev
60
61# required to find nng and rmr libs
62export LD_LIBRARY_PATH=/usr/local/lib
63
64# go installs tools like go-acc to $HOME/go/bin
65# ubuntu minion path lacks go
66export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
67
68# install the go coverage tool helper
69go get -v github.com/ory/go-acc
70
71cd 3rdparty/asn1codec \
72 && make \
73 && cd ../..
74
75go build -v app/main.go
76
77# Execute UT and measure coverage
78# cgocheck=2 enables expensive checks that should not miss any errors, but will cause your program to run slower.
79# clobberfree=1 causes the garbage collector to clobber the memory content of an object with bad content when it frees the object.
80# gcstoptheworld=1 disables concurrent garbage collection, making every garbage collection a stop-the-world event.
81# Setting gcstoptheworld=2 also disables concurrent sweeping after the garbage collection finishes.
82# Setting allocfreetrace=1 causes every allocation to be profiled and a stack trace printed on each object's allocation and free.
83export GODEBUG=cgocheck=2,clobberfree=1,gcstoptheworld=2,allocfreetrace=0
84export RIC_ID="bbbccc-abcd0e/20"
85# Static route table is provided in git repo
86export RMR_SEED_RT=$(pwd)/router_test.txt
87# writes to coverage.txt by default
88# SonarCloud accepts the text format
89go-acc $(go list ./... | grep -vE '(/mocks|/tests|/e2managererrors|/enums)' )
90
91# rewrite the module name to a directory name in the coverage report
92# https://jira.sonarsource.com/browse/SONARSLANG-450
93sed -i -e 's/^e2mgr/E2Manager/' coverage.txt
94
95echo "--> e2mgr-build-ubuntu.sh ends"