Skip to content

Commit 5b89d02

Browse files
authored
Merge pull request #5947 from larsewi/ent-12619/master
ENT-12619, CFE-4605, CFE-4606: Various fixes to acceptance tests and CI scripts
2 parents e639010 + ea0fd73 commit 5b89d02

File tree

11 files changed

+108
-71
lines changed

11 files changed

+108
-71
lines changed

ci/configure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cd "$thisdir"/..
77
OPTS="--enable-debug"
88

99
if [ -n "$TERMUX_VERSION" ]; then
10-
OPTS="$OPTS --without-pam"
10+
OPTS="$OPTS --without-pam"
1111
fi
1212

1313
./autogen.sh $OPTS

ci/dependencies.sh

Lines changed: 71 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,83 @@ set -ex
44

55
GAINROOT=""
66
if [ "$(id -u)" != "0" ]; then
7-
GAINROOT="sudo"
8-
if ! command -v sudo >/dev/null; then
9-
echo "Sorry, either run $0 as root or install sudo."
10-
exit 1
11-
fi
7+
GAINROOT="sudo"
8+
if ! command -v sudo >/dev/null; then
9+
echo "Sorry, either run $0 as root or install sudo."
10+
exit 1
11+
fi
1212
fi
1313

14+
build_lmdb() {
15+
if [ -f /usr/include/lmdb.h ]; then
16+
echo lmdb libraries already installed, no-op.
17+
return
18+
fi
19+
tmpdir="$(mktemp -d)"
20+
echo building lmdb in "$tmpdir"
21+
(
22+
cd "$tmpdir"
23+
git clone --recursive --depth 1 https://github.com/LMDB/lmdb
24+
cd lmdb/libraries/liblmdb
25+
make
26+
$GAINROOT make install prefix=/usr
27+
)
28+
}
29+
30+
build_librsync() {
31+
tmpdir="$(mktemp -d)"
32+
echo building librsync in "$tmpdir"
33+
(
34+
cd "$tmpdir"
35+
git clone --recursive --depth 1 https://github.com/librsync/librsync
36+
cd librsync
37+
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release .
38+
make
39+
$GAINROOT make install
40+
)
41+
}
42+
1443
# limited support here, focused on rhel-like on aarch64 which has no previous CFEngine version to leverage: ENT-13016
1544
if [ -f /etc/os-release ]; then
16-
source /etc/os-release
17-
VERSION_MAJOR=${VERSION_ID%.*}
18-
if [ "$ID" = "rhel" ] || [[ "$ID_LIKE" =~ "rhel" ]]; then
19-
if [ "$VERSION_MAJOR" -ge "10" ]; then
20-
# note that having a redhat subscription makes things easier: lmdb-devel and librsync-devel are available from codeready-builder repo
21-
if subscription-manager status; then
22-
$GAINROOT subscription-manager config --rhsm.manage_repos=1
23-
$GAINROOT subscription-manager repos --enable codeready-builder-for-rhel-"$VERSION_MAJOR"-"$(uname -m)"-rpms
24-
$GAINROOT dnf install --assumeyes https://dl.fedoraproject.org/pub/epel/epel-release-latest-"$VERSION_MAJOR".noarch.rpm
25-
$GAINROOT dnf install --assumeyes flex-devel lmdb-devel librsync-devel fakeroot # only available via subscription with codeready-builder installed
26-
# flex-devel, libyaml-devel and fakeroot are also only available easily from codeready-builder but are not critical to building CFEngine usable enough to configure a build host.
27-
# fakeroot is only needed for running tests but can be worked around by using GAINROOT=env with tests/acceptance/testall script
28-
else
29-
# here we assume no subscription and so must build those two dependencies from source :)
30-
$GAINROOT yum groups install -y 'Development Tools'
31-
$GAINROOT yum update --assumeyes
32-
$GAINROOT yum install -y gcc gdb make git libtool autoconf automake byacc flex openssl-devel pcre2-devel pam-devel libxml2-devel
33-
tmpdir="$(mktemp -d)"
34-
echo "Building lmdb and librsync in $tmpdir"
35-
(
36-
cd "$tmpdir"
37-
git clone --recursive --depth 1 https://github.com/LMDB/lmdb
38-
cd lmdb/libraries/liblmdb
39-
make
40-
$GAINROOT make install prefix=/usr
41-
cd -
42-
$GAINROOT dnf install -y cmake
43-
git clone --recursive --depth 1 https://github.com/librsync/librsync
44-
cd librsync
45-
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release .
46-
make
47-
$GAINROOT make install
48-
)
49-
fi
45+
source /etc/os-release
46+
VERSION_MAJOR=${VERSION_ID%.*}
47+
if [[ "$ID_LIKE" =~ "suse" ]]; then
48+
$GAINROOT zypper -qn install gdb gcc make lmdb autoconf automake libtool git python3 pcre2-devel libopenssl-devel pam-devel cmake flex byacc
49+
build_lmdb
50+
build_librsync
51+
elif [ "$ID" = "rhel" ] || [[ "$ID_LIKE" =~ "rhel" ]]; then
52+
if [ "$VERSION_MAJOR" -ge "10" ]; then
53+
# note that having a redhat subscription makes things easier: lmdb-devel and librsync-devel are available from codeready-builder repo
54+
if subscription-manager status; then
55+
$GAINROOT subscription-manager config --rhsm.manage_repos=1
56+
$GAINROOT subscription-manager repos --enable codeready-builder-for-rhel-"$VERSION_MAJOR"-"$(uname -m)"-rpms
57+
$GAINROOT dnf install --assumeyes https://dl.fedoraproject.org/pub/epel/epel-release-latest-"$VERSION_MAJOR".noarch.rpm
58+
$GAINROOT dnf install --assumeyes autoconf automake
59+
$GAINROOT dnf install --assumeyes gcc gdb make git libtool autoconf automake byacc flex openssl-devel pcre2-devel lmdb-devel pam-devel flex-devel libyaml-devel fakeroot libxml2-devel librsync-devel
60+
# flex-devel, libyaml-devel and fakeroot are also only available easily from codeready-builder but are not critical to building CFEngine usable enough to configure a build host.
61+
# fakeroot is only needed for running tests but can be worked around by using GAINROOT=env with tests/acceptance/testall script
62+
else
63+
# here we assume no subscription and so must build those two dependencies from source :)
64+
$GAINROOT yum groups install --assumeyes 'Development Tools'
65+
$GAINROOT yum update --assumeyes
66+
# cmake is for building librsync
67+
$GAINROOT yum install --assumeyes gcc gdb make git libtool autoconf automake byacc flex openssl-devel pcre2-devel pam-devel libxml2-devel cmake
68+
build_lmdb
69+
build_librsync
70+
fi
71+
else
72+
echo "Unsupported version of redhat for $0"
73+
exit 1
74+
fi
75+
elif [ "$ID" = "debian" ] || [[ "$ID_LIKE" =~ "debian" ]]; then
76+
$GAINROOT apt update --yes
77+
$GAINROOT apt install --yes build-essential git libtool autoconf automake bison flex libssl-dev libpcre2-dev libbison-dev libacl1 libacl1-dev lmdb-utils liblmdb-dev libpam0g-dev libtool libyaml-dev libxml2-dev librsync-dev
5078
else
51-
echo "Unsupported version of redhat for $0"
52-
exit 1
79+
echo "Unsupported distribution based on /etc/os-release."
5380
fi
54-
elif [ "$ID" = "debian" ] || [[ "$ID_LIKE" =~ "debian" ]]; then
55-
$GAINROOT apt update -y
56-
$GAINROOT apt install -y build-essential git libtool autoconf automake bison flex libssl-dev libpcre2-dev libbison-dev libacl1 libacl1-dev lmdb-utils liblmdb-dev libpam0g-dev libtool libyaml-dev libxml2-dev librsync-dev
57-
else
58-
echo "Unsupported distribution based on /etc/os-release."
59-
fi
6081
elif [ -n "$TERMUX_VERSION" ]; then
61-
pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml
82+
pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml
6283
else
63-
echo "Unsupported operating system for $0"
64-
exit 1
84+
echo "Unsupported operating system for $0"
85+
exit 1
6586
fi
66-

