Skip to content

Add test for make uninstall target #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ name: BasicBuilds

on: [push, pull_request]

env:
BUILD_DIR : "${{github.workspace}}/build/"
INSTL_DIR : "${{github.workspace}}/build/install-dir"

jobs:
ubuntu-build:
name: Build - Ubuntu

strategy:
matrix:
os: ['ubuntu-20.04', 'ubuntu-22.04']
Expand All @@ -17,9 +20,11 @@ jobs:
- os: 'ubuntu-20.04'
build_type: Release
compiler: {c: gcc-7, cxx: g++-7}
shared_library: 'OFF'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: clang, cxx: clang++}
shared_library: 'OFF'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: gcc, cxx: g++}
Expand All @@ -43,7 +48,8 @@ jobs:
- name: Configure build
run: >
cmake
-B ${{github.workspace}}/build
-B ${{env.BUILD_DIR}}
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
Expand All @@ -57,13 +63,22 @@ jobs:

- name: Build UMF
run: |
cmake --build ${{github.workspace}}/build -j $(nproc)
cmake --build ${{env.BUILD_DIR}} -j $(nproc)

- name: Run tests
working-directory: ${{github.workspace}}/build
working-directory: ${{env.BUILD_DIR}}
run: |
ctest --output-on-failure

- name: Test make install
working-directory: ${{env.BUILD_DIR}}
run: ${{github.workspace}}/test/test_make_install.sh \
${{github.workspace}} ${{env.BUILD_DIR}} ${{env.INSTL_DIR}} ${{matrix.build_type}} ${{matrix.shared_library}}

- name: Test make uninstall
working-directory: ${{env.BUILD_DIR}}
run: ${{github.workspace}}/test/test_make_uninstall.sh ${{github.workspace}} ${{env.BUILD_DIR}} ${{env.INSTL_DIR}}

windows-build:
name: Build - Windows
strategy:
Expand Down Expand Up @@ -92,7 +107,7 @@ jobs:
- name: Configure build
run: >
cmake
-B ${{github.workspace}}/build
-B ${{env.BUILD_DIR}}
${{matrix.toolset}}
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
Expand All @@ -103,10 +118,10 @@ jobs:
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON

- name: Build UMF
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS

- name: Test
working-directory: ${{github.workspace}}/build
working-directory: ${{env.BUILD_DIR}}
run: ctest -C ${{matrix.build_type}} --output-on-failure

macos-build:
Expand All @@ -125,16 +140,16 @@ jobs:
- name: Configure build
run: >
cmake
-B ${{github.workspace}}/build
-B ${{env.BUILD_DIR}}
-DCMAKE_BUILD_TYPE=Release
-DUMF_FORMAT_CODE_STYLE=ON
-DUMF_DEVELOPER_MODE=ON
-DUMF_ENABLE_POOL_TRACKING=ON

- name: Run code-style check
run: |
cmake --build ${{github.workspace}}/build --target clang-format-check
cmake --build ${{env.BUILD_DIR}} --target clang-format-check

- name: Build UMF
run: |
cmake --build ${{github.workspace}}/build -j $(sysctl -n hw.logicalcpu)
cmake --build ${{env.BUILD_DIR}} -j $(sysctl -n hw.logicalcpu)
83 changes: 83 additions & 0 deletions test/test_make_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set -e

USAGE_STR="Usage: $(basename $0) <workspace_dir> <build_dir> <install_dir> <build_type:Release|Debug> <shared_library:ON|OFF>"

if [ "$5" == "" ]; then
echo $USAGE_STR
exit 1
fi

WORKSPACE=$(realpath $1)
BUILD_DIR=$(realpath $2)
INSTALL_DIR=$(realpath $3)
BUILD_TYPE=$4
SHARED_LIB=$5

if [ ! -f $WORKSPACE/README.md ]; then
echo "Incorrect <workspace_dir>: $WORKSPACE"
echo $USAGE_STR
exit 1
fi

if [ "$BUILD_DIR" == "$WORKSPACE" ]; then
echo "Incorrect <build_dir>: $BUILD_DIR"
echo $USAGE_STR
exit 1
fi

if [ -d $INSTALL_DIR ]; then
echo "Incorrect <install_dir> (it should not exist): $INSTALL_DIR"
echo $USAGE_STR
exit 1
fi

if [ "$BUILD_TYPE" != "Release" -a "$BUILD_TYPE" != "Debug" ]; then
echo "Incorrect <build_type> argument: $BUILD_TYPE"
echo $USAGE_STR
exit 1
fi

if [ "$SHARED_LIB" != "ON" -a "$SHARED_LIB" != "OFF" ]; then
echo "Incorrect <shared_library> argument: $SHARED_LIB"
echo $USAGE_STR
exit 1
fi

