Skip to content

Commit

Permalink
add analysis and coverage to CDash reports (#4938)
Browse files Browse the repository at this point in the history
* Add sanitzers and coverage workflows
* add UndefinedBehavior sanitize
  • Loading branch information
byrnHDF authored Oct 10, 2024
1 parent 68bffcd commit 6e8c7a9
Show file tree
Hide file tree
Showing 10 changed files with 473 additions and 134 deletions.
419 changes: 419 additions & 0 deletions .github/workflows/cmake-analysis.yml

Large diffs are not rendered by default.

108 changes: 1 addition & 107 deletions .github/workflows/cmake-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,7 @@ jobs:
env:
FC: ${{ steps.setup-fortran.outputs.fc }}
CC: ${{ steps.setup-fortran.outputs.cc }}
CXX: ${{ steps.setup-fortran.outputs.cxx }}
BINSIGN: ${{ needs.check-secret.outputs.sign-state }}
SIGNTOOLDIR: ${{ github.workspace }}/Microsoft.Windows.SDK.BuildTools/bin/10.0.22621.0/x64
CXX: ${{ steps.setup-fortran.outputs.cc }}
run: |
cd "${{ runner.workspace }}/hdf5"
ctest -S HDF5config.cmake,CTEST_SITE_EXT=GH-Intel,LOCAL_SUBMIT=ON,NINJA=TRUE,BUILD_GENERATOR=VS202264,CTEST_SOURCE_NAME=${{ steps.set-file-base.outputs.SOURCE_BASE }} -C Release -VV -O hdf5.log
Expand Down Expand Up @@ -603,110 +601,6 @@ jobs:
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`

####### clang builds
build_and_test_win_clang:
# Windows w/ clang + CMake
#
name: "Windows ClangCL CTest"
runs-on: windows-latest
steps:
- name: Install Dependencies (Windows_clang)
run: choco install ninja

- name: add clang to env
uses: KyleMayes/[email protected]
id: setup-clang
with:
env: true
version: '18'

- name: Set file base name (Windows_clang)
id: set-file-base
run: |
FILE_NAME_BASE=$(echo "${{ inputs.file_base }}")
echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT
if [[ '${{ inputs.use_environ }}' == 'release' ]]
then
SOURCE_NAME_BASE=$(echo "${{ inputs.snap_name }}")
else
SOURCE_NAME_BASE=$(echo "hdfsrc")
fi
echo "SOURCE_BASE=$SOURCE_NAME_BASE" >> $GITHUB_OUTPUT
shell: bash

# Get files created by release script
- name: Get zip-tarball (Windows_clang)
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: zip-tarball
path: ${{ github.workspace }}

- name: using powershell
shell: pwsh
run: Get-Location

- name: List files for the space (Windows_clang)
run: |
Get-ChildItem -Path ${{ github.workspace }}
Get-ChildItem -Path ${{ runner.workspace }}
shell: pwsh

- name: Uncompress source (Windows_clang)
working-directory: ${{ github.workspace }}
run: 7z x ${{ steps.set-file-base.outputs.FILE_BASE }}.zip
shell: bash

- name: Copy script files for the space (Windows_clang)
run: |
Copy-Item -Path ${{ runner.workspace }}/hdf5/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/CTestScript.cmake -Destination ${{ runner.workspace }}/hdf5/
Copy-Item -Path ${{ runner.workspace }}/hdf5/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/HDF5config.cmake -Destination ${{ runner.workspace }}/hdf5/
shell: pwsh

- name: List files for the hdf5 (Windows_clang)
run: |
Get-ChildItem -Path ${{ runner.workspace }}/hdf5
shell: pwsh

- name: Create options file (Windows_clang)
uses: "DamianReeves/write-file-action@master"
with:
path: ${{ runner.workspace }}/hdf5/HDF5options.cmake
write-mode: overwrite
contents: |
set (CTEST_DROP_SITE_INIT "my.cdash.org")
# Change following line to submit to your CDash dashboard to a different CDash project
#set (CTEST_DROP_LOCATION_INIT "/submit.php?project=HDF5")
set (SITE_BUILDNAME_SUFFIX "${{ steps.set-file-base.outputs.FILE_BASE }}")
#set (CMAKE_GENERATOR_TOOLSET "ClangCL")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} --log-level=VERBOSE")
#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/clang.cmake")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=ON")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=ON")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
- name: Run ctest (Windows_clang) with clang
env:
BINSIGN: ${{ needs.check-secret.outputs.sign-state }}
SIGNTOOLDIR: ${{ github.workspace }}/Microsoft.Windows.SDK.BuildTools/bin/10.0.22621.0/x64
run: |
cd "${{ runner.workspace }}/hdf5"
ctest -S HDF5config.cmake,CTEST_SITE_EXT=GH-Clang,LOCAL_SUBMIT=ON,NINJA=TRUE,BUILD_GENERATOR=VS202264,CTEST_SOURCE_NAME=${{ steps.set-file-base.outputs.SOURCE_BASE }} -C Release -VV -O hdf5.log
shell: pwsh
continue-on-error: true

# Save log files created by ctest script
- name: Save log (Windows_clang)
uses: actions/upload-artifact@v4
with:
name: clang-win-log
path: ${{ runner.workspace }}/hdf5/hdf5.log
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`

build_and_test_linux_clang:
# Linux (Ubuntu) w/ clang + CMake
#
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/daily-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: hdf5 dev daily build

# Triggers the workflow on a schedule or on demand
# Triggers the workflow on demand or on a call from another workflow
# NOTE: inputs must be duplicated between triggers
on:
workflow_dispatch:
inputs:
Expand All @@ -9,8 +10,13 @@ on:
type: string
required: false
default: check
schedule:
- cron: "6 0 * * *"
workflow_call:
inputs:
use_ignore:
description: 'Ignore has_changes check'
type: string
required: false
default: check

permissions:
contents: read
Expand Down Expand Up @@ -61,6 +67,14 @@ jobs:
use_environ: snapshots
if: ${{ ((needs.call-workflow-tarball.outputs.has_changes == 'true') || (needs.get-old-names.outputs.run-ignore == 'ignore')) }}

call-workflow-sanitizers:
needs: [get-old-names, call-workflow-tarball]
uses: ./.github/workflows/cmake-analysis.yml
with:
file_base: ${{ needs.call-workflow-tarball.outputs.file_base }}
use_environ: snapshots
if: ${{ ((needs.call-workflow-tarball.outputs.has_changes == 'true') || (needs.get-old-names.outputs.run-ignore == 'ignore')) }}

call-workflow-ctest:
needs: [get-old-names, call-workflow-tarball]
uses: ./.github/workflows/cmake-ctest.yml
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/daily-schedule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: hdf5 dev daily build on schedule

# Triggers the workflow on a schedule or on demand
on:
workflow_dispatch:
schedule:
- cron: "6 0 * * *"

permissions:
contents: write # In order to allow tag creation and file deletion

jobs:
daily-build:
uses: ./.github/workflows/daily-build.yml
with:
use_ignore: check
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,10 @@ option (HDF5_ENABLE_COVERAGE "Enable code coverage for Libraries and Programs" O
if (HDF5_ENABLE_COVERAGE)
include (${HDF5_SOURCE_DIR}/config/sanitizer/code-coverage.cmake)
if(CODE_COVERAGE AND CODE_COVERAGE_ADDED)
message(VERBOSE "Add instrumentation to all targets")
add_code_coverage () # Adds instrumentation to all targets
else ()
message(VERBOSE "Use --coverage option")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g --coverage -O0 -fprofile-arcs -ftest-coverage")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
Expand Down
7 changes: 4 additions & 3 deletions config/cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ if (WIN32 AND NOT MINGW)
set (${HDF_PREFIX}_HAVE_VISUAL_STUDIO 1)
endif ()
endif ()
message (TRACE "MSVC=${MSVC}")
message (TRACE "HAVE_VISUAL_STUDIO=${${HDF_PREFIX}_HAVE_VISUAL_STUDIO}")
endif ()

if (WINDOWS)
Expand All @@ -79,13 +81,12 @@ if (WINDOWS)
endif ()
if (NOT UNIX AND NOT CYGWIN)
set (${HDF_PREFIX}_HAVE_GETCONSOLESCREENBUFFERINFO 1)
if (MSVC_VERSION GREATER_EQUAL 1900)
set (${HDF_PREFIX}_HAVE_TIMEZONE 1)
endif ()
set (${HDF_PREFIX}_HAVE_TIMEZONE 1)
set (${HDF_PREFIX}_HAVE_GETTIMEOFDAY 1)
set (${HDF_PREFIX}_HAVE_LIBWS2_32 1)
set (${HDF_PREFIX}_HAVE_LIBWSOCK32 1)
endif ()
message (TRACE "HAVE_TIMEZONE=${${HDF_PREFIX}_HAVE_TIMEZONE}")
endif ()

# ----------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions config/sanitizer/code-coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ option(

# Programs
find_program(LLVM_COV_PATH llvm-cov)
message(VERBOSE "program llvm-cov=${LLVM_COV_PATH}")
find_program(LLVM_PROFDATA_PATH llvm-profdata)
message(VERBOSE "program llvm-profdata=${LLVM_PROFDATA_PATH}")
find_program(LCOV_PATH lcov)
message(VERBOSE "program lcov=${LCOV_PATH}")
find_program(GENHTML_PATH genhtml)
message(VERBOSE "program genhtml=${GENHTML_PATH}")
# Hide behind the 'advanced' mode flag for GUI/ccmake
mark_as_advanced(FORCE LLVM_COV_PATH LLVM_PROFDATA_PATH LCOV_PATH GENHTML_PATH)

Expand Down
6 changes: 5 additions & 1 deletion config/toolchain/intel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
set(CMAKE_COMPILER_VENDOR "intel")

set(CMAKE_C_COMPILER icx)
set(CMAKE_CXX_COMPILER icpx)
if(WIN32)
set(CMAKE_CXX_COMPILER icx)
else()
set(CMAKE_CXX_COMPILER icpx)
endif()
set(CMAKE_Fortran_COMPILER ifx)

# the following is used if cross-compiling
Expand Down
7 changes: 0 additions & 7 deletions src/H5VLpassthru.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@
/* (Uncomment to enable) */
/* #define ENABLE_PASSTHRU_LOGGING */

/* Hack for missing va_copy() in old Visual Studio editions
* (from H5win2_defs.h - used on VS2012 and earlier)
*/
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1800)
#define va_copy(D, S) ((D) = (S))
#endif

/************/
/* Typedefs */
/************/
Expand Down
18 changes: 5 additions & 13 deletions src/H5system.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,10 @@ Nflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation)
time_t
H5_make_time(struct tm *tm)
{
time_t the_time; /* The converted time */
#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */
/* In gcc and in Visual Studio prior to VS 2015 'timezone' is a global
* variable declared in time.h. That variable was deprecated and in
* VS 2015 is removed, with _get_timezone replacing it.
*/
time_t the_time; /* The converted time */
#if defined(H5_HAVE_VISUAL_STUDIO)
long timezone = 0;
#endif /* defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) */
#endif
time_t ret_value = 0; /* Return value */

FUNC_ENTER_NOAPI_NOINIT
Expand All @@ -203,13 +199,9 @@ H5_make_time(struct tm *tm)
/* BSD-like systems */
the_time += tm->tm_gmtoff;
#elif defined(H5_HAVE_TIMEZONE)
#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */
/* In gcc and in Visual Studio prior to VS 2015 'timezone' is a global
* variable declared in time.h. That variable was deprecated and in
* VS 2015 is removed, with _get_timezone replacing it.
*/
#if defined(H5_HAVE_VISUAL_STUDIO)
_get_timezone(&timezone);
#endif /* defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) */
#endif

the_time -= timezone - (tm->tm_isdst ? 3600 : 0);
#else
Expand Down

0 comments on commit 6e8c7a9

Please sign in to comment.