From 57f89ba957b5582f7d38c0169acb6b62f97027a9 Mon Sep 17 00:00:00 2001 From: Dan Cristoloveanu Date: Mon, 5 Dec 2016 14:03:15 -0800 Subject: [PATCH] Switch cmake option from skip_unittests to run_unittests and default to OFF --- CMakeLists.txt | 4 ++-- build_all/linux/build.sh | 8 +++---- build_all/packaging/linux/debian/rules | 2 +- build_all/windows/build.cmd | 24 ++++++++++----------- c-utility | 2 +- jenkins/linux_c_gcc44.sh | 2 +- jenkins/ubuntu1510_c.sh | 2 +- jenkins/windows_c.cmd | 2 +- readme.md | 30 ++++++++++++++++++++++---- 9 files changed, 49 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d412bf2..247cb66 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ endif() include(ExternalProject) #the following variables are project-wide and can be used with cmake-gui -option(skip_unittests "set skip_unittests to ON to skip unittests (default is OFF)[if possible, they are always built]" OFF) +option(run_unittests "set run_unittests to ON to run unittests (default is OFF)" OFF) option(skip_samples "set skip_samples to ON to skip building samples (default is OFF)[if possible, they are always built]" OFF) option(compileOption_C "passes a string to the command line of the C compiler" OFF) option(compileOption_CXX "passes a string to the command line of the C++ compiler" OFF) @@ -167,7 +167,7 @@ if (NOT ${ARCHITECTURE} STREQUAL "ARM") endif() endif() -if (NOT ${skip_unittests}) +if (${run_unittests}) include("dependencies-test.cmake") add_subdirectory(tests) endif() diff --git a/build_all/linux/build.sh b/build_all/linux/build.sh index 2c3c6e7..6c68eec 100755 --- a/build_all/linux/build.sh +++ b/build_all/linux/build.sh @@ -9,7 +9,7 @@ build_root=$(cd "${script_dir}/../.." && pwd) run_unit_tests=ON run_valgrind=0 build_folder=$build_root"/cmake/umqtt_linux" -skip_unittests=OFF +run_unittests=OFF usage () { @@ -18,7 +18,7 @@ usage () echo " -cl, --compileoption specify a compile option to be passed to gcc" echo " Example: -cl -O1 -cl ..." echo "-rv, --run_valgrind will execute ctest with valgrind" - echo "--skip-unittests do not build or run unit tests" + echo "--run-unittests do not build or run unit tests" echo "" exit 1 } @@ -38,7 +38,7 @@ process_args () case "$arg" in "-cl" | "--compileoption" ) save_next_arg=1;; "-rv" | "--run_valgrind" ) run_valgrind=1;; - "--skip-unittests" ) skip_unittests=ON;; + "--run-unittests" ) run_unittests=ON;; * ) usage;; esac fi @@ -50,7 +50,7 @@ process_args $* rm -r -f $build_folder mkdir -p $build_folder pushd $build_folder -cmake -DcompileOption_C:STRING="$extracloptions" -Drun_valgrind:BOOL=$run_valgrind $build_root -Dskip_unittests:BOOL=$skip_unittests +cmake -DcompileOption_C:STRING="$extracloptions" -Drun_valgrind:BOOL=$run_valgrind $build_root -Drun_unittests:BOOL=$run_unittests make --jobs=$(nproc) if [[ $run_valgrind == 1 ]] ; diff --git a/build_all/packaging/linux/debian/rules b/build_all/packaging/linux/debian/rules index fd1d4e1..cbc84a8 100755 --- a/build_all/packaging/linux/debian/rules +++ b/build_all/packaging/linux/debian/rules @@ -22,7 +22,7 @@ include /usr/share/dpkg/default.mk dh $@ --buildsystem=cmake --DSYSINSTALL_BINDINGS=ON override_dh_auto_configure: - dh_auto_configure -- -Dskip_unittests=ON + dh_auto_configure -- override_dh_auto_install: rm -f -r $$(pwd)/debian/tmp diff --git a/build_all/windows/build.cmd b/build_all/windows/build.cmd index 3dfd17e..0cd719b 100644 --- a/build_all/windows/build.cmd +++ b/build_all/windows/build.cmd @@ -34,7 +34,7 @@ rem // default build options set build-clean=0 set build-config=Debug set build-platform=Win32 -set CMAKE_skip_unittests=OFF +set CMAKE_run_unittests=OFF set CMAKE_DIR=umqtt_win32 set MAKE_NUGET_PKG=no @@ -44,7 +44,7 @@ if "%1" equ "-c" goto arg-build-clean if "%1" equ "--clean" goto arg-build-clean if "%1" equ "--config" goto arg-build-config if "%1" equ "--platform" goto arg-build-platform -if "%1" equ "--skip-unittests" goto arg-skip-unittests +if "%1" equ "--run-unittests" goto arg-run-unittests if "%1" equ "--make_nuget" goto arg-build-nuget call :usage && exit /b 1 @@ -69,15 +69,15 @@ if %build-platform% == x64 ( ) goto args-continue -:arg-skip-unittests -set CMAKE_skip_unittests=ON +:arg-run-unittests +set CMAKE_run_unittests=ON goto args-continue :arg-build-nuget shift if "%1" equ "" call :usage && exit /b 1 set MAKE_NUGET_PKG=%1 -set CMAKE_skip_unittests=ON +set CMAKE_run_unittests=ON goto args-continue :args-continue @@ -103,7 +103,7 @@ pushd %build-root%\cmake\%CMAKE_DIR% if %MAKE_NUGET_PKG% == yes ( echo ***Running CMAKE for Win32*** - cmake %build-root% -Dskip_unittests:BOOL=%CMAKE_skip_unittests% + cmake %build-root% -Drun_unittests:BOOL=%CMAKE_run_unittests% if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! popd @@ -113,7 +113,7 @@ if %MAKE_NUGET_PKG% == yes ( ) mkdir %build-root%\cmake\umqtt_x64 pushd %build-root%\cmake\umqtt_x64 - cmake -Dskip_unittests:BOOL=%CMAKE_skip_unittests% %build-root% -G "Visual Studio 14 Win64" + cmake -Drun_unittests:BOOL=%CMAKE_run_unittests% %build-root% -G "Visual Studio 14 Win64" if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! popd @@ -124,20 +124,20 @@ if %MAKE_NUGET_PKG% == yes ( mkdir %build-root%\cmake\umqtt_arm pushd %build-root%\cmake\umqtt_arm echo ***Running CMAKE for ARM*** - cmake -Dskip_unittests:BOOL=%CMAKE_skip_unittests% %build-root% -G "Visual Studio 14 ARM" + cmake -Drun_unittests:BOOL=%CMAKE_run_unittests% %build-root% -G "Visual Studio 14 ARM" if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! ) else if %build-platform% == Win32 ( echo ***Running CMAKE for Win32*** - cmake %build-root% -Dskip_unittests:BOOL=%CMAKE_skip_unittests% + cmake %build-root% -Drun_unittests:BOOL=%CMAKE_run_unittests% if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! ) else if %build-platform% == arm ( echo ***Running CMAKE for ARM*** - cmake -Dskip_unittests:BOOL=%CMAKE_skip_unittests% %build-root% -G "Visual Studio 14 ARM" + cmake -Drun_unittests:BOOL=%CMAKE_run_unittests% %build-root% -G "Visual Studio 14 ARM" if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! ) else ( echo ***Running CMAKE for Win64*** - cmake -Dskip_unittests:BOOL=%CMAKE_skip_unittests% %build-root% -G "Visual Studio 14 Win64" + cmake -Drun_unittests:BOOL=%CMAKE_run_unittests% %build-root% -G "Visual Studio 14 Win64" if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! ) @@ -196,7 +196,7 @@ echo options: echo -c, --clean delete artifacts from previous build before building echo --config ^ [Debug] build configuration (e.g. Debug, Release) echo --platform ^ [Win32] build platform (e.g. Win32, x64, arm, ...) -echo --skip-unittests skip the unit tests +echo --run-unittests run the unit tests echo --make_nuget ^ [no] generates the binaries to be used for nuget packaging (e.g. yes, no) goto :eof diff --git a/c-utility b/c-utility index 59bd050..66f4822 160000 --- a/c-utility +++ b/c-utility @@ -1 +1 @@ -Subproject commit 59bd0504af5f8ef0101f5cdda11c5b9c11f14ae6 +Subproject commit 66f4822e9d3d8a640f7166acac1ae5c2247a106a diff --git a/jenkins/linux_c_gcc44.sh b/jenkins/linux_c_gcc44.sh index 433d5a7..346f243 100755 --- a/jenkins/linux_c_gcc44.sh +++ b/jenkins/linux_c_gcc44.sh @@ -6,5 +6,5 @@ build_root=$(cd "$(dirname "$0")/.." && pwd) cd $build_root # -- C -- -./build_all/linux/build.sh --skip-unittests "$@" +./build_all/linux/build.sh "$@" [ $? -eq 0 ] || exit $? diff --git a/jenkins/ubuntu1510_c.sh b/jenkins/ubuntu1510_c.sh index ab6d806..7f2eb7c 100755 --- a/jenkins/ubuntu1510_c.sh +++ b/jenkins/ubuntu1510_c.sh @@ -6,6 +6,6 @@ build_root=$(cd "$(dirname "$0")/.." && pwd) cd $build_root # -- C -- -./build_all/linux/build.sh --run_valgrind "$@" #-x +./build_all/linux/build.sh --run-unittests --run_valgrind "$@" #-x [ $? -eq 0 ] || exit $? diff --git a/jenkins/windows_c.cmd b/jenkins/windows_c.cmd index ec0aca6..d75ea39 100644 --- a/jenkins/windows_c.cmd +++ b/jenkins/windows_c.cmd @@ -10,6 +10,6 @@ for %%i in ("%build-root%") do set build-root=%%~fi REM -- C -- cd %build-root%\build_all\windows -call build.cmd %* +call build.cmd --run-unittests %* if errorlevel 1 goto :eof cd %build-root% \ No newline at end of file diff --git a/readme.md b/readme.md index 612da5d..c097af7 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope # Microsoft Azure MQTT -azure-mqtt is a general purpose library build for MQTT protocol +azure-umqtt-c is a general purpose library build for MQTT protocol ## Dependencies @@ -12,13 +12,27 @@ azure-c-shared-utility needs to be built before building azure-mqtt-c. ## Setup +### Build + - Clone azure-umqtt-c by: + ``` git clone --recursive https://github.com/Azure/azure-umqtt-c.git ``` -- Create a folder build under azure-umqtt-c -- Switch to the build folder and run - cmake .. + +- Create a folder cmake under azure-umqtt-c + +- Switch to the cmake folder and run + +``` +cmake .. +``` + +- Build + +``` +cmake --build . +``` ### Installation and Use Optionally, you may choose to install azure-umqtt-c on your machine: @@ -52,3 +66,11 @@ Optionally, you may choose to install azure-umqtt-c on your machine: _This requires that azure-c-shared-utility is installed (through CMake) on your machine._ _If running tests, this requires that umock-c, azure-ctest, and azure-c-testrunnerswitcher are installed (through CMake) on your machine._ + +### Building the tests + +In order to build the tests use: + +``` +cmake .. -Drun_unittests:bool=ON +```