diff --git a/ci-scripts/Jenkinsfile-GitLab-Container b/ci-scripts/Jenkinsfile-GitLab-Container index fbf9ba8f4b551070ff35bdc6ffbce1f9b0d17d69..dd9dba2e6675656f73c6f8ef0d99141ad2332819 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Container +++ b/ci-scripts/Jenkinsfile-GitLab-Container @@ -27,6 +27,9 @@ def nodeExecutor = params.nodeExecutor def doMandatoryTests = false def doFullTestsuite = false +// +def gitCommitAuthorEmailAddr + pipeline { agent { label nodeExecutor @@ -152,21 +155,40 @@ pipeline { } } } + stage ("CppCheck Analysis") { + steps { + script { + triggerSlaveJob ('RAN-cppcheck', 'CppCheck Analysis') + } + } + post { + always { + script { + finalizeSlaveJob('RAN-cppcheck') + } + } + failure { + script { + currentBuild.result = 'FAILURE' + } + } + } + } } } } post { always { script { + def eSubject = JOB_NAME + ' - Build # ' + BUILD_ID + ' - ' + currentBuild.result + '!' + def eBody = "Hi,\n\n" + eBody += "Here are attached HTML report files for " + JOB_NAME + " - Build # " + BUILD_ID + " - " + currentBuild.result + "!\n\n" + eBody += "Regards,\n" + eBody += "OAI CI Team" emailext attachmentsPattern: '*results*.html', - body: '''Hi, - -Here are attached HTML report files for $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS! - -Regards, -OAI CI Team''', + body: eBody, replyTo: 'no-reply@openairinterface.org', - subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!', + subject: eSubject, to: gitCommitAuthorEmailAddr if (fileExists('.git/CI_COMMIT_MSG')) { diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab index de49275b7ead1652a3b11e716e981359faa0df78..2f062161015fcf73bc8976ca47b347d735a9138b 100644 --- a/ci-scripts/Jenkinsfile-gitlab +++ b/ci-scripts/Jenkinsfile-gitlab @@ -226,27 +226,8 @@ pipeline { } } - stage ("Start VM -- cppcheck") { - steps { - lock (vmResource) { - timeout (time: 7, unit: 'MINUTES') { - sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant cppcheck --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon" - } - } - } - } - stage ("Variant Builds") { parallel { - stage ("Analysis with cppcheck") { - steps { - gitlabCommitStatus(name: "Analysis with cppcheck") { - timeout (time: 30, unit: 'MINUTES') { - sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant cppcheck --job-name ${JOB_NAME} --build-id ${BUILD_ID}" - } - } - } - } stage ("Build basic simulator") { steps { gitlabCommitStatus(name: "Build basic-sim") { @@ -315,9 +296,9 @@ pipeline { script { dir ('archives') { if (fileExists('red_hat')) { - sh "zip -r -qq vm_build_logs.zip basic_sim enb_usrp phy_sim cppcheck enb_eth ue_eth gnb_usrp nr_ue_usrp red_hat" + sh "zip -r -qq vm_build_logs.zip basic_sim phy_sim enb_eth ue_eth gnb_usrp nr_ue_usrp red_hat" } else { - sh "zip -r -qq vm_build_logs.zip basic_sim enb_usrp phy_sim cppcheck enb_eth ue_eth gnb_usrp nr_ue_usrp" + sh "zip -r -qq vm_build_logs.zip basic_sim phy_sim enb_eth ue_eth gnb_usrp nr_ue_usrp" } } if(fileExists('archives/vm_build_logs.zip')) { @@ -325,16 +306,6 @@ pipeline { } if ("MERGE".equals(env.gitlabActionType)) { sh "./ci-scripts/oai-ci-vm-tool report-build --workspace $WORKSPACE --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger merge-request --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}" - // If the merge request has introduced more CPPCHECK errors or warnings, notifications in GitLab - if (fileExists('oai_cppcheck_added_errors.txt')) { - def ret=readFile('./oai_cppcheck_added_errors.txt').trim(); - if ("0".equals(ret)) { - echo "No added cppcheck warnings/errors in this merge request" - } else { - def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): Some modified files in Merge Request MAY have INTRODUCED up to " + ret + " CPPCHECK errors/warnings" - addGitLabMRComment comment: message - } - } // If the merge request has introduced compilation warnings, notifications in GitLab sh "./ci-scripts/checkAddedWarnings.sh --src-branch ${env.gitlabSourceBranch} --target-branch ${env.gitlabTargetBranch}" def res=readFile('./oai_warning_files.txt').trim(); diff --git a/ci-scripts/args_parse.py b/ci-scripts/args_parse.py index 248e873cdd66845490ee2fbd5a74a6edd3a26e66..288e0b4885aeccab95de87ba0f3eec896e2fa767 100644 --- a/ci-scripts/args_parse.py +++ b/ci-scripts/args_parse.py @@ -41,7 +41,7 @@ import constants as CONST #----------------------------------------------------------- -def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP): +def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): py_param_file_present = False @@ -80,6 +80,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP): HTML.ranRepository=matchReg.group(1) ldpc.ranRepository=matchReg.group(1) CONTAINERS.ranRepository=matchReg.group(1) + SCA.ranRepository=matchReg.group(1) elif re.match('^\-\-eNB_AllowMerge=(.+)$|^\-\-ranAllowMerge=(.+)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNB_AllowMerge=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB_AllowMerge=(.+)$', myArgv, re.IGNORECASE) @@ -92,6 +93,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP): RAN.ranAllowMerge=True HTML.ranAllowMerge=True CONTAINERS.ranAllowMerge=True + SCA.ranAllowMerge=True elif re.match('^\-\-eNBBranch=(.+)$|^\-\-ranBranch=(.+)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE) @@ -102,6 +104,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP): HTML.ranBranch=matchReg.group(1) ldpc.ranBranch=matchReg.group(1) CONTAINERS.ranBranch=matchReg.group(1) + SCA.ranBranch=matchReg.group(1) elif re.match('^\-\-eNBCommitID=(.*)$|^\-\-ranCommitID=(.*)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE) @@ -112,6 +115,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP): HTML.ranCommitID=matchReg.group(1) ldpc.ranCommitID=matchReg.group(1) CONTAINERS.ranCommitID=matchReg.group(1) + SCA.ranCommitID=matchReg.group(1) elif re.match('^\-\-eNBTargetBranch=(.*)$|^\-\-ranTargetBranch=(.*)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBTargetBranch=(.*)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBTargetBranch=(.*)$', myArgv, re.IGNORECASE) @@ -122,12 +126,14 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP): HTML.ranTargetBranch=matchReg.group(1) ldpc.ranTargetBranch=matchReg.group(1) CONTAINERS.ranTargetBranch=matchReg.group(1) + SCA.ranTargetBranch=matchReg.group(1) elif re.match('^\-\-eNBIPAddress=(.+)$|^\-\-eNB[1-2]IPAddress=(.+)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBIPAddress=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBIPAddress=(.+)$', myArgv, re.IGNORECASE) RAN.eNBIPAddress=matchReg.group(1) ldpc.eNBIpAddr=matchReg.group(1) CONTAINERS.eNBIPAddress=matchReg.group(1) + SCA.eNBIPAddress=matchReg.group(1) elif re.match('^\-\-eNB1IPAddress=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1IPAddress=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1IPAddress=matchReg.group(1) @@ -142,6 +148,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP): RAN.eNBUserName=matchReg.group(1) ldpc.eNBUserName=matchReg.group(1) CONTAINERS.eNBUserName=matchReg.group(1) + SCA.eNBUserName=matchReg.group(1) elif re.match('^\-\-eNB1UserName=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1UserName=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1UserName=matchReg.group(1) @@ -156,6 +163,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP): RAN.eNBPassword=matchReg.group(1) ldpc.eNBPassWord=matchReg.group(1) CONTAINERS.eNBPassword=matchReg.group(1) + SCA.eNBPassword=matchReg.group(1) elif re.match('^\-\-eNB1Password=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1Password=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1Password=matchReg.group(1) @@ -170,6 +178,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP): RAN.eNBSourceCodePath=matchReg.group(1) ldpc.eNBSourceCodePath=matchReg.group(1) CONTAINERS.eNBSourceCodePath=matchReg.group(1) + SCA.eNBSourceCodePath=matchReg.group(1) elif re.match('^\-\-eNB1SourceCodePath=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1SourceCodePath=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1SourceCodePath=matchReg.group(1) diff --git a/ci-scripts/buildOnRH.sh b/ci-scripts/buildOnRH.sh deleted file mode 100755 index eaff097c885ad1d219ba502bd58cbde245020955..0000000000000000000000000000000000000000 --- a/ci-scripts/buildOnRH.sh +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ - -function usage { - echo "OAI RedHat Build Check script" - echo " Original Author: Raphael Defosseux" - - echo "" - echo "Usage:" - echo "------" - echo " buildOnRH.sh [OPTIONS]" - echo "" - echo "Options:" - echo "--------" - echo " --job-name #### OR -jn ####" - echo " Specify the name of the Jenkins job." - echo "" - echo " --build-id #### OR -id ####" - echo " Specify the build ID of the Jenkins job." - echo "" - echo " --workspace #### OR -ws ####" - echo " Specify the workspace." - echo "" - echo " --remote-host #### OR -rh ####" - echo " Specify the RedHat remote server." - echo "" - echo " --remote-user-name #### OR -ru ####" - echo " Specify the RedHat remote server username." - echo "" - echo " --remote-password #### OR -rp ####" - echo " Specify the RedHat remote server password." - echo "" - echo " --remote-path #### OR -ra ####" - echo " Specify the RedHat remote server path to work on." - echo "" -} - -if [ $# -lt 1 ] || [ $# -gt 14 ] -then - echo "Syntax Error: not the correct number of arguments" - echo "" - usage - exit 1 -fi - -RH_HOST=XX -RH_USER=XX -RH_PASSWD=XX -RH_PATH=XX -JOB_NAME=XX -BUILD_ID=XX - -while [[ $# -gt 0 ]] -do -key="$1" - -case $key in - -h|--help) - shift - usage - exit 0 - ;; - -jn|--job-name) - JOB_NAME="$2" - shift - shift - ;; - -id|--build-id) - BUILD_ID="$2" - shift - shift - ;; - -ws|--workspace) - JENKINS_WKSP="$2" - shift - shift - ;; - -rh|--remote-host) - RH_HOST="$2" - shift - shift - ;; - -ru|--remote-user-name) - RH_USER="$2" - shift - shift - ;; - -rp|--remote-password) - RH_PASSWD="$2" - shift - shift - ;; - -ra|--remote-path) - RH_PATH="$2" - shift - shift - ;; - *) - echo "Syntax Error: unknown option: $key" - echo "" - usage - exit 1 -esac -done - -if [ ! -f $JENKINS_WKSP/localZip.zip ] -then - echo "Missing localZip.zip file!" - exit 1 -fi - -if [ "$JOB_NAME" == "XX" ] || [ "$BUILD_ID" == "XX" ] || [ "$RH_HOST" == "XX" ] || [ "$RH_USER" == "XX" ] || [ "$RH_PASSWD" == "XX" ] || [ "$RH_PATH" == "XX" ] -then - echo "Missing options" - usage - exit 1 -fi - -echo "############################################################" -echo "Copying GIT repo into RedHat Server" -echo "############################################################" -echo "rm -Rf ${RH_PATH}" >> rh-cmd.txt -echo "mkdir -p ${RH_PATH}" >> rh-cmd.txt - -sshpass -p ${RH_PASSWD} ssh -o 'StrictHostKeyChecking no' ${RH_USER}@${RH_HOST} < rh-cmd.txt -rm -f rh-cmd.txt - -echo "############################################################" -echo "Running install and build script on RedHat Server" -echo "############################################################" -sshpass -p ${RH_PASSWD} scp -o 'StrictHostKeyChecking no' $JENKINS_WKSP/localZip.zip ${RH_USER}@${RH_HOST}:${RH_PATH} - -echo "cd ${RH_PATH}" > rh-cmd.txt -echo "unzip -qq localZip.zip" >> rh-cmd.txt -echo "source oaienv" >> rh-cmd.txt -echo "cd cmake_targets" >> rh-cmd.txt -echo "mkdir -p log" >> rh-cmd.txt -echo "./build_oai -I -w USRP --eNB > log/install-build.txt 2>&1" >> rh-cmd.txt -sshpass -p ${RH_PASSWD} ssh -o 'StrictHostKeyChecking no' ${RH_USER}@${RH_HOST} < rh-cmd.txt - -rm -f rh-cmd.txt - -echo "############################################################" -echo "Creating a tmp folder to store results and artifacts" -echo "############################################################" -if [ ! -d $JENKINS_WKSP/archives ] -then - mkdir -p $JENKINS_WKSP/archives -fi - -ARCHIVES_LOC=$JENKINS_WKSP/archives/red_hat -if [ ! -d $ARCHIVES_LOC ] -then - mkdir -p $ARCHIVES_LOC -fi - -sshpass -p ${RH_PASSWD} scp -o 'StrictHostKeyChecking no' ${RH_USER}@${RH_HOST}:${RH_PATH}/cmake_targets/log/*.txt $ARCHIVES_LOC - -echo "############################################################" -echo "Checking build status" -echo "############################################################" - -LOG_PATTERN=.Rel15.txt -NB_PATTERN_FILES=7 - -LOG_FILES=`ls $ARCHIVES_LOC/*.txt` -STATUS=0 -NB_FOUND_FILES=0 - -for FULLFILE in $LOG_FILES -do - if [[ $FULLFILE == *"$LOG_PATTERN"* ]] - then - filename=$(basename -- "$FULLFILE") - PASS_PATTERN=`echo $filename | sed -e "s#$LOG_PATTERN##"` - LOCAL_STAT=`egrep -c "Built target $PASS_PATTERN" $FULLFILE` - if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi - NB_FOUND_FILES=$((NB_FOUND_FILES + 1)) - fi -done - -if [ $NB_PATTERN_FILES -ne $NB_FOUND_FILES ] -then - echo "Expecting $NB_PATTERN_FILES log files and found $NB_FOUND_FILES" - STATUS=-1 -fi - -echo "COMMAND: build_oai -I -w USRP --eNB" > $ARCHIVES_LOC/build_final_status.log -if [ $STATUS -eq 0 ] -then - echo "BUILD_OK" >> $ARCHIVES_LOC/build_final_status.log - echo "STATUS seems OK" -else - echo "BUILD_KO" >> $ARCHIVES_LOC/build_final_status.log - echo "STATUS failed?" -fi -exit $STATUS diff --git a/ci-scripts/buildOnVM.sh b/ci-scripts/buildOnVM.sh index 2b1a5e0c71526534c7173111a2909a31c150e5cd..31e9653769cdc019745ce3864eed45aea34e9f4b 100755 --- a/ci-scripts/buildOnVM.sh +++ b/ci-scripts/buildOnVM.sh @@ -62,7 +62,7 @@ function build_on_vm { echo "ARCHIVES_LOC = $ARCHIVES_LOC" echo "BUILD_OPTIONS = $BUILD_OPTIONS" - if [[ "$VM_NAME" == *"-enb-usrp"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] then echo "This VM type is no longer supported in the pipeline framework" return diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 0debe424684b8c9396cb85058df8bae4db280d50..e5011dcd46413ae051b4c4ed2899459baa3acd62 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -83,6 +83,7 @@ class Containerize(): self.flexranCtrlDeployed = False self.flexranCtrlIpAddress = '' self.cli = '' + self.cliBuildOptions = '' self.dockerfileprefix = '' self.host = '' self.allImagesSize = {} @@ -124,9 +125,11 @@ class Containerize(): if self.host == 'Ubuntu': self.cli = 'docker' self.dockerfileprefix = '.ubuntu18' + self.cliBuildOptions = '--no-cache' elif self.host == 'Red Hat': self.cli = 'sudo podman' self.dockerfileprefix = '.rhel8.2' + self.cliBuildOptions = '--no-cache --disable-compression' imageNames = [] result = re.search('eNB', self.imageKind) @@ -144,6 +147,8 @@ class Containerize(): imageNames.append(('oai-gnb', 'gNB')) imageNames.append(('oai-lte-ue', 'lteUE')) imageNames.append(('oai-nr-ue', 'nrUE')) + if self.host == 'Red Hat': + imageNames.append(('oai-physim', 'phySim')) if len(imageNames) == 0: imageNames.append(('oai-enb', 'eNB')) @@ -201,7 +206,7 @@ class Containerize(): # Build the shared image only on Push Events (not on Merge Requests) if (not self.ranAllowMerge): - mySSH.command(self.cli + ' build --target ' + sharedimage + ' --tag ' + sharedimage + ':' + sharedTag + ' --file docker/Dockerfile.ran' + self.dockerfileprefix + ' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-build.log 2>&1', '\$', 1600) + mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + sharedimage + ' --tag ' + sharedimage + ':' + sharedTag + ' --file docker/Dockerfile.ran' + self.dockerfileprefix + ' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-build.log 2>&1', '\$', 1600) # First verify if the shared image was properly created. status = True mySSH.command(self.cli + ' image inspect --format=\'Size = {{.Size}} bytes\' ' + sharedimage + ':' + sharedTag, '\$', 5) @@ -249,7 +254,7 @@ class Containerize(): # the archived Dockerfiles have "ran-build:latest" as base image # we need to update them with proper tag mySSH.command('sed -i -e "s#' + sharedimage + ':latest#' + sharedimage + ':' + sharedTag + '#" docker/Dockerfile.' + pattern + self.dockerfileprefix, '\$', 5) - mySSH.command(self.cli + ' build --target ' + image + ' --tag ' + image + ':' + imageTag + ' --file docker/Dockerfile.' + pattern + self.dockerfileprefix + ' . > cmake_targets/log/' + image + '.log 2>&1', '\$', 1200) + mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + image + ' --tag ' + image + ':' + imageTag + ' --file docker/Dockerfile.' + pattern + self.dockerfileprefix + ' . > cmake_targets/log/' + image + '.log 2>&1', '\$', 1200) # split the log mySSH.command('mkdir -p cmake_targets/log/' + image, '\$', 5) mySSH.command('python3 ci-scripts/docker_log_split.py --logfilename=cmake_targets/log/' + image + '.log', '\$', 5) diff --git a/ci-scripts/cls_static_code_analysis.py b/ci-scripts/cls_static_code_analysis.py new file mode 100644 index 0000000000000000000000000000000000000000..980efb4f8adb72c7c4af31e3cdeecb41d96be74a --- /dev/null +++ b/ci-scripts/cls_static_code_analysis.py @@ -0,0 +1,192 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# Python for CI of OAI-eNB + COTS-UE +# +# Required Python Version +# Python 3.x +# +# Required Python Package +# pexpect +#--------------------------------------------------------------------- + +#----------------------------------------------------------- +# Import +#----------------------------------------------------------- +import sys # arg +import re # reg +import logging +import os +import time + +#----------------------------------------------------------- +# OAI Testing modules +#----------------------------------------------------------- +import sshconnection as SSH +import helpreadme as HELP +import constants as CONST + +#----------------------------------------------------------- +# Class Declaration +#----------------------------------------------------------- +class CppCheckResults(): + + def __init__(self): + + self.variants = ['xenial', 'bionic'] + self.versions = ['',''] + self.nbErrors = [0,0] + self.nbWarnings = [0,0] + self.nbNullPtrs = [0,0] + self.nbMemLeaks = [0,0] + self.nbUninitVars = [0,0] + self.nbInvalidPrintf = [0,0] + self.nbModuloAlways = [0,0] + self.nbTooManyBitsShift = [0,0] + self.nbIntegerOverflow = [0,0] + self.nbWrongScanfArg = [0,0] + self.nbPtrAddNotNull = [0,0] + self.nbOppoInnerCondition = [0,0] + +class StaticCodeAnalysis(): + + def __init__(self): + + self.ranRepository = '' + self.ranBranch = '' + self.ranAllowMerge = False + self.ranCommitID = '' + self.ranTargetBranch = '' + self.eNBIPAddress = '' + self.eNBUserName = '' + self.eNBPassword = '' + self.eNBSourceCodePath = '' + + def CppCheckAnalysis(self, HTML): + if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + lIpAddr = self.eNBIPAddress + lUserName = self.eNBUserName + lPassWord = self.eNBPassword + lSourcePath = self.eNBSourceCodePath + + if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + logging.debug('Building on server: ' + lIpAddr) + mySSH = SSH.SSHConnection() + mySSH.open(lIpAddr, lUserName, lPassWord) + + self.testCase_id = HTML.testCase_id + + # on RedHat/CentOS .git extension is mandatory + result = re.search('([a-zA-Z0-9\:\-\.\/])+\.git', self.ranRepository) + if result is not None: + full_ran_repo_name = self.ranRepository + else: + full_ran_repo_name = self.ranRepository + '.git' + mySSH.command('mkdir -p ' + lSourcePath, '\$', 5) + mySSH.command('cd ' + lSourcePath, '\$', 5) + mySSH.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + full_ran_repo_name + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600) + # Raphael: here add a check if git clone or git fetch went smoothly + mySSH.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) + mySSH.command('git config user.name "OAI Jenkins"', '\$', 5) + + mySSH.command('echo ' + lPassWord + ' | sudo -S git clean -x -d -ff', '\$', 30) + mySSH.command('mkdir -p cmake_targets/log', '\$', 5) + # if the commit ID is provided use it to point to it + if self.ranCommitID != '': + mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 5) + + mySSH.command('docker image rm oai-cppcheck:bionic oai-cppcheck:xenial || true', '\$', 60) + mySSH.command('docker build --tag oai-cppcheck:xenial --file ci-scripts/docker/Dockerfile.cppcheck.xenial . > cmake_targets/log/cppcheck-xenial.txt 2>&1', '\$', 600) + mySSH.command('sed -e "s@xenial@bionic@" ci-scripts/docker/Dockerfile.cppcheck.xenial > ci-scripts/docker/Dockerfile.cppcheck.bionic', '\$', 6) + mySSH.command('docker build --tag oai-cppcheck:bionic --file ci-scripts/docker/Dockerfile.cppcheck.bionic . > cmake_targets/log/cppcheck-bionic.txt 2>&1', '\$', 600) + mySSH.command('docker image rm oai-cppcheck:bionic oai-cppcheck:xenial || true', '\$', 60) + + # Analyzing the logs + mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) + mySSH.command('mkdir -p build_log_' + self.testCase_id, '\$', 5) + mySSH.command('mv log/* ' + 'build_log_' + self.testCase_id, '\$', 5) + mySSH.close() + + mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/build_log_' + self.testCase_id + '/*', '.') + CCR = CppCheckResults() + vId = 0 + for variant in CCR.variants: + if (os.path.isfile('./cppcheck-'+ variant + '.txt')): + xmlStart = False + with open('./cppcheck-'+ variant + '.txt', 'r') as logfile: + for line in logfile: + ret = re.search('Unpacking cppcheck \((?P<version>[0-9\.]+)', str(line)) + if ret is not None: + CCR.versions[vId] = ret.group('version') + if re.search('RUN cat cmake_targets/log/cppcheck.xml', str(line)) is not None: + xmlStart = True + if xmlStart: + if re.search('severity="error"', str(line)) is not None: + CCR.nbErrors[vId] += 1 + if re.search('severity="warning"', str(line)) is not None: + CCR.nbWarnings[vId] += 1 + if re.search('id="memleak"', str(line)) is not None: + CCR.nbMemLeaks[vId] += 1 + if re.search('id="nullPointer"', str(line)) is not None: + CCR.nbNullPtrs[vId] += 1 + if re.search('id="uninitvar"', str(line)) is not None: + CCR.nbUninitVars[vId] += 1 + if re.search('id="invalidPrintfArgType_sint"|id="invalidPrintfArgType_uint"', str(line)) is not None: + CCR.nbInvalidPrintf[vId] += 1 + if re.search('id="moduloAlwaysTrueFalse"', str(line)) is not None: + CCR.nbModuloAlways[vId] += 1 + if re.search('id="shiftTooManyBitsSigned"', str(line)) is not None: + CCR.nbTooManyBitsShift[vId] += 1 + if re.search('id="integerOverflow"', str(line)) is not None: + CCR.nbIntegerOverflow[vId] += 1 + if re.search('id="wrongPrintfScanfArgNum"|id="invalidScanfArgType_int"', str(line)) is not None: + CCR.nbWrongScanfArg[vId] += 1 + if re.search('id="pointerAdditionResultNotNull"', str(line)) is not None: + CCR.nbPtrAddNotNull[vId] += 1 + if re.search('id="oppositeInnerCondition"', str(line)) is not None: + CCR.nbOppoInnerCondition[vId] += 1 + logging.debug('======== Variant ' + variant + ' - ' + CCR.versions[vId] + ' ========') + logging.debug(' ' + str(CCR.nbErrors[vId]) + ' errors') + logging.debug(' ' + str(CCR.nbWarnings[vId]) + ' warnings') + logging.debug(' -- Details --') + logging.debug(' Memory leak: ' + str(CCR.nbMemLeaks[vId])) + logging.debug(' Possible null pointer deference: ' + str(CCR.nbNullPtrs[vId])) + logging.debug(' Uninitialized variable: ' + str(CCR.nbUninitVars[vId])) + logging.debug(' Undefined behaviour shifting: ' + str(CCR.nbTooManyBitsShift[vId])) + logging.debug(' Signed integer overflow: ' + str(CCR.nbIntegerOverflow[vId])) + logging.debug('') + logging.debug(' Printf formatting issue: ' + str(CCR.nbInvalidPrintf[vId])) + logging.debug(' Modulo result is predetermined: ' + str(CCR.nbModuloAlways[vId])) + logging.debug(' Opposite Condition -> dead code: ' + str(CCR.nbOppoInnerCondition[vId])) + logging.debug(' Wrong Scanf Nb Args: ' + str(CCR.nbWrongScanfArg[vId])) + logging.debug('') + vId += 1 + + HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) + HTML.CreateHtmlTestRowCppCheckResults(CCR) + logging.info('\u001B[1m Static Code Analysis Pass\u001B[0m') + + return 0 + diff --git a/ci-scripts/createVM.sh b/ci-scripts/createVM.sh index b67668f0bcc4036736b381d9caf84ab6e8567c19..ab859c10d761fb27d2fc7e1f4d5503361453eaed 100755 --- a/ci-scripts/createVM.sh +++ b/ci-scripts/createVM.sh @@ -87,7 +87,7 @@ function create_vm { echo "VM_CPU = $VM_CPU" echo "VM_DISK = $VM_DISK GBytes" - if [[ "$VM_NAME" == *"-enb-usrp"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] then echo "This VM type is no longer supported in the pipeline framework" return diff --git a/ci-scripts/docker/Dockerfile.cppcheck.xenial b/ci-scripts/docker/Dockerfile.cppcheck.xenial new file mode 100644 index 0000000000000000000000000000000000000000..0aecc62037e6a2bdfb849f02e2618dd04bd4eb7e --- /dev/null +++ b/ci-scripts/docker/Dockerfile.cppcheck.xenial @@ -0,0 +1,31 @@ +FROM ubuntu:xenial AS oai-cppcheck + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ + DEBIAN_FRONTEND=noninteractive apt-get install --yes \ + build-essential \ + vim \ + cppcheck + +WORKDIR /oai-ran +COPY . . + +WORKDIR /oai-ran/common/utils/T +RUN make + +WORKDIR /oai-ran +RUN mkdir -p cmake_targets/log && \ + cppcheck --enable=warning --force --xml --xml-version=2 \ + -i openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c \ + --suppressions-list=ci-scripts/cppcheck_suppressions.list \ + -I common/utils \ + -I openair3/NAS/COMMON/UTIL \ + -j`nproc` . 2> cmake_targets/log/cppcheck.xml 1> cmake_targets/log/cppcheck_build.txt + +RUN egrep -c 'severity="error' cmake_targets/log/cppcheck.xml + +RUN egrep -c 'severity="warning' cmake_targets/log/cppcheck.xml + +RUN cat cmake_targets/log/cppcheck.xml diff --git a/ci-scripts/html.py b/ci-scripts/html.py index b3ee00e7dc5253133431803ff7f9a2f3b8d647dd..a0ac6385730104e5b965fc772f81b18a7da56733 100644 --- a/ci-scripts/html.py +++ b/ci-scripts/html.py @@ -479,3 +479,88 @@ class HTMLManagement(): self.htmlFile.write(' </tr>\n') self.htmlFile.close() + def CreateHtmlTestRowCppCheckResults(self, CCR): + if (self.htmlFooterCreated or (not self.htmlHeaderCreated)): + return + self.htmlFile = open('test_results.html', 'a') + vId = 0 + for version in CCR.versions: + self.htmlFile.write(' <tr bgcolor = "#F0F0F0" >\n') + self.htmlFile.write(' <td colspan=' + str(5+self.htmlUEConnected) + '><b> Results for cppcheck v ' + version + ' </b></td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> NB ERRORS</b></td>\n') + if CCR.nbErrors[vId] == 0: + myColor = 'lightgreen' + elif CCR.nbErrors[vId] < 20: + myColor = 'orange' + else: + myColor = 'lightcoral' + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + ' bgcolor = "' + myColor + '"><b>' + str(CCR.nbErrors[vId]) + '</b></td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> NB WARNINGS</b></td>\n') + if CCR.nbWarnings[vId] == 0: + myColor = 'lightgreen' + elif CCR.nbWarnings[vId] < 20: + myColor = 'orange' + else: + myColor = 'lightcoral' + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + ' bgcolor = "' + myColor + '"><b>' + str(CCR.nbWarnings[vId]) + '</b></td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr bgcolor = "#F0F0F0" >\n') + self.htmlFile.write(' <td colspan=' + str(5+self.htmlUEConnected) + '> ----------------- </td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> Memory leak</b></td>\n') + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + '>' + str(CCR.nbMemLeaks[vId]) + '</td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> Possible null pointer deference</b></td>\n') + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + '>' + str(CCR.nbNullPtrs[vId]) + '</td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> Uninitialized variable</b></td>\n') + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + '>' + str(CCR.nbUninitVars[vId]) + '</td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> Undefined behaviour shifting</b></td>\n') + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + '>' + str(CCR.nbTooManyBitsShift[vId]) + '</td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> Signed integer overflow</b></td>\n') + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + '>' + str(CCR.nbIntegerOverflow[vId]) + '</td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr bgcolor = "#F0F0F0" >\n') + self.htmlFile.write(' <td colspan=' + str(5+self.htmlUEConnected) + '> </td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> Printf formatting issues</b></td>\n') + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + '>' + str(CCR.nbInvalidPrintf[vId]) + '</td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> Modulo result is predetermined</b></td>\n') + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + '>' + str(CCR.nbModuloAlways[vId]) + '</td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> Opposite Condition -> dead code</b></td>\n') + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + '>' + str(CCR.nbOppoInnerCondition[vId]) + '</td>\n') + self.htmlFile.write(' </tr>\n') + self.htmlFile.write(' <tr>\n') + self.htmlFile.write(' <td></td>\n') + self.htmlFile.write(' <td colspan=2 bgcolor = "lightcyan" ><b> Wrong Scanf Nb Args</b></td>\n') + self.htmlFile.write(' <td colspan=' + str(2+self.htmlUEConnected) + '>' + str(CCR.nbWrongScanfArg[vId]) + '</td>\n') + self.htmlFile.write(' </tr>\n') + vId += 1 + + self.htmlFile.close() diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 3094197c542f8bbf6a7ca90a91dff1dfe656d287..f13df9beb5bb4ea2942563c8a05ddd5fb7bf4c71 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -38,10 +38,11 @@ import helpreadme as HELP import constants as CONST -import cls_oaicitest #main class for OAI CI test framework -import cls_physim #class PhySim for physical simulators build and test -import cls_cots_ue #class CotsUe for Airplane mode control -import cls_containerize #class Containerize for all container-based operations on RAN/UE objects +import cls_oaicitest #main class for OAI CI test framework +import cls_physim #class PhySim for physical simulators build and test +import cls_cots_ue #class CotsUe for Airplane mode control +import cls_containerize #class Containerize for all container-based operations on RAN/UE objects +import cls_static_code_analysis #class for static code analysis import sshconnection @@ -378,6 +379,7 @@ EPC = epc.EPCManagement() RAN = ran.RANManagement() HTML = html.HTMLManagement() CONTAINERS = cls_containerize.Containerize() +SCA = cls_static_code_analysis.StaticCodeAnalysis() ldpc=cls_physim.PhySim() #create an instance for LDPC test using GPU or CPU build @@ -388,7 +390,7 @@ ldpc=cls_physim.PhySim() #create an instance for LDPC test using GPU or CPU b #----------------------------------------------------------- import args_parse -py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP) +py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA) @@ -741,6 +743,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re CONTAINERS.DeployObject(HTML, EPC) elif action == 'Undeploy_Object': CONTAINERS.UndeployObject(HTML, RAN) + elif action == 'Cppcheck_Analysis': + SCA.CppCheckAnalysis(HTML) else: sys.exit('Invalid class (action) from xml') if not RAN.prematureExit: diff --git a/ci-scripts/reportBuildLocally.sh b/ci-scripts/reportBuildLocally.sh index 19a486303f10e5355d49c8b1e425b9c42314e6dc..b46ade903f2d36ce49e5d39e5b813863f710af70 100755 --- a/ci-scripts/reportBuildLocally.sh +++ b/ci-scripts/reportBuildLocally.sh @@ -568,17 +568,20 @@ function report_build { echo " <h2>Ubuntu 16.04 LTS -- Summary</h2>" >> ./build_results.html - sca_summary_table_header ./archives/cppcheck/cppcheck.xml "OAI Static Code Analysis with CPPCHECK" - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Uninitialized variable" uninitvar - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Uninitialized struct member" uninitStructMember - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Memory leak" memleak - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Memory is freed twice" doubleFree - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Resource leak" resourceLeak - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Possible null pointer dereference" nullPointer - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Array access out of bounds" arrayIndexOutOfBounds - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Buffer is accessed out of bounds" bufferAccessOutOfBounds - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Expression depends on order of evaluation of side effects" unknownEvaluationOrder - sca_summary_table_footer ./archives/cppcheck/cppcheck.xml + if [ -f ./archives/cppcheck/cppcheck.xml ] + then + sca_summary_table_header ./archives/cppcheck/cppcheck.xml "OAI Static Code Analysis with CPPCHECK" + sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Uninitialized variable" uninitvar + sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Uninitialized struct member" uninitStructMember + sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Memory leak" memleak + sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Memory is freed twice" doubleFree + sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Resource leak" resourceLeak + sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Possible null pointer dereference" nullPointer + sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Array access out of bounds" arrayIndexOutOfBounds + sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Buffer is accessed out of bounds" bufferAccessOutOfBounds + sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Expression depends on order of evaluation of side effects" unknownEvaluationOrder + sca_summary_table_footer ./archives/cppcheck/cppcheck.xml + fi # summary_table_header "OAI Build: 4G LTE eNB -- USRP option" ./archives/enb_usrp # summary_table_row "LTE SoftModem - Release 15" ./archives/enb_usrp/lte-softmodem.Rel15.txt "Built target lte-softmodem" ./enb_usrp_row1.html diff --git a/ci-scripts/waitBuildOnVM.sh b/ci-scripts/waitBuildOnVM.sh index ff2129a187d4a0216d75c73a05889418650e9f44..f7e300edf452bbc93203168073e30d8b01ab1799 100755 --- a/ci-scripts/waitBuildOnVM.sh +++ b/ci-scripts/waitBuildOnVM.sh @@ -47,7 +47,7 @@ function wait_on_vm_build { echo "ARCHIVES_LOC = $ARCHIVES_LOC" echo "BUILD_OPTIONS = $BUILD_OPTIONS" - if [[ "$VM_NAME" == *"-enb-usrp"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] then echo "This VM type is no longer supported in the pipeline framework" return @@ -73,6 +73,9 @@ function wait_on_vm_build { echo "############################################################" echo "Waiting build process to end on VM ($VM_NAME)" echo "############################################################" + # Since the last VM was cppcheck and is removed + # we are going too fast in wait and the build_oai is not yet started + sleep 120 if [[ "$VM_NAME" == *"-cppcheck"* ]] then @@ -90,7 +93,7 @@ function wait_on_vm_build { } function check_on_vm_build { - if [[ "$VM_NAME" == *"-enb-usrp"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] then echo "This VM type is no longer supported in the pipeline framework" return diff --git a/ci-scripts/xml_class_list.yml b/ci-scripts/xml_class_list.yml index 0e00a2e7d413da5784e7c88210335bfa335406ec..de16116124c8f3999e58a8b47f1e7a7bd0419ccd 100755 --- a/ci-scripts/xml_class_list.yml +++ b/ci-scripts/xml_class_list.yml @@ -37,3 +37,4 @@ - Build_Image - Deploy_Object - Undeploy_Object + - Cppcheck_Analysis diff --git a/ci-scripts/xml_files/cppcheck.xml b/ci-scripts/xml_files/cppcheck.xml new file mode 100644 index 0000000000000000000000000000000000000000..dd90d88f7e289cba5e35ac56df3c6f409bd08960 --- /dev/null +++ b/ci-scripts/xml_files/cppcheck.xml @@ -0,0 +1,37 @@ +<!-- + + Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The OpenAirInterface Software Alliance licenses this file to You under + the OAI Public License, Version 1.1 (the "License"); you may not use this file + except in compliance with the License. + You may obtain a copy of the License at + + http://www.openairinterface.org/?page_id=698 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + For more information about the OpenAirInterface (OAI) Software Alliance: + contact@openairinterface.org + +--> +<testCaseList> + <htmlTabRef>build-tab</htmlTabRef> + <htmlTabName>CPPCHECK Analysis</htmlTabName> + <htmlTabIcon>wrench</htmlTabIcon> + <TestCaseRequestedList> + 000001 + </TestCaseRequestedList> + <TestCaseExclusionList></TestCaseExclusionList> + + <testCase id="000001"> + <class>Cppcheck_Analysis</class> + <desc>Static Code Analysis with cppcheck</desc> + </testCase> + +</testCaseList> diff --git a/docker/Dockerfile.phySim.rhel8.2 b/docker/Dockerfile.phySim.rhel8.2 new file mode 100644 index 0000000000000000000000000000000000000000..4472ece36313de139ff26710dc253f19fb4f9585 --- /dev/null +++ b/docker/Dockerfile.phySim.rhel8.2 @@ -0,0 +1,123 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Dockerfile for the Open-Air-Interface BUILD service +# Valid for RHEL8 +# +#--------------------------------------------------------------------- + +FROM localhost/ran-build:develop AS phy-sim-build + +RUN rm -Rf /oai-ran +WORKDIR /oai-ran +COPY . . + +#run build_oai to build the target image +RUN /bin/sh oaienv && \ + cd cmake_targets && \ + mkdir -p log && \ + ./build_oai --phy_simulators --ninja --verbose-ci + + +#start from scratch for target executable +FROM registry.access.redhat.com/ubi8/ubi:latest as oai-physim + +RUN yum update -y && \ + yum install -y --enablerepo="ubi-8-codeready-builder" \ + lksctp-tools \ + nettle \ + atlas \ + hostname \ + sudo \ + procps-ng \ + net-tools \ + iputils \ + bc \ + iproute \ + libyaml && \ + echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ + echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf + +WORKDIR /opt/oai-physim/targets/bin +COPY --from=phy-sim-build /oai-ran/targets/bin/dlsim.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/nr_dlsim.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/nr_prachsim.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/nr_ulschsim.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/polartest.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/ulsim.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/ldpctest.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/nr_dlschsim.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/nr_pbchsim.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/nr_pucchsim.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/nr_ulsim.Rel15 . +COPY --from=phy-sim-build /oai-ran/targets/bin/smallblocktest.Rel15 . + +WORKDIR /usr/local/lib/ +COPY --from=phy-sim-build /oai-ran/targets/bin/libcoding.so . +COPY --from=phy-sim-build /lib64/liblapacke.so.3 . +COPY --from=phy-sim-build /lib64/libX11.so.6 . +COPY --from=phy-sim-build /lib64/libXpm.so.4 . +COPY --from=phy-sim-build /lib64/libxcb.so.1 . +COPY --from=phy-sim-build /lib64/libXau.so.6 . +COPY --from=phy-sim-build /lib64/libforms.so.2 . +COPY --from=phy-sim-build /lib64/libblas.so.3 . +COPY --from=phy-sim-build /lib64/liblapack.so.3 . +COPY --from=phy-sim-build /lib64/libexslt.so.0 . +COPY --from=phy-sim-build /lib64/libxslt.so.1 . +COPY --from=phy-sim-build /oai-ran/cmake_targets/phy_simulators/build/libdfts.so . +COPY --from=phy-sim-build /oai-ran/cmake_targets/phy_simulators/build/libSIMU.so . +COPY --from=phy-sim-build /oai-ran/cmake_targets/phy_simulators/build/libldpc.so . +COPY --from=phy-sim-build /oai-ran/cmake_targets/phy_simulators/build/libldpc_orig.so . + +RUN ldconfig + +#debug +#RUN ldd /opt/oai-physim/targets/bin/dlsim.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/nr_dlsim.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/nr_prachsim.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/nr_ulschsim.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/polartest.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/ulsim.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/ldpctest.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/nr_dlschsim.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/nr_pbchsim.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/nr_pucchsim.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/nr_ulsim.Rel15 +#RUN ldd /opt/oai-physim/targets/bin/smallblocktest.Rel15 + +# Copy some executables +WORKDIR /usr/bin/ + +COPY --from=phy-sim-build /usr/bin/killall . +COPY --from=phy-sim-build /usr/bin/xmlstarlet . +COPY --from=phy-sim-build /usr/bin/svn . + +# Copy the relevant configuration files for phySim +WORKDIR /opt/oai-physim/ + +COPY --from=phy-sim-build /oai-ran/cmake_targets/autotests/run_exec_autotests.bash /opt/oai-physim/cmake_targets/autotests/ +COPY --from=phy-sim-build /oai-ran/cmake_targets/autotests/test_case_list.xml /opt/oai-physim/cmake_targets/autotests/ +COPY --from=phy-sim-build /oai-ran/cmake_targets/autotests/tools/free_mem.bash /opt/oai-physim/cmake_targets/autotests/tools/ +COPY --from=phy-sim-build /oai-ran/cmake_targets/tools/build_helper /opt/oai-physim/cmake_targets/tools/ +COPY --from=phy-sim-build /oai-ran/cmake_targets/tools/test_helper /opt/oai-physim/cmake_targets/tools/ + +#CMD ["sleep", "infinity"] diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 47ddd7896e501ecbeaf29a3b5d03fb2f3b23ea56..2adf37319627f8fec1609ad469002c097d7b44cf 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -332,6 +332,14 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { protocol_ctxt_t ctxt; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE->Mod_id, ENB_FLAG_NO, mac->crnti, proc->frame_rx, proc->nr_slot_rx, 0); pdcp_run(&ctxt); + + /* send tick to RLC and PDCP every ms */ + if (proc->nr_slot_rx % UE->frame_parms.slots_per_subframe == 0) { + void nr_rlc_tick(int frame, int subframe); + void nr_pdcp_tick(int frame, int subframe); + nr_rlc_tick(proc->frame_rx, proc->nr_slot_rx / UE->frame_parms.slots_per_subframe); + nr_pdcp_tick(proc->frame_rx, proc->nr_slot_rx / UE->frame_parms.slots_per_subframe); + } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 94524795f3264b13a0129035696ededc7d062f68..9db78244baed631a26859f036c34096dec46a46d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1705,6 +1705,7 @@ void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti) { int UE_id; int i; + int cc_id; NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; for (i = 0; i < MAX_MOBILES_PER_GNB; i++) { @@ -1741,6 +1742,20 @@ void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti) rnti_to_remove_count++; if (pthread_mutex_unlock(&rnti_to_remove_mutex)) exit(1); } + + /* clear RA process(es?) associated to the UE */ + for (cc_id = 0; cc_id < NFAPI_CC_MAX; cc_id++) { + NR_COMMON_channels_t *cc = &RC.nrmac[mod_id]->common_channels[cc_id]; + for (i = 0; i < NR_NB_RA_PROC_MAX; i++) { + if (cc->ra[i].rnti == rnti) { + LOG_D(MAC, "free RA process %d for rnti %d\n", i, rnti); + /* is it enough? */ + cc->ra[i].cfra = false; + cc->ra[i].rnti = 0; + cc->ra[i].crnti = 0; + } + } + } } uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) {