Skip to content

Commit fa22e4a

Browse files
committed
cgroup-limit: support running test where DOTNET_PROCESSOR_COUNT is set.
1 parent a5baa20 commit fa22e4a

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

cgroup-limit/test.sh

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@ if [[ "$(stat -f -c "%T" /sys/fs/cgroup)" == "cgroup2fs" ]] ; then
1414
CGROUPV2=true
1515
fi
1616

17-
if [[ $CGROUPV2 == true ]] && [[ $(dotnet --version) == "3."* ]]; then
18-
echo "cgroup v2 is not fully supported on .NET Core 3.x. Skipping."
19-
exit 0
20-
fi
21-
22-
# For mono-based runtimes (ppc64le, s390x), cgroup support is only functional
23-
# on .NET 7.0 and later.
24-
if [[ "$(uname -m)" == "s390x" ]] || [[ "$(uname -m)" == "ppc64le" ]] ; then
25-
IFS='.-' read -ra VERSION <<< "${1:-$(dotnet --version)}"
26-
if [[ "${VERSION[0]}" -lt "7" ]]; then
27-
echo "cgroup support is not available on Mono-based runtimes before .NET 7. Skipping."
28-
exit 0
29-
fi
30-
fi
31-
3217
if [ -z "$(command -v systemctl)" ]; then
3318
echo "Environment does not use systemd"
3419
exit 0
@@ -41,18 +26,17 @@ if [ "$UID" != "0" ]; then
4126
if ! grep -q "cpu" "/sys/fs/cgroup/user.slice/user-$UID.slice/user@$UID.service/cgroup.controllers" ; then
4227
# user can't set cpu limits, use sudo.
4328
SYSTEMD_RUN="sudo -n $SYSTEMD_RUN"
44-
45-
# Pass DOTNET_ROOT to support testing against a dotnet tarball.
46-
# On RHEL 7 we don't pass the envvar because systemd-run doesn't support '-E' yet and the envvar is passed by default.
47-
if [[ "$runtime_id" != "rhel.7"* ]]; then
48-
SYSTEMD_RUN="$SYSTEMD_RUN -E DOTNET_ROOT=$DOTNET_ROOT"
49-
fi
5029
else
5130
# run on behalf of user.
5231
SYSTEMD_RUN="$SYSTEMD_RUN --user"
5332
fi
5433
fi
5534

35+
# Pass DOTNET_ROOT to support testing against a dotnet tarball.
36+
SYSTEMD_RUN="$SYSTEMD_RUN -E DOTNET_ROOT=$DOTNET_ROOT"
37+
# Unset DOTNET_PROCESSOR_COUNT so .NET won't return its value instead of the cgroup CPU limit.
38+
SYSTEMD_RUN="$SYSTEMD_RUN -E DOTNET_PROCESSOR_COUNT="
39+
5640
memory_args="-p MemoryLimit=100M"
5741
if [[ $CGROUPV2 == true ]]; then
5842
memory_args="-p MemoryMax=100M"

0 commit comments

Comments
 (0)