ci/install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ thisdir=$(dirname $0)
88
cd "$thisdir"/..
99
GAINROOT=""
1010
if [ ! -n "$TERMUX_VERSION" ]; then
11-
if [ "$(id -u)" != "0" ]; then
12-
if ! command -v sudo >/dev/null; then
13-
echo "Sorry, run $0 as root or install and configure sudo."
14-
exit 1
11+
if [ "$(id -u)" != "0" ]; then
12+
if ! command -v sudo >/dev/null; then
13+
echo "Sorry, run $0 as root or install and configure sudo."
14+
exit 1
15+
fi
16+
GAINROOT="sudo"
1517
fi
16-
GAINROOT="sudo"
17-
fi
1818
fi
1919

2020
$GAINROOT make install

tests/acceptance/01_vars/01_basic/policy_release_id.cf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
body common control
22
{
3-
bundlesequence => { "test" };
3+
inputs => { "../../default.cf.sub" };
4+
bundlesequence => { default("$(this.promise_filename)") };
5+
version => "1.0";
46
}
57

68

79
bundle agent test
810
{
11+
meta:
12+
"test_skip_needs_work"
13+
string => "aix",
14+
meta => { "CFE-4606" };
15+
916
vars:
1017
"release_id_list" slist => variablesmatching("default:sys.policy_release_id");
1118
"escaped" string => escape("$(sys.policy_entry_dirname)");

tests/acceptance/01_vars/02_functions/findlocalgroups.cf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bundle agent test
3535
{
3636
meta:
3737
"test_soft_fail"
38-
string => "!linux|(termux|android)",
38+
string => "(!linux&!solaris)|(termux|android)",
3939
meta => { "CFE-2318" };
4040
vars:
4141
"glist1"

tests/acceptance/01_vars/02_functions/findlocalusers.cf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ bundle agent init
2828
bundle agent test
2929
{
3030
meta:
31-
"test_soft_fail" string => "windows|aix|solaris",
31+
"test_soft_fail" string => "windows|aix|solaris|redhat_10",
32+
comment => "redhat_10 user name is 'Super User' not 'root'",
3233
meta => { "CFE-2318" };
3334

3435
vars:

tests/acceptance/01_vars/02_functions/getgroups.cf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
body common control
88
{
99
inputs => { "../../default.cf.sub" };
10-
bundlesequence => { check };
10+
bundlesequence => { default("$(this.promise_filename)") };
1111
version => "1.0";
1212
}
1313

@@ -16,6 +16,13 @@ bundle agent check
1616
meta:
1717
"description" -> { "ENT-12722" }
1818
string => "Test whether the entries of getroups() are like the ones inside /etc/group";
19+
"test_skip_needs_work"
20+
string => "suse_15|sles_15|aix",
21+
comment => "expects first three groups are root, bin, daemon. However, on:
22+
- suse_15 they are root, shadow, trusted.
23+
- aix they are root, daemon, bin (i.e. different order).",
24+
meta => { "ENT-13504", "CFE-4605" };
25+
1926
"test_skip_unsupported"
2027
string => "windows";
2128
vars:

tests/acceptance/01_vars/02_functions/unsafe/findlocalusers_unsafe.cf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ bundle agent init
5151
bundle agent test
5252
{
5353
meta:
54-
"test_soft_fail" string => "windows|aix|solaris",
54+
"test_soft_fail" string => "windows|aix|solaris|redhat_10",
55+
comment => "RedHat 10 root user is named 'Super User' not 'root'",
5556
meta => { "CFE-2318" };
5657

5758
vars:

tests/acceptance/05_processes/01_matching/select_without_result.cf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ bundle agent test
3636
meta:
3737
# This test exposes a known issue with processes on the Windows platform.
3838
"test_soft_fail"
39-
string => "windows",
40-
meta => {"ENT-12751"};
39+
string => "windows|solaris",
40+
meta => { "ENT-12751", "ENT-13505" };
4141

4242
"description" -> {"CFE-4511"}
4343
string => "process_select body without process_result";

tests/acceptance/16_cf-serverd/serial/copy_from_ciphers_success.cf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ body common control
88
bundle agent test
99
{
1010
meta:
11-
"test_soft_fail" string => "windows",
12-
meta => { "ENT-10401" };
11+
"test_soft_fail" string => "windows|redhat_10",
12+
meta => { "ENT-10401", "ENT-13494" };
1313

1414
methods:
1515
# source file

0 commit comments

Comments
 (0)