Skip to content

Commit

Permalink
add coverage testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan-devarajan committed Oct 8, 2023
1 parent e819560 commit 2fbff6b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
sudo apt-get update
sudo apt-get install gcc g++ libtool-bin openmpi-bin libopenmpi-dev
sudo apt-get install python3.10 python3-pip
sudo apt-get install gcovr
- name: Install dlio benchmark
if: matrix.os == 'ubuntu-22.04' && matrix.perm == 'root' && matrix.dir == 'github'
run: |
Expand All @@ -48,6 +49,8 @@ jobs:
fi
- name: Build from ${{ matrix.dir }} on ${{ matrix.perm }}
run: |
export CMAKE_BUILD_TYPE=Profile
export DLIO_PROFILER_ENABLE_TESTS=ON
LOC=.
if [[ $DIR == 'github' ]]; then
LOC=git+https://github.com/hariharan-devarajan/dlio-profiler.git@dev
Expand All @@ -66,6 +69,18 @@ jobs:
pip install -r test/py/requirements.txt
cd build/temp*/dlio_profiler_py
ctest -VV
- name: Create Coverage
if: matrix.os == 'ubuntu-22.04' && matrix.dir == 'clone' && matrix.perm == 'user'
run: |
mkdir coverage
FILE=$PWD/coverage/coverage.json
cd build
COVERALLS_REPO_TOKEN=${{ secrets.GITHUB_TOKEN }} gcovr -r ../ . --coveralls $FILE -e ../test/ -e ../src/example
if [ -e '$FILE' ]; then
sed -i'' -e 's/"service_name": "github-actions-ci"/"service_name": "github"/' '$FILE'
fi
cat $FILE
curl -v -F json_file=@$FILE https://coveralls.io/api/v1/jobs
- name: Test dlio benchmark npz
if: matrix.os == 'ubuntu-22.04' && matrix.perm == 'root' && matrix.dir == 'github'
run: |
Expand Down
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_BINARY_DIR})
# Build options
#------------------------------------------------------------------------------
option(BUILD_PYTHON_BINDINGS "Build python bindings." ON)
option(DLIO_PROFILER_ENABLE_TESTS "Enable internal tests" Off)
#------------------------------------------------------------------------------
# Setup install and output Directories
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -69,6 +70,15 @@ if (NOT DLIO_PROFILER_EXTERNALLY_CONFIGURED)
endif ()


if(DLIO_PROFILER_ENABLE_TESTS)
enable_testing()
if(CMAKE_BUILD_TYPE STREQUAL "PROFILE")
set(CMAKE_C_FLAGS_PROFILE --coverage)
set(CMAKE_CXX_FLAGS_PROFILE --coverage)
endif()
add_subdirectory(test)
endif()

if (BUILD_PYTHON_BINDINGS)
find_package(pybind11 REQUIRED)
#add_subdirectory(dependency/py11bind)
Expand Down Expand Up @@ -321,8 +331,3 @@ install(EXPORT
FILE
${DLIO_PROFILER_EXPORTED_TARGETS}.cmake
)
option(DLIO_PROFILER_BUILD_TEST "Build the unit tests" ON)
if (DLIO_PROFILER_BUILD_TEST)
enable_testing()
add_subdirectory(test)
endif ()
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ def build_extension(self, ext: CMakeExtension) -> None:
print(f"{extdir}")
# Using this requires trailing slash for auto-detection & inclusion of
# auxiliary "native" libs

debug = int(os.environ.get("DEBUG", 0)) if self.debug is None else self.debug
cfg = "Debug" if debug else "Release"
build_type = os.environ.get("CMAKE_BUILD_TYPE", "Release")
cmake_args += [f"-DCMAKE_BUILD_TYPE={build_type}"]
enable_tests = os.environ.get("DLIO_PROFILER_ENABLE_TESTS", "Off")
cmake_args += [f"-DLIO_PROFILER_ENABLE_TESTS={enable_tests}"]

# CMake lets you override the generator - we need to check this.
# Can be set with Conda-Build, for example.
Expand Down

0 comments on commit 2fbff6b

Please sign in to comment.