[ "$BUILD_TYPE" == "Release" ] && BUILD_TYPE_STR="release" || BUILD_TYPE_STR="debug"
[ "$SHARED_LIB" == "ON" ] && LIB_EXT_STR="so" || LIB_EXT_STR="a"

echo "WORKSPACE=$WORKSPACE"
echo "BUILD_DIR=$BUILD_DIR"
echo "INSTALL_DIR=$INSTALL_DIR"
echo "BUILD_TYPE=$BUILD_TYPE"
echo "BUILD_TYPE_STR=$BUILD_TYPE_STR"
echo "SHARED_LIB=$SHARED_LIB"
echo "LIB_EXT_STR=$LIB_EXT_STR"

set -x

TEMPLATE_INSTALL_FILES="${WORKSPACE}/test/test_make_install.txt"
INSTALLED_FILES="${BUILD_DIR}/install-files.txt"
MATCH_INSTALLED_FILES="${BUILD_DIR}/install-files-match.txt"

cp -f ${TEMPLATE_INSTALL_FILES} ${MATCH_INSTALLED_FILES}
sed -i "s/@BUILD_TYPE_STR@/$BUILD_TYPE_STR/g" ${MATCH_INSTALLED_FILES}
sed -i "s/@LIB_EXT_STR@/$LIB_EXT_STR/g" ${MATCH_INSTALLED_FILES}

mkdir ${INSTALL_DIR}
cd ${BUILD_DIR}
make install prefix=${INSTALL_DIR}

cd ${INSTALL_DIR}
find | sort > ${INSTALLED_FILES}

# check if 'make install' installed all and only required files
diff ${INSTALLED_FILES} ${MATCH_INSTALLED_FILES} || exit 1
set +x

echo "Success"
31 changes: 31 additions & 0 deletions test/test_make_install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.
./include
./include/umf
./include/umf.h
./include/umf/base.h
./include/umf/memory_pool.h
./include/umf/memory_pool_ops.h
./include/umf/memory_provider.h
./include/umf/memory_provider_ops.h
./include/umf/pools
./include/umf/pools/pool_disjoint.h
./include/umf/pools/pool_jemalloc.h
./include/umf/pools/pool_scalable.h
./include/umf/providers
./include/umf/providers/provider_os_memory.h
./lib
./lib/cmake
./lib/cmake/unified-memory-framework
./lib/cmake/unified-memory-framework/unified-memory-framework-config-version.cmake
./lib/cmake/unified-memory-framework/unified-memory-framework-config.cmake
./lib/cmake/unified-memory-framework/unified-memory-framework-targets-@[email protected]
./lib/cmake/unified-memory-framework/unified-memory-framework-targets.cmake
./lib/libdisjoint_pool.a
./lib/libjemalloc_pool.a
./lib/libscalable_pool.a
./lib/libumf.@LIB_EXT_STR@
./lib/libumf_utils.a
./share
./share/doc
./share/doc/unified-memory-framework
./share/doc/unified-memory-framework/LICENSE.TXT
57 changes: 57 additions & 0 deletions test/test_make_uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set -e

USAGE_STR="Usage: $(basename $0) <workspace_dir> <build_dir> <install_dir>"

if [ "$3" == "" ]; then
echo $USAGE_STR
exit 1
fi

WORKSPACE=$(realpath $1)
BUILD_DIR=$(realpath $2)
INSTALL_DIR=$(realpath $3)

if [ ! -f $WORKSPACE/README.md ]; then
echo "Incorrect <workspace_dir>: $WORKSPACE"
echo $USAGE_STR
exit 1
fi

if [ "$BUILD_DIR" == "$WORKSPACE" ]; then
echo "Incorrect <build_dir>: $BUILD_DIR"
echo $USAGE_STR
exit 1
fi

if [ ! -d $INSTALL_DIR ]; then
echo "Incorrect <install_dir> (it must exist): $INSTALL_DIR"
echo $USAGE_STR
exit 1
fi

echo "WORKSPACE=$WORKSPACE"
echo "BUILD_DIR=$BUILD_DIR"
echo "INSTALL_DIR=$INSTALL_DIR"

set -x

MATCH_UNINSTALLED_FILES="${WORKSPACE}/test/test_make_uninstall.txt"
UNINSTALLED_FILES="${BUILD_DIR}/uninstall-files.txt"

cd ${BUILD_DIR}
make uninstall

# check what files are left, there should be only empty directories left after 'make uninstall'
cd ${INSTALL_DIR}
find | sort > ${UNINSTALLED_FILES}

# check if 'make uninstall' left only empty directories
diff ${UNINSTALLED_FILES} ${MATCH_UNINSTALLED_FILES} || exit 1
set +x

echo "Success"
11 changes: 11 additions & 0 deletions test/test_make_uninstall.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.
./include
./include/umf
./include/umf/pools
./include/umf/providers
./lib
./lib/cmake
./lib/cmake/unified-memory-framework
./share
./share/doc
./share/doc/unified-memory-framework