Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2034,7 +2034,8 @@ AC_CONFIG_FILES([Makefile
tests/unit/Makefile
tests/load/Makefile
tests/static-check/Makefile
tests/valgrind-check/Makefile])
tests/valgrind-check/Makefile
tests/asan-check/Makefile])

# Run autoconf/configure in libutils, generating necessary makefiles:
AC_CONFIG_SUBDIRS([libntech])
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
# (COSL) may apply to this file if you as a licensee so wish it. See
# included file COSL.txt.
#
SUBDIRS = unit load acceptance static-check valgrind-check
SUBDIRS = unit load acceptance static-check valgrind-check asan-check
6 changes: 6 additions & 0 deletions tests/asan-check/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ubuntu:24.04 AS build
RUN DEBIAN_FRONTEND=noninteractive apt-get update -y --fix-missing && \
DEBIAN_FRONTEND=noninteractive apt-get install -y libssl-dev libxml2-dev libpam0g-dev liblmdb-dev libacl1-dev libpcre2-dev librsync-dev git flex bison byacc automake make autoconf libtool
COPY . core
WORKDIR core
CMD bash tests/asan-check/run_checks.sh
25 changes: 25 additions & 0 deletions tests/asan-check/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright 2026 Northern.tech AS
#
# This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# To the extent this program is licensed as part of the Enterprise
# versions of CFEngine, the applicable Commercial Open Source License
# (COSL) may apply to this file if you as a licensee so wish it. See
# included file COSL.txt.
#

DISTFILES = run_checks.sh run.sh Makefile.in Makefile.am Containerfile
17 changes: 17 additions & 0 deletions tests/asan-check/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e
trap "echo FAILURE" ERR

set -x

cd "$(dirname "$0")"/../../

if which podman ; then
CLI="sudo podman --cgroup-manager=cgroupfs"
else
CLI="docker"
fi

$CLI build --tag ubuntu:mycfecontainer -f ./tests/asan-check/Containerfile .
$CLI run --rm ubuntu:mycfecontainer
27 changes: 27 additions & 0 deletions tests/asan-check/run_checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -x

function check_with_asan() {
local n_procs use_procs
n_procs="$(getconf _NPROCESSORS_ONLN)"
use_procs=$((n_procs/2))
if [ "$use_procs" -lt "1" ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [ "$use_procs" -lt "1" ]; then
if [ "$use_procs" -lt 1 ]; then

use_procs=1
fi

local asan_flags="-fsanitize=address"

./autogen.sh --enable-debug &&
make -j"${use_procs}" CFLAGS="-Werror -Wall -Wextra -Wno-sign-compare ${asan_flags}" LDFLAGS="${asan_flags}" &&
make -C tests/unit CFLAGS="${asan_flags}" LDFLAGS="${asan_flags}" check
}

cd "$(dirname "$0")"/../../

failure=0
if ! check_with_asan; then
echo "FAIL: ASAN compile/unit check failed";
failure=1;
fi
exit $failure
Comment on lines +22 to +27

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
failure=0
if ! check_with_asan; then
echo "FAIL: ASAN compile/unit check failed";
failure=1;
fi
exit $failure
if ! check_with_asan; then
echo "FAIL: ASAN compile/unit check failed";
exit 1;
fi

Loading