From 27d915dd21678c9acdcbf9b2d243082001f58cf6 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 16 Mar 2022 15:33:15 -0400 Subject: [PATCH] Initial draft of Alpine support --- apphost-framework-lookup/test.sh | 2 +- aspnet-same-runtime-version-2x/test.sh | 2 +- aspnet-same-runtime-version/test.sh | 2 +- aspnetpatch-21/test.sh | 2 +- assemblies-valid/AssembliesValid.cs | 2 +- bash-completion/get-completions.sh | 2 +- bash-completion/test.sh | 2 +- bundled-libunwind/test.sh | 2 +- cgroup-limit/test.sh | 8 ++++- commit-ids-in-binaries/test.sh | 2 +- createdump-aspnet/test.sh | 2 +- curl-certificate-store/test.sh | 2 +- debugging-sos-lldb-via-core-2x/test.sh | 2 +- debugging-sos-lldb-via-core/test.sh | 2 +- distribution-packages/test.sh | 5 ++- dotnet-info-commit-ids/test.sh | 2 +- extract-bundle-dir/test.sh | 2 +- fdd-no-nuget/test.sh | 4 +-- file-permissions/test.sh | 2 +- hardened-binaries/test.sh | 2 +- helloworld/test.sh | 2 +- install-location/test.sh | 2 +- liblttng-ust_sys-sdt.h/test.sh | 31 ++++++++++++++++--- libuv-kestrel-sample-app-2x/test.sh | 2 +- lttng/test.sh | 7 +++-- man-pages/test.sh | 9 ++++-- managed-symbols-available/test.sh | 2 +- omnisharp/test.sh | 5 ++- openssl-alpn/test.sh | 2 +- publish-ready-to-run-linux/test.sh | 2 +- publish-ready-to-run/test.sh | 2 +- restore-with-rid/test.sh | 2 +- runtime-id | 7 +++-- sdks-are-available/test.sh | 2 +- system-libcurl/test.sh | 2 +- system-libunwind/test.sh | 2 +- system-openssl/test.sh | 2 +- targeting-packs-bad-files/test.sh | 2 +- .../test-telemetry-tcpdump.sh | 2 +- telemetry-is-off-by-default/test.sh | 2 +- template-test/test.sh | 2 +- tool-dev-certs/test.sh | 2 +- use-apphost-from-sdk/test.sh | 2 +- use-current-runtime/test.sh | 2 +- workload/test.sh | 2 +- xunit-smoketest/test.sh | 2 +- 46 files changed, 98 insertions(+), 54 deletions(-) diff --git a/apphost-framework-lookup/test.sh b/apphost-framework-lookup/test.sh index bde3320..771b8b8 100755 --- a/apphost-framework-lookup/test.sh +++ b/apphost-framework-lookup/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash if [ -f /etc/profile ]; then source /etc/profile diff --git a/aspnet-same-runtime-version-2x/test.sh b/aspnet-same-runtime-version-2x/test.sh index 3c0c72f..0d2bedb 100755 --- a/aspnet-same-runtime-version-2x/test.sh +++ b/aspnet-same-runtime-version-2x/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/aspnet-same-runtime-version/test.sh b/aspnet-same-runtime-version/test.sh index 7e8509b..35a091d 100755 --- a/aspnet-same-runtime-version/test.sh +++ b/aspnet-same-runtime-version/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/aspnetpatch-21/test.sh b/aspnetpatch-21/test.sh index ffca7c2..c1be634 100755 --- a/aspnetpatch-21/test.sh +++ b/aspnetpatch-21/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail set -x diff --git a/assemblies-valid/AssembliesValid.cs b/assemblies-valid/AssembliesValid.cs index 3cf75b1..76b723c 100644 --- a/assemblies-valid/AssembliesValid.cs +++ b/assemblies-valid/AssembliesValid.cs @@ -44,7 +44,7 @@ public class AssembliesValid public void ValidateAssemblies() { string dotnetPath = null; - int exitCode = RunProcessAndGetOutput(new string[] { "command", "-v", "dotnet" }, out dotnetPath); + int exitCode = RunProcessAndGetOutput(new string[] { "bash", "-c", "\"command", "-v", "dotnet\"" }, out dotnetPath); if (exitCode != 0) { Console.Error.WriteLine("'dotnet' command not found"); diff --git a/bash-completion/get-completions.sh b/bash-completion/get-completions.sh index 431dc74..510c2b1 100755 --- a/bash-completion/get-completions.sh +++ b/bash-completion/get-completions.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash get_completion_function_name_from_complete_output() { diff --git a/bash-completion/test.sh b/bash-completion/test.sh index 9010509..3f63a1c 100755 --- a/bash-completion/test.sh +++ b/bash-completion/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/bundled-libunwind/test.sh b/bundled-libunwind/test.sh index 8743072..7a34a79 100755 --- a/bundled-libunwind/test.sh +++ b/bundled-libunwind/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/cgroup-limit/test.sh b/cgroup-limit/test.sh index 413ba78..5bbf263 100755 --- a/cgroup-limit/test.sh +++ b/cgroup-limit/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail @@ -13,6 +13,12 @@ if [[ "$(stat -f -c "%T" /sys/fs/cgroup)" == "cgroup2fs" ]] && [[ $(dotnet --ver exit 0 fi + +if [ -z "$(command -v systemctl)" ]; then + echo "Environment does not use systemd" + exit 0 +fi + dotnet publish SYSTEMD_RUN="systemd-run" diff --git a/commit-ids-in-binaries/test.sh b/commit-ids-in-binaries/test.sh index 4ee952a..5f6bfb0 100755 --- a/commit-ids-in-binaries/test.sh +++ b/commit-ids-in-binaries/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # .NET Core native binaries (coreclr.so, System.Native.so) contain a # commit id as text somewhere in the binary. For example diff --git a/createdump-aspnet/test.sh b/createdump-aspnet/test.sh index e0af909..c14d807 100755 --- a/createdump-aspnet/test.sh +++ b/createdump-aspnet/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Enable "unofficial bash strict mode" set -euo pipefail diff --git a/curl-certificate-store/test.sh b/curl-certificate-store/test.sh index a74161f..39cb11c 100755 --- a/curl-certificate-store/test.sh +++ b/curl-certificate-store/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/debugging-sos-lldb-via-core-2x/test.sh b/debugging-sos-lldb-via-core-2x/test.sh index 8d28bdf..8b307af 100755 --- a/debugging-sos-lldb-via-core-2x/test.sh +++ b/debugging-sos-lldb-via-core-2x/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Check whether coredumps produced by .NET Core can be used by sos # successfully. This test uses the built-in CoreCLR sos support, not diff --git a/debugging-sos-lldb-via-core/test.sh b/debugging-sos-lldb-via-core/test.sh index 6ee806c..12d2590 100755 --- a/debugging-sos-lldb-via-core/test.sh +++ b/debugging-sos-lldb-via-core/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Check whether coredumps produced by .NET Core can be used by sos # successfully. This test uses the `dotnet sos` global tool. diff --git a/distribution-packages/test.sh b/distribution-packages/test.sh index 01a2405..f6b29d0 100755 --- a/distribution-packages/test.sh +++ b/distribution-packages/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail @@ -8,6 +8,9 @@ runtime_id=$(../runtime-id) # This might be the final/only netstandard version from now on netstandard_version=2.1 +# disabled for alpine +[ -z "${runtime_id##alpine*}" ] && { echo Disabled for Alpine; exit 0; } + ./test-standard-packages \ "${runtime_id}" \ "${runtime_version}" "${runtime_version}" \ diff --git a/dotnet-info-commit-ids/test.sh b/dotnet-info-commit-ids/test.sh index 04debe7..7358001 100755 --- a/dotnet-info-commit-ids/test.sh +++ b/dotnet-info-commit-ids/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # unofficial bash strict mode set -euo pipefail diff --git a/extract-bundle-dir/test.sh b/extract-bundle-dir/test.sh index 0d96031..0733c36 100755 --- a/extract-bundle-dir/test.sh +++ b/extract-bundle-dir/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # The profile file sets DOTNET_BUNDLE_EXTRACT_BASE_DIR to avoid multi-user issues. # see: https://bugzilla.redhat.com/show_bug.cgi?id=1752350. diff --git a/fdd-no-nuget/test.sh b/fdd-no-nuget/test.sh index d00fd29..b49b0f2 100755 --- a/fdd-no-nuget/test.sh +++ b/fdd-no-nuget/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash set +x @@ -21,4 +21,4 @@ if [ $? -eq 1 ]; then exit 1 fi -echo "PASS: successfully published FDD without nuget.org access" \ No newline at end of file +echo "PASS: successfully published FDD without nuget.org access" diff --git a/file-permissions/test.sh b/file-permissions/test.sh index 7a4b126..cd3c60c 100755 --- a/file-permissions/test.sh +++ b/file-permissions/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' diff --git a/hardened-binaries/test.sh b/hardened-binaries/test.sh index 81f8e85..bbe14d6 100755 --- a/hardened-binaries/test.sh +++ b/hardened-binaries/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' diff --git a/helloworld/test.sh b/helloworld/test.sh index 9de4d32..96458b1 100755 --- a/helloworld/test.sh +++ b/helloworld/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/install-location/test.sh b/install-location/test.sh index 274f734..c89ecc9 100755 --- a/install-location/test.sh +++ b/install-location/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' diff --git a/liblttng-ust_sys-sdt.h/test.sh b/liblttng-ust_sys-sdt.h/test.sh index 7ab7597..fcdc07a 100755 --- a/liblttng-ust_sys-sdt.h/test.sh +++ b/liblttng-ust_sys-sdt.h/test.sh @@ -1,22 +1,43 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail set -x +RUNTIME_ID=$(../runtime-id) set +e # disable abort-on-error so we can have the pipeline below fail -packageName=$(rpm -qa | grep 'dotnet.*lttng-ust') +case $RUNTIME_ID in + alpine*)packageName=$(apk list dotnet*lttng-ust);; + *)packageName=$(rpm -qa | grep 'dotnet.*lttng-ust');; +esac set -e # If a dotnet-specific lttng package doesn't exist, we must be using # the normal system-wide lttng package. if [[ -z "$packageName" ]]; then - packageName=$(rpm -qa | grep 'lttng-ust') + case $RUNTIME_ID in + alpine*) + packageName="lttng-ust" + ;; + *) + packageName=$(rpm -qa | grep 'lttng-ust') + ;; + esac fi -filePath=$(rpm -ql "$packageName" | grep -E 'liblttng-ust.so.[01]$') +# If a dotnet-specific lttng package doesn't exist, we must be using +# the normal system-wide lttng package. +case $RUNTIME_ID in + alpine*) + filePath="/$(apk info -L "$packageName" | grep -E 'liblttng-ust.so.[01]$')" + ;; + *) + filePath=$(rpm -ql "$packageName" | grep -E 'liblttng-ust.so.[01]$') + ;; +esac + readelf -n "$filePath" | grep -F 'NT_STAPSDT (SystemTap probe descriptors)' if [[ $? -eq 1 ]]; then - echo "NO NT_STAPSDT were found in lttng-ust: FAL" + echo "NO NT_STAPSDT were found in lttng-ust: FAIL" exit 1 fi diff --git a/libuv-kestrel-sample-app-2x/test.sh b/libuv-kestrel-sample-app-2x/test.sh index 3f8b1f5..24eaacf 100755 --- a/libuv-kestrel-sample-app-2x/test.sh +++ b/libuv-kestrel-sample-app-2x/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/lttng/test.sh b/lttng/test.sh index 01c7ac0..7a06aac 100755 --- a/lttng/test.sh +++ b/lttng/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail @@ -49,8 +49,11 @@ wait $DOTNET_PID echo "== Ending lttng session" end_session +CMD="$(command -v babeltrace || true)" +[ -z "${CMD}" ] && CMD="$(command -v babeltrace2)" + # Retrieve trace -LTTNG_TRACE=$(babeltrace "$TRACE_FOLDER/ust/uid/$(id -u)/64-bit" | grep "vpid = $DOTNET_PID") +LTTNG_TRACE=$($CMD "$TRACE_FOLDER/ust/uid/$(id -u)/64-bit" | grep "vpid = $DOTNET_PID") # Clean up remove_test_folder diff --git a/man-pages/test.sh b/man-pages/test.sh index 7a8bba6..b06b41d 100755 --- a/man-pages/test.sh +++ b/man-pages/test.sh @@ -1,9 +1,14 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail helpPages=$(dotnet --help | grep -A 999 'SDK commands' | grep -E -B 999 'Common options|Additional commands' | awk 'NR>1 {print $1}' | head -n-2) -manPages=$(rpm -qd $(rpm -qa | grep 'dotnet') | grep 'man1/dotnet-') + +RUNTIME_ID=$(../runtime-id) +case $RUNTIME_ID in + alpine*)manPages=$(apk info -L dotnet-doc);; + *)manPages=$(rpm -qd $(rpm -qa | grep 'dotnet') | grep 'man1/dotnet-');; +esac failed=0 for page in $helpPages; do diff --git a/managed-symbols-available/test.sh b/managed-symbols-available/test.sh index b733091..c5d819b 100755 --- a/managed-symbols-available/test.sh +++ b/managed-symbols-available/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Check that managed symbol files are available diff --git a/omnisharp/test.sh b/omnisharp/test.sh index 741508b..3bf73d7 100755 --- a/omnisharp/test.sh +++ b/omnisharp/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' @@ -11,6 +11,9 @@ pushd workdir runtime_id="$(../../runtime-id --portable)" +# disabled for alpine +[ -z "${runtime_id##*musl*}" ] && { echo No musl release of omnisharp, disabled; exit 0; } + wget --no-verbose "https://github.com/OmniSharp/omnisharp-roslyn/releases/latest/download/omnisharp-${runtime_id}.tar.gz" mkdir omnisharp diff --git a/openssl-alpn/test.sh b/openssl-alpn/test.sh index 6511eee..2f92afd 100755 --- a/openssl-alpn/test.sh +++ b/openssl-alpn/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Make sure .NET Core has linked to SSL_*_alpn_* functions from OpenSSL diff --git a/publish-ready-to-run-linux/test.sh b/publish-ready-to-run-linux/test.sh index f8b6e93..42a044c 100755 --- a/publish-ready-to-run-linux/test.sh +++ b/publish-ready-to-run-linux/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash set -euo pipefail set -x diff --git a/publish-ready-to-run/test.sh b/publish-ready-to-run/test.sh index d765181..03cacdd 100755 --- a/publish-ready-to-run/test.sh +++ b/publish-ready-to-run/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash set -euo pipefail set -x diff --git a/restore-with-rid/test.sh b/restore-with-rid/test.sh index 3c08019..d6581e8 100755 --- a/restore-with-rid/test.sh +++ b/restore-with-rid/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash set -euo pipefail set -x diff --git a/runtime-id b/runtime-id index 3224860..6b21c33 100755 --- a/runtime-id +++ b/runtime-id @@ -38,11 +38,14 @@ while [[ $# -gt 0 ]]; do done if [[ ${portable_rid} == 1 ]]; then - echo "linux-${arch}" + case "${ID}" in + alpine)echo "linux-musl-${arch}" ;; + *) echo "linux-${arch}" ;; + esac else case "${ID}" in # Remove the RHEL minor version - rhel) rid_version=${VERSION_ID%.*} ;; + rhel|alpine|rocky) rid_version=${VERSION_ID%.*} ;; *) rid_version=${VERSION_ID} ;; esac diff --git a/sdks-are-available/test.sh b/sdks-are-available/test.sh index 0abdee4..2847b91 100755 --- a/sdks-are-available/test.sh +++ b/sdks-are-available/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' diff --git a/system-libcurl/test.sh b/system-libcurl/test.sh index 1f13dc6..33c7cf9 100755 --- a/system-libcurl/test.sh +++ b/system-libcurl/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/system-libunwind/test.sh b/system-libunwind/test.sh index 7396685..d6239a5 100755 --- a/system-libunwind/test.sh +++ b/system-libunwind/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/system-openssl/test.sh b/system-openssl/test.sh index 00cebc5..b98625d 100755 --- a/system-openssl/test.sh +++ b/system-openssl/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Make sure .NET has ldd-visible links to OpenSSL. We prefer that over # using OpenSSL via dlopen (which is more likely to fail at runtime). diff --git a/targeting-packs-bad-files/test.sh b/targeting-packs-bad-files/test.sh index 713a68e..2e20b7c 100755 --- a/targeting-packs-bad-files/test.sh +++ b/targeting-packs-bad-files/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/telemetry-is-off-by-default/test-telemetry-tcpdump.sh b/telemetry-is-off-by-default/test-telemetry-tcpdump.sh index 5c0c360..d391c5d 100755 --- a/telemetry-is-off-by-default/test-telemetry-tcpdump.sh +++ b/telemetry-is-off-by-default/test-telemetry-tcpdump.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This test is *NOT* executed by default. diff --git a/telemetry-is-off-by-default/test.sh b/telemetry-is-off-by-default/test.sh index b9e42c2..d0bcd65 100755 --- a/telemetry-is-off-by-default/test.sh +++ b/telemetry-is-off-by-default/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This test ensures telemetry is not being sent for (some) commands by # checking that no network connections are being made when not diff --git a/template-test/test.sh b/template-test/test.sh index cc21f6c..dc16698 100755 --- a/template-test/test.sh +++ b/template-test/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # this file tests templates created by # dotnet new