From 4af65b50e166ebf0b6fdeae8ec464dbb2bb820fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Kadl=C4=8D=C3=ADk?= Date: Wed, 22 Jan 2025 07:47:33 +0100 Subject: [PATCH] std module smoke test --- .../files/expected_stdout.txt | 1 + tests/Sanity/std_module-smoke/files/hello.cpp | 6 +++ tests/Sanity/std_module-smoke/main.fmf | 25 +++++++++ tests/Sanity/std_module-smoke/runtest.sh | 53 +++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 tests/Sanity/std_module-smoke/files/expected_stdout.txt create mode 100644 tests/Sanity/std_module-smoke/files/hello.cpp create mode 100644 tests/Sanity/std_module-smoke/main.fmf create mode 100755 tests/Sanity/std_module-smoke/runtest.sh diff --git a/tests/Sanity/std_module-smoke/files/expected_stdout.txt b/tests/Sanity/std_module-smoke/files/expected_stdout.txt new file mode 100644 index 0000000..a5c1966 --- /dev/null +++ b/tests/Sanity/std_module-smoke/files/expected_stdout.txt @@ -0,0 +1 @@ +Hello, world diff --git a/tests/Sanity/std_module-smoke/files/hello.cpp b/tests/Sanity/std_module-smoke/files/hello.cpp new file mode 100644 index 0000000..197bf24 --- /dev/null +++ b/tests/Sanity/std_module-smoke/files/hello.cpp @@ -0,0 +1,6 @@ +import std; +using namespace std::literals; +int main() { + std::println("Hello, {}", "world"s); + return 0; +} diff --git a/tests/Sanity/std_module-smoke/main.fmf b/tests/Sanity/std_module-smoke/main.fmf new file mode 100644 index 0000000..8cc5d28 --- /dev/null +++ b/tests/Sanity/std_module-smoke/main.fmf @@ -0,0 +1,25 @@ +summary: std module smoke test +enabled: true +adjust+: + - enabled: false + when: distro < fedora-42 + continue: false + - enabled: false + when: distro < rhel-11 and collection is not defined + continue: false + - enabled: false + when: distro < centos-stream-11 and collection is not defined + continue: false + - enabled: false + when: collection == gcc-toolset-14, gcc-toolset-13, devtoolset-13 + continue: false +contact: Vaclav Kadlcik +component: + - gcc +test: ${WITH_SCL:-bash} ./runtest.sh +framework: beakerlib +require+: + - gcc-c++ +duration: 10m +extra-summary: /tools/gcc/Sanity/std_module-smoke +extra-task: /tools/gcc/Sanity/std_module-smoke diff --git a/tests/Sanity/std_module-smoke/runtest.sh b/tests/Sanity/std_module-smoke/runtest.sh new file mode 100755 index 0000000..11f020d --- /dev/null +++ b/tests/Sanity/std_module-smoke/runtest.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +. /usr/share/beakerlib/beakerlib.sh || exit 1 +. "${0%/*}"/../../lib/common.sh || exit 1 + +# Relevancy: GCC > 14 + +GCC=${GCC:-$(type -P gcc)} +GCC_RPM_NAME=$(rpm --qf '%{name}' -qf "$GCC") +GXX_RPM_NAME=${GCC_RPM_NAME}-c++ + +# shellcheck disable=SC2034 +PACKAGES="${GCC_RPM_NAME} ${GXX_RPM_NAME}" + +rlJournalStart + rlPhaseStartSetup + rlLogInfo "GCC=$GCC" + rlLogInfo "GCC_RPM_NAME=$GCC_RPM_NAME" + rlLogInfo "SKIP_COLLECTION_METAPACKAGE_CHECK=$SKIP_COLLECTION_METAPACKAGE_CHECK" + + # We optionally need to skip checking for the presence of the metapackage + # because that would pull in all the dependent toolset subrpms. We do not + # always want that, especially in CI. + _COLLECTIONS="$COLLECTIONS" + if ! test -z "$SKIP_COLLECTION_METAPACKAGE_CHECK"; then + for c in $SKIP_COLLECTION_METAPACKAGE_CHECK; do + rlLogInfo "ignoring metapackage check for collection $c" + COLLECTIONS=$(shopt -s extglob && echo "${COLLECTIONS//$c/}"); export COLLECTIONS + done + fi + rlLogInfo "(without skipped) COLLECTIONS=$COLLECTIONS" + rlAssertRpm --all + export COLLECTIONS="$_COLLECTIONS" + + rlRun "TmpDir=\$(mktemp -d)" + # shellcheck disable=SC2154 + rlRun "cp files/* $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun 'g++ -std=c++23 -fsearch-include-path bits/std.cc -fmodules-ts hello.cpp' + rlRun './a.out >stdout.txt 2>stderr.txt' + rlAssertNotDiffer stdout.txt expected_stdout.txt + rlAssertNotDiffer stderr.txt /dev/null + rlPhaseEnd + + rlPhaseStartCleanup + rlRun popd + rlRun "rm -r $TmpDir" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd