Skip to content

Commit

Permalink
(#104) add asan to CI, fix a memory leak in unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonlharvey committed Feb 9, 2024
1 parent edb51e6 commit ea4a835
Show file tree
Hide file tree
Showing 7 changed files with 654 additions and 7 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/unit_test_asan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Unit Tests (ASan)

# For more info and troubleshooting help for this workflow, see the Continuous Integration
# page in the GUNNS Wiki.

on:
push:
paths-ignore:
- 'README.md'
- 'draw/**'
- 'bin/utils/simbus_icd_input_gen/**'
- '.github/workflows/**'
- '!.github/workflows/unit_test_asan.yml'

jobs:
all_unit_tests:
runs-on: ubuntu-latest
container: docker://oraclelinux:8

steps:
- name: Update package manager
run: |
yum install -y yum-utils
dnf config-manager --set-enabled ol8_codeready_builder
yum repolist
yum install -y epel-release && yum update -y
- name: Install dependencies
run: yum install -y tcsh make gcc gcc-c++ cppunit cppunit-devel lcov valgrind python3

- name: Checkout repository
uses: actions/checkout@master

- name: Run tests
run: |
# Set environment variables
export GUNNS_HOME=`pwd`
export MS_UTILS_HOME="${GUNNS_HOME}/ms-utils"
export TS_MODELS_HOME="${GUNNS_HOME}/gunns-ts-models"
# Some unit tests can fail unless parallel make, probably a missing dependency
# in the UT makefiles...
export MAKEFLAGS="-j4"
# Set file permissions needed by the parsing test
chmod a-r ms-utils/parsing/test/file_no_permission.txt
chmod a-r ms-utils/parsing/test/nopermission
# Make & run unit tests
cd test
./make_all_ut_asan.sh
# Scan results for pass/fail
chmod +x scan_all_ut_asan.py
python3 ./scan_all_ut_asan.py
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ unit-tests
unit-tests.log
unit-tests.info
unit-tests-valgrind.log
asan.log*
main.d
output/
test/int_test/*/TEST_*
Expand All @@ -73,6 +74,7 @@ test/int_test/*/uit_logdata.d
test/ci/verification/verification
make_all_ut.out
make_all_ut_roses.out
make_all_ut_asan.out

# Ignore trick-generated makefiles for unit tests
Makefile.trick
Expand Down
3 changes: 2 additions & 1 deletion core/test/UtGunnsMinorStepLog.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
@copyright Copyright 2020 United States Government as represented by the Administrator of the
@copyright Copyright 2024 United States Government as represented by the Administrator of the
National Aeronautics and Space Administration. All Rights Reserved.
*/

Expand Down Expand Up @@ -444,6 +444,7 @@ void UtGunnsMinorStepLog::testRecord()
{
std::cout << "\n UtGunnsMinorStepLog .... 07: testRecord ............................";

tNetworkSize = 2;
tArticle->initialize(tName, tNetworkSize, tNumLinks, tLinks);

/// - Override the link's [A] and {w} arrays so we don't have to init the links.
Expand Down
8 changes: 7 additions & 1 deletion lib/test/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
################################################################################
# Copyright 2019 United States Government as represented by the Administrator of the
# Copyright 2024 United States Government as represented by the Administrator of the
# National Aeronautics and Space Administration. All Rights Reserved.
#
# This builds the Trick-less GUNNS compiled libraries for unit tests.
Expand Down Expand Up @@ -29,6 +29,12 @@
################################################################################
GUNNS_HOME ?= $(abspath ${PWD}/../..)

# Default options, enabling LCOV and Valgrind:
# For asan, we suggest calling this with overriding OPTS on the command line:
# $ make OPTS='-O2 -g -fstack-protector-all -fsanitize=address'
# Note that asan interferes with Valgrind, and any compilation with asan directives
# or inclusion of asan libraries breaks Valgrind, so its best to use them
# completely separately.
OPTS = -O2 -g -ftest-coverage -fprofile-arcs

GUNNSLIB := libgunns.a
Expand Down
Loading

0 comments on commit ea4a835

Please sign in to comment.