diff --git a/Deployment.md b/Deployment.md index 771d9d3..98c631e 100644 --- a/Deployment.md +++ b/Deployment.md @@ -1,6 +1,6 @@ ### CAN API V3 Wrapper Library for PEAK-System PCAN® Interfaces (Windows®) -_Copyright © 2005-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \ +_Copyright © 2005-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \ _All rights reserved._ # Deployment @@ -76,7 +76,7 @@ _All rights reserved._ - `C:\Users\haumea>cd C:\Projects\CAN\Drivers\PeakCAN\Tests` - `C:\Projects\CAN\Drivers\PeakCAN\Tests>x64_build.bat` 5. Run the CAN API V3 GoogleTest program with two PCAN-USB devices in CAN 2.0 mode: - - `C:\Projects\CAN\Drivers\PeakCAN\Tests>x64\Debug\pcb_testing --can_dut1=PCAN-USB1 --can_dut2=PCAN-USB2 --can_mode=2.0 --can_bitrate=DEFAULT --gtest_output=xml:TestReport_PCAN-USB.xml --run_all=YES --smoketest_frames=100000` [...] + - `C:\Projects\CAN\Drivers\PeakCAN\Tests>x64\Debug\pcb_testing --can_dut1=PCAN-USB1 --can_dut2=PCAN-USB2 --can_mode=2.0 --can_baudrate=DEFAULT --gtest_output=xml:TestReport_PCAN-USB.xml --run_all=YES --smoketest_frames=100000` [...] - _If there is any error then **stop** here or create an issue for each error in the repo._ - Copy the test report into the binary's directory `$(PROJROOT)\Binaries`. 6. Run the CAN API V3 GoogleTest program with two PCAN-USB FD devices in CAN FD mode: diff --git a/Libraries/CANAPI/uvcanpcb.rc b/Libraries/CANAPI/uvcanpcb.rc index 8f6b1c2..ed1b69d 100644 Binary files a/Libraries/CANAPI/uvcanpcb.rc and b/Libraries/CANAPI/uvcanpcb.rc differ diff --git a/Libraries/CANAPI/uvcanpcb.vcxproj b/Libraries/CANAPI/uvcanpcb.vcxproj index d500247..a524d92 100644 --- a/Libraries/CANAPI/uvcanpcb.vcxproj +++ b/Libraries/CANAPI/uvcanpcb.vcxproj @@ -1,22 +1,10 @@  - - Debug_dll - Win32 - - - Debug_lib - Win32 - Debug_lib x64 - - Release_dll - Win32 - Debug_dll x64 @@ -25,10 +13,6 @@ Release_dll x64 - - Release_lib - Win32 - Release_lib x64 @@ -42,32 +26,6 @@ 10.0 - - DynamicLibrary - true - v143 - Unicode - - - StaticLibrary - true - v143 - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - StaticLibrary - false - v143 - true - Unicode - DynamicLibrary true @@ -99,18 +57,6 @@ - - - - - - - - - - - - @@ -124,18 +70,6 @@ - - u3canpcb - - - u3canpcb - - - u3canpcb - - - u3canpcb - u3canpcb @@ -148,84 +82,6 @@ u3canpcb - - - Level3 - true - WIN32;_DEBUG;UVCANPCB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANAPI_DLLEXPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_RETVALS=1 - true - Use - pch.h - .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - MultiThreadedDebug - - - Windows - true - ..\..\Sources\PCANBasic\x86\PCANBasic.lib;%(AdditionalDependencies) - false - - - - - Level3 - true - WIN32;_DEBUG;UVCANPCB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANAPI_DLLEXPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_RETVALS=1 - true - Use - pch.h - .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - MultiThreadedDebug - - - Windows - true - ..\..\Sources\PCANBasic\x86\PCANBasic.lib;%(AdditionalDependencies) - false - - - - - Level3 - true - true - true - WIN32;NDEBUG;UVCANPCB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANAPI_DLLEXPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_RETVALS=1 - true - Use - pch.h - .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - ..\..\Sources\PCANBasic\x86\PCANBasic.lib;%(AdditionalDependencies) - false - - - - - Level3 - true - true - true - WIN32;NDEBUG;UVCANPCB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANAPI_DLLEXPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_RETVALS=1 - true - Use - pch.h - .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - ..\..\Sources\PCANBasic\x86\PCANBasic.lib;%(AdditionalDependencies) - false - - Level3 @@ -235,7 +91,7 @@ Use pch.h .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - MultiThreadedDebug + MultiThreadedDebugDLL Windows @@ -253,7 +109,7 @@ Use pch.h .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - MultiThreadedDebug + MultiThreadedDebugDLL Windows @@ -312,20 +168,12 @@ - NotUsing - NotUsing - NotUsing - NotUsing NotUsing NotUsing NotUsing NotUsing - NotUsing - NotUsing - NotUsing - NotUsing NotUsing NotUsing NotUsing @@ -335,10 +183,6 @@ Create Create - Create - Create - Create - Create Create Create diff --git a/Libraries/CANAPI/uvcanpcb.vcxproj.filters b/Libraries/CANAPI/uvcanpcb.vcxproj.filters index a6b2f7e..f33a475 100644 --- a/Libraries/CANAPI/uvcanpcb.vcxproj.filters +++ b/Libraries/CANAPI/uvcanpcb.vcxproj.filters @@ -24,6 +24,9 @@ Header Files + + Header Files + diff --git a/Libraries/PeakCAN/PeakCAN.rc b/Libraries/PeakCAN/PeakCAN.rc index eaff784..3b7b5ba 100644 Binary files a/Libraries/PeakCAN/PeakCAN.rc and b/Libraries/PeakCAN/PeakCAN.rc differ diff --git a/Libraries/PeakCAN/PeakCAN.vcxproj b/Libraries/PeakCAN/PeakCAN.vcxproj index 818d49c..7bc3125 100644 --- a/Libraries/PeakCAN/PeakCAN.vcxproj +++ b/Libraries/PeakCAN/PeakCAN.vcxproj @@ -1,22 +1,10 @@  - - Debug_dll - Win32 - - - Debug_lib - Win32 - Debug_lib x64 - - Release_dll - Win32 - Debug_dll x64 @@ -25,10 +13,6 @@ Release_dll x64 - - Release_lib - Win32 - Release_lib x64 @@ -42,32 +26,6 @@ 10.0 - - DynamicLibrary - true - v143 - Unicode - - - StaticLibrary - true - v143 - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - StaticLibrary - false - v143 - true - Unicode - DynamicLibrary true @@ -99,18 +57,6 @@ - - - - - - - - - - - - @@ -124,18 +70,6 @@ - - uvPeakCAN - - - uvPeakCAN - - - uvPeakCAN - - - uvPeakCAN - uvPeakCAN @@ -148,84 +82,6 @@ uvPeakCAN - - - Level3 - true - WIN32;_DEBUG;PEAKCAN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANAPI_DLLEXPORT=0;OPTION_CANCPP_DLLEXPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_RETVALS=0 - true - Use - pch.h - .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - MultiThreadedDebug - - - Windows - true - ..\..\Sources\PCANBasic\x86\PCANBasic.lib;%(AdditionalDependencies) - false - - - - - Level3 - true - WIN32;_DEBUG;PEAKCAN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANAPI_DLLEXPORT=0;OPTION_CANCPP_DLLEXPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_RETVALS=0 - true - Use - pch.h - .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - MultiThreadedDebug - - - Windows - true - ..\..\Sources\PCANBasic\x86\PCANBasic.lib;%(AdditionalDependencies) - false - - - - - Level3 - true - true - true - WIN32;NDEBUG;PEAKCAN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANAPI_DLLEXPORT=0;OPTION_CANCPP_DLLEXPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_RETVALS=0 - true - Use - pch.h - .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - ..\..\Sources\PCANBasic\x86\PCANBasic.lib;%(AdditionalDependencies) - false - - - - - Level3 - true - true - true - WIN32;NDEBUG;PEAKCAN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANAPI_DLLEXPORT=0;OPTION_CANCPP_DLLEXPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_RETVALS=0 - true - Use - pch.h - .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - ..\..\Sources\PCANBasic\x86\PCANBasic.lib;%(AdditionalDependencies) - false - - Level3 @@ -235,7 +91,7 @@ Use pch.h .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - MultiThreadedDebug + MultiThreadedDebugDLL Windows @@ -253,7 +109,7 @@ Use pch.h .\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\PCANBasic;..\..\Sources\Wrapper;%(AdditionalIncludeDirectories) - MultiThreadedDebug + MultiThreadedDebugDLL Windows @@ -312,30 +168,18 @@ - NotUsing - NotUsing - NotUsing - NotUsing NotUsing NotUsing NotUsing NotUsing - NotUsing - NotUsing - NotUsing - NotUsing NotUsing NotUsing NotUsing NotUsing - NotUsing - NotUsing - NotUsing - NotUsing NotUsing NotUsing NotUsing @@ -345,10 +189,6 @@ Create Create - Create - Create - Create - Create Create Create diff --git a/Libraries/PeakCAN/PeakCAN.vcxproj.filters b/Libraries/PeakCAN/PeakCAN.vcxproj.filters index 4ef2562..0fdb63b 100644 --- a/Libraries/PeakCAN/PeakCAN.vcxproj.filters +++ b/Libraries/PeakCAN/PeakCAN.vcxproj.filters @@ -24,11 +24,17 @@ Header Files + + Header Files + Source Files + + Source Files + Source Files @@ -38,9 +44,6 @@ Source Files - - Source Files - diff --git a/README.md b/README.md index da576c5..1b2e25e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ### CAN API V3 Wrapper Library for PEAK-System PCAN® Interfaces (Windows®) -_Copyright © 2005-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ +_Copyright © 2005-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de)_ ![MSBuild](https://github.com/uv-software/PCANBasic-Wrapper/actions/workflows/msbuild.yml/badge.svg) @@ -90,19 +90,19 @@ C:\Projects\CAN\Drivers\PeakCAN>x64_build.bat ``` (The version number of the libraries can be adapted by editing the `.rc` files in the corresponding subfolders. Don´t forget to set the version number also in the header file `Version.h`.) -#### Libraries +### Libraries -##### uvPeakCAN (DLL) +#### uvPeakCAN (DLL) ___uvPeakCAN___ is a dynamic link library with a CAN API V3 compatible application programming interface for use in __C++__ applications. See header file `PeakCAN.h` for a description of all class members. -##### u3canpcb (DLL) +#### u3canpcb (DLL) ___u3canpcb___ is a dynamic link library with a CAN API V3 compatible application programming interface for use in __C__ applications. See header file `can_api.h` for a description of all API functions. -#### Utilities +### Utilities ##### can_send @@ -128,21 +128,21 @@ Type `can_test /?` to display all program options. ### Target Platform -- Windows 10 & 11 (x64 operating systems) +- Windows 11 (x64 operating systems) ### Development Environment -- Microsoft Visual Studio Community 2022 (Version 17.13.2) +- Microsoft Visual Studio Community 2022 (Version 17.14.39) ### Required PCANBasic DLL -- Version 4.5 or later _(Latest is Greatest!)_ +- Version 5.0 or later _(Latest is Greatest!)_ ### Tested CAN Hardware -- PCAN-USB - single channel, CAN 2.0 (Peak´s item no.: IPEH-002021, IPEH-002021) -- PCAN-USB FD - single channel, CAN 2.0 and CAN FD (Peak´s item no.: IPEH-004022) -- PCAN-USB Pro FD - dual channel, CAN 2.0 and CAN FD (Peak´s item no.: IPEH-004061) +- PCAN-USB - single channel, CAN 2.0 (Peak´s item no.: IPEH-002021, IPEH-002022; Firmware 6.0.1) +- PCAN-USB FD - single channel, CAN 2.0 and CAN FD (Peak´s item no.: IPEH-004022; Firmware 3.5.1) +- PCAN-USB Pro FD - dual channel, CAN 2.0 and CAN FD (Peak´s item no.: IPEH-004061; Firmware 3.5.3) ## Known Bugs and Caveats @@ -183,5 +183,5 @@ _If you connect your CAN device to a real CAN network when using this library, y ### Contact -E-Mail: mailto://info@uv-software.com \ +E-Mail: mailto://info@uv-software.de \ Internet: https://www.uv-software.com diff --git a/Sources/CANAPI/CANAPI.h b/Sources/CANAPI/CANAPI.h index 02ec152..250d1eb 100644 --- a/Sources/CANAPI/CANAPI.h +++ b/Sources/CANAPI/CANAPI.h @@ -7,8 +7,8 @@ // // This file is part of CAN API V3. // -// CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License -// and under the GNU General Public License v2.0 (or any later version). You can +// CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and +// under the GNU General Public License v2.0 (or any later version). You can // choose between one of them if you use CAN API V3 in whole or in part. // // (1) BSD 2-Clause "Simplified" License @@ -75,9 +75,9 @@ /// zero to compile your program with the CAN API source files or to /// link your program with the static library at compile-time. /// -/// \author $Author: makemake $ +/// \author $Author: sedna $ // -/// \version $Rev: 1407 $ +/// \version $Rev: 1488 $ of $Date: 2025-03-06 20:46:30 +0100 (Do, 06 Mrz 2025) $ // /// \defgroup can_api CAN Interface API, Version 3 /// \{ @@ -538,4 +538,4 @@ class CANCPP CCanApi { /// \} #endif // CANAPI_H_INCLUDED /// \} -// $Id: CANAPI.h 1407 2025-01-15 21:08:44Z makemake $ Copyright (c) UV Software // +// $Id: CANAPI.h 1488 2025-03-06 19:46:30Z sedna $ Copyright (c) UV Software // diff --git a/Sources/CANAPI/CANAPI_Defines.h b/Sources/CANAPI/CANAPI_Defines.h index 4c6f09a..557c6bc 100644 --- a/Sources/CANAPI/CANAPI_Defines.h +++ b/Sources/CANAPI/CANAPI_Defines.h @@ -7,8 +7,8 @@ * * This file is part of CAN API V3. * - * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License - * and under the GNU General Public License v2.0 (or any later version). You can + * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and + * under the GNU General Public License v2.0 (or any later version). You can * choose between one of them if you use CAN API V3 in whole or in part. * * (1) BSD 2-Clause "Simplified" License @@ -51,9 +51,9 @@ * * @brief CAN API V3 for generic CAN Interfaces - Definitions and Options * - * @author $Author: makemake $ + * @author $Author: sedna $ * - * @version $Rev: 1407 $ + * @version $Rev: 1488 $ of $Date: 2025-03-06 20:46:30 +0100 (Do, 06 Mrz 2025) $ * * @addtogroup can_api * @{ diff --git a/Sources/CANAPI/CANAPI_Types.h b/Sources/CANAPI/CANAPI_Types.h index 4af8126..977491d 100644 --- a/Sources/CANAPI/CANAPI_Types.h +++ b/Sources/CANAPI/CANAPI_Types.h @@ -7,8 +7,8 @@ * * This file is part of CAN API V3. * - * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License - * and under the GNU General Public License v2.0 (or any later version). You can + * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and + * under the GNU General Public License v2.0 (or any later version). You can * choose between one of them if you use CAN API V3 in whole or in part. * * (1) BSD 2-Clause "Simplified" License @@ -51,9 +51,9 @@ * * @brief CAN API V3 for generic CAN Interfaces - Data Types and Defines * - * @author $Author: makemake $ + * @author $Author: sedna $ * - * @version $Rev: 1407 $ + * @version $Rev: 1490 $ of $Date: 2025-03-06 21:06:42 +0100 (Do, 06 Mrz 2025) $ * * @addtogroup can_api * @{ @@ -595,10 +595,11 @@ typedef struct can_message_t_ { uint8_t fdf : 1; /**< flag: CAN FD format */ uint8_t brs : 1; /**< flag: bit-rate switching */ uint8_t esi : 1; /**< flag: error state indicator */ - uint8_t : 2; + uint8_t : 1; #else - uint8_t : 5; + uint8_t : 4; #endif + uint8_t err : 1; /**< flag: error frame (ECC) */ uint8_t sts : 1; /**< flag: status message */ }; #if (OPTION_CAN_2_0_ONLY == 0) diff --git a/Sources/CANAPI/CANAPI_Version.h b/Sources/CANAPI/CANAPI_Version.h index 1a5bfee..465d3a6 100644 --- a/Sources/CANAPI/CANAPI_Version.h +++ b/Sources/CANAPI/CANAPI_Version.h @@ -2,13 +2,13 @@ /* * CAN Interface API, Version 3 (Data Types and Defines) * - * Copyright (c) 2004-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) + * Copyright (c) 2004-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) * All rights reserved. * * This file is part of CAN API V3. * - * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License - * and under the GNU General Public License v2.0 (or any later version). You can + * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and + * under the GNU General Public License v2.0 (or any later version). You can * choose between one of them if you use CAN API V3 in whole or in part. * * (1) BSD 2-Clause "Simplified" License @@ -47,26 +47,11 @@ * You should have received a copy of the GNU General Public License along * with CAN API V3; if not, see . */ -/** @file CANAPI_Version.h - * - * @brief CAN API V3 for generic CAN Interfaces - Version Number - * - * @note This is only a dummy file to have a SVN revision number. - * - * @author $Author: quaoar $ - * - * @version $Rev: 1467 $ - * - * @addtogroup can_api - * @{ - */ #ifndef CANAPI_VERSION_H_INCLUDED #define CANAPI_VERSION_H_INCLUDED -// SVN revision number (update with each commit: VI) -#define CAN_API_REV "$Rev: 1467 $" +// SVN revision number (update with each commit: VIII) +#define CANAPI_SVN_REV "$Rev: 1599 $" #endif /* CANAPI_VERSION_H_INCLUDED */ -/** @} - */ /* ---------------------------------------------------------------------- * Uwe Vogt, UV Software, Chausseestrasse 33 A, 10115 Berlin, Germany * Tel.: +49-30-46799872, Fax: +49-30-46799873, Mobile: +49-170-3801903 diff --git a/Sources/CANAPI/CANBTR_Defaults.h b/Sources/CANAPI/CANBTR_Defaults.h index 52b77fb..5cc0ad2 100644 --- a/Sources/CANAPI/CANBTR_Defaults.h +++ b/Sources/CANAPI/CANBTR_Defaults.h @@ -2,13 +2,13 @@ /* * CAN Interface API, Version 3 (Definitions and Options) * - * Copyright (c) 2004-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) + * Copyright (c) 2004-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) * All rights reserved. * * This file is part of CAN API V3. * - * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License - * and under the GNU General Public License v2.0 (or any later version). You can + * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and + * under the GNU General Public License v2.0 (or any later version). You can * choose between one of them if you use CAN API V3 in whole or in part. * * (1) BSD 2-Clause "Simplified" License @@ -47,19 +47,19 @@ * You should have received a copy of the GNU General Public License along * with CAN API V3; if not, see . */ -/** @file CANBTR_Defines.h +/** @file CANBTR_Defaults.h * - * @brief CAN API V3 for generic CAN Interfaces - Definitions and Options + * @brief CAN API V3 for generic CAN Interfaces - SJA1000 Bit-timing Defaults * - * @author $Author: makemake $ + * @author $Author: quaoar $ * - * @version $Rev: 1407 $ + * @version $Rev: 1599 $ of $Date: 2026-08-27 18:03:18 +0200 (Do, 27 Aug 2026) $ * * @addtogroup can_btr * @{ */ -#ifndef CANBTR_DEFINES_H_INCLUDED -#define CANBTR_DEFINES_H_INCLUDED +#ifndef CANBTR_DEFAULTS_H_INCLUDED +#define CANBTR_DEFAULTS_H_INCLUDED #ifdef __cplusplus extern "C" { @@ -138,39 +138,14 @@ extern "C" { #define DEFAULT_CAN_BR_5K(x) SJA1000_BR_5K(x) /** @} */ -#if (OPTION_CAN_2_0_ONLY == 0) -/** @name CAN FD Bit-rate Settings w/o Bit-rate Switching - * @brief Default values for long frames only (0 to 64 bytes). - * - * @note Actual bit-rate settings for specific controllers may vary. - * The settings made here are for Peak CAN FD interfaces. - * @{ */ -#define DEFAULT_CAN_FD_BR_1M(x) do {x.btr.frequency=DEFAULT_CAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=31; x.btr.nominal.tseg2=8; x.btr.nominal.sjw=8; } while(0) -#define DEFAULT_CAN_FD_BR_500K(x) do {x.btr.frequency=DEFAULT_CAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=63; x.btr.nominal.tseg2=16;x.btr.nominal.sjw=16;} while(0) -#define DEFAULT_CAN_FD_BR_250K(x) do {x.btr.frequency=DEFAULT_CAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=127;x.btr.nominal.tseg2=32;x.btr.nominal.sjw=32;} while(0) -#define DEFAULT_CAN_FD_BR_125K(x) do {x.btr.frequency=DEFAULT_CAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=255;x.btr.nominal.tseg2=64;x.btr.nominal.sjw=64;} while(0) -/** @} */ - -/** @name CAN FD Bit-rate Settings with Bit-rate Switching - * @brief Default values for long and fast frames only (up to 8 Mbps). - * - * @note Actual bit-rate settings for specific controllers may vary. - * The settings made here are for Peak CAN FD interfaces. - * @{ */ -#define DEFAULT_CAN_FD_BR_1M8M(x) do {x.btr.frequency=DEFAULT_CAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=31; x.btr.nominal.tseg2=8; x.btr.nominal.sjw=8; x.btr.data.brp=2; x.btr.data.tseg1=3; x.btr.data.tseg2=1; x.btr.data.sjw=1; } while(0) -#define DEFAULT_CAN_FD_BR_500K4M(x) do {x.btr.frequency=DEFAULT_CAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=63; x.btr.nominal.tseg2=16;x.btr.nominal.sjw=16; x.btr.data.brp=2; x.btr.data.tseg1=7; x.btr.data.tseg2=2; x.btr.data.sjw=2; } while(0) -#define DEFAULT_CAN_FD_BR_250K2M(x) do {x.btr.frequency=DEFAULT_CAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=127;x.btr.nominal.tseg2=32;x.btr.nominal.sjw=32; x.btr.data.brp=2; x.btr.data.tseg1=15; x.btr.data.tseg2=4; x.btr.data.sjw=4; } while(0) -#define DEFAULT_CAN_FD_BR_125K1M(x) do {x.btr.frequency=DEFAULT_CAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=255;x.btr.nominal.tseg2=64;x.btr.nominal.sjw=64; x.btr.data.brp=2; x.btr.data.tseg1=31; x.btr.data.tseg2=8; x.btr.data.sjw=8; } while(0) -/** @} */ -#endif #ifdef __cplusplus } #endif -#endif /* CANBTR_DEFINES_H_INCLUDED */ +#endif /* CANBTR_DEFAULTS_H_INCLUDED */ /** @} */ /* ---------------------------------------------------------------------- * Uwe Vogt, UV Software, Chausseestrasse 33 A, 10115 Berlin, Germany * Tel.: +49-30-46799872, Fax: +49-30-46799873, Mobile: +49-170-3801903 - * E-Mail: uwe.vogt@uv-software.de, Homepage: http://www.uv-software.de/ + * E-Mail: uwe.vogt@uv-software.de, Homepage: https://www.uv-software.de/ */ diff --git a/Sources/CANAPI/README.md b/Sources/CANAPI/README.md index 679426f..abadb4e 100644 --- a/Sources/CANAPI/README.md +++ b/Sources/CANAPI/README.md @@ -1,6 +1,6 @@ ### CAN Interface API, Version 3 -_Copyright © 2004-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \ +_Copyright © 2004-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de)_ \ _All rights reserved._ # A CAN Interface Wrapper Specification @@ -65,7 +65,7 @@ See header file `can_api.h` for a description of the provided functions. ### CAN API V3 Reference -A generic documentation of the CAN API V3 application programming interface can be found [here](https://uv-software.github.io/CANAPI-Docs/#/). +A generic documentation of the CAN API V3 application programming interface is available as [Docsify pages](https://uv-software.github.io/CANAPI-Docs/#/). ### vanilla-json @@ -80,5 +80,5 @@ You can choose between one of them if you use this work in whole or in part. ### Contact -E-Mail: mailto://info@uv-software.com \ +E-Mail: mailto://info@uv-software.de \ Internet: https://www.uv-software.com diff --git a/Sources/CANAPI/can_api.h b/Sources/CANAPI/can_api.h index 83e5084..d8a6715 100644 --- a/Sources/CANAPI/can_api.h +++ b/Sources/CANAPI/can_api.h @@ -7,8 +7,8 @@ * * This file is part of CAN API V3. * - * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License - * and under the GNU General Public License v2.0 (or any later version). You can + * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and + * under the GNU General Public License v2.0 (or any later version). You can * choose between one of them if you use CAN API V3 in whole or in part. * * (1) BSD 2-Clause "Simplified" License @@ -51,9 +51,9 @@ * * @brief CAN API V3 for generic CAN Interfaces * - * @author $Author: makemake $ + * @author $Author: sedna $ * - * @version $Rev: 1407 $ + * @version $Rev: 1488 $ of $Date: 2025-03-06 20:46:30 +0100 (Do, 06 Mrz 2025) $ * * @defgroup can_api CAN Interface API, Version 3 * @{ diff --git a/Sources/CANAPI/can_btr.c b/Sources/CANAPI/can_btr.c index 1c2447f..6643899 100644 --- a/Sources/CANAPI/can_btr.c +++ b/Sources/CANAPI/can_btr.c @@ -7,8 +7,8 @@ * * This file is part of CAN API V3. * - * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License - * and under the GNU General Public License v2.0 (or any later version). You can + * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and + * under the GNU General Public License v2.0 (or any later version). You can * choose between one of them if you use CAN API V3 in whole or in part. * * (1) BSD 2-Clause "Simplified" License @@ -57,9 +57,9 @@ * | SJW | BRP |SAM| TSEG2 | TSEG1 |
* +-7-+-6-+-5-+---+---+---+---+-0-+-7-+-6-+---+-4-+-3-+---+---+-0-+
* - * @author $Author: makemake $ + * @author $Author: sedna $ * - * @version $Rev: 1407 $ + * @version $Rev: 1488 $ of $Date: 2025-03-06 20:46:30 +0100 (Do, 06 Mrz 2025) $ * * @addtogroup can_btr * @{ diff --git a/Sources/CANAPI/can_btr.h b/Sources/CANAPI/can_btr.h index 45adfe8..b8a5b75 100644 --- a/Sources/CANAPI/can_btr.h +++ b/Sources/CANAPI/can_btr.h @@ -7,8 +7,8 @@ * * This file is part of CAN API V3. * - * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License - * and under the GNU General Public License v2.0 (or any later version). You can + * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and + * under the GNU General Public License v2.0 (or any later version). You can * choose between one of them if you use CAN API V3 in whole or in part. * * (1) BSD 2-Clause "Simplified" License @@ -51,9 +51,9 @@ * * @brief CAN API V3 for generic CAN Interfaces (Bit-rate Conversion) * - * @author $Author: makemake $ + * @author $Author: sedna $ * - * @version $Rev: 1407 $ + * @version $Rev: 1488 $ of $Date: 2025-03-06 20:46:30 +0100 (Do, 06 Mrz 2025) $ * * @defgroup can_btr CAN Bit-rate Conversion * @{ diff --git a/Sources/CANAPI/can_msg.c b/Sources/CANAPI/can_msg.c index 6025434..e9bad32 100644 --- a/Sources/CANAPI/can_msg.c +++ b/Sources/CANAPI/can_msg.c @@ -7,8 +7,8 @@ * * This file is part of CAN API V3. * - * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License - * and under the GNU General Public License v2.0 (or any later version). You can + * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and + * under the GNU General Public License v2.0 (or any later version). You can * choose between one of them if you use CAN API V3 in whole or in part. * * (1) BSD 2-Clause "Simplified" License @@ -51,9 +51,9 @@ * * @brief CAN Message Formatter * - * @author $Author: quaoar $ + * @author $Author: sedna $ * - * @version $Rev: 1467 $ + * @version $Rev: 1490 $ of $Date: 2025-03-06 21:06:42 +0100 (Do, 06 Mrz 2025) $ * * @addtogroup can_msg * @{ @@ -234,7 +234,7 @@ char *msg_format_message(const msg_message_t *message, msg_direction_t direction /* flags (optional) */ if (msg_option.flags != MSG_FMT_OPTION_OFF) { #if (OPTION_CAN_2_0_ONLY == 0) - if (!message->sts) { + if (!message->sts && !message->err) { strcat(msg_string, message->xtd ? "X" : "S"); strcat(msg_string, message->fdf ? "F" : "-"); strcat(msg_string, message->brs ? "B" : "-"); @@ -245,7 +245,7 @@ char *msg_format_message(const msg_message_t *message, msg_direction_t direction strcat(msg_string, "Error"); } #else - if (!message->sts) { + if (!message-> && !message->err) { strcat(msg_string, message->xtd ? "X" : "S"); strcat(msg_string, message->rtr ? "R" : "-"); } @@ -301,7 +301,7 @@ char *msg_format_flags(const msg_message_t *message) if (message) { #if (OPTION_CAN_2_0_ONLY == 0) - if (!message->sts) { + if (!message->sts && !message->err) { strcat(msg_string, message->xtd ? "X" : "S"); strcat(msg_string, message->fdf ? "F" : "-"); strcat(msg_string, message->brs ? "B" : "-"); @@ -312,7 +312,7 @@ char *msg_format_flags(const msg_message_t *message) strcat(msg_string, "Error"); } #else - if (!message->sts) { + if (!message->sts && !message->err) { strcat(msg_string, message->xtd ? "X" : "S"); strcat(msg_string, message->rtr ? "R" : "-"); } diff --git a/Sources/CANAPI/can_msg.h b/Sources/CANAPI/can_msg.h index 351fa9b..7e34075 100644 --- a/Sources/CANAPI/can_msg.h +++ b/Sources/CANAPI/can_msg.h @@ -7,8 +7,8 @@ * * This file is part of CAN API V3. * - * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License - * and under the GNU General Public License v2.0 (or any later version). You can + * CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License and + * under the GNU General Public License v2.0 (or any later version). You can * choose between one of them if you use CAN API V3 in whole or in part. * * (1) BSD 2-Clause "Simplified" License @@ -53,7 +53,7 @@ * * @author $Author: sedna $ * - * @version $Rev: 1458 $ + * @version $Rev: 1490 $ of $Date: 2025-03-06 21:06:42 +0100 (Do, 06 Mrz 2025) $ * * @defgroup can_msg CAN Message Formatter * @{ @@ -249,10 +249,11 @@ typedef struct msg_message_t_ { uint8_t fdf : 1; /**< flag: CAN FD format */ uint8_t brs : 1; /**< flag: bit-rate switching */ uint8_t esi : 1; /**< flag: error state indicator */ - uint8_t : 2; + uint8_t : 1; #else - uint8_t : 5; + uint8_t : 4; #endif + uint8_t err : 1; /**< flag: error frame (ECC) */ uint8_t sts : 1; /**< flag: status message */ }; #if (OPTION_CAN_2_0_ONLY == 0) diff --git a/Sources/PCANBasic/PCANBasic.h b/Sources/PCANBasic/PCANBasic.h index 8bd4167..05ab1f7 100644 --- a/Sources/PCANBasic/PCANBasic.h +++ b/Sources/PCANBasic/PCANBasic.h @@ -8,12 +8,12 @@ // // ------------------------------------------------------------------ // Author : Keneth Wagner -// Last change: 2024-09-24 +// Last change: 2025-10-24 // // Language: ANSI-C // ------------------------------------------------------------------ // -// Copyright (C) 1999-2024 PEAK-System Technik GmbH, Darmstadt +// Copyright (C) 1999-2025 PEAK-System Technik GmbH, Darmstadt // more Info at http://www.peak-system.com // #ifndef __PCANBASICH__ @@ -27,17 +27,6 @@ // #define PCAN_NONEBUS 0x00U // Undefined/default value for a PCAN bus -#define PCAN_ISABUS1 0x21U // PCAN-ISA interface, channel 1 -#define PCAN_ISABUS2 0x22U // PCAN-ISA interface, channel 2 -#define PCAN_ISABUS3 0x23U // PCAN-ISA interface, channel 3 -#define PCAN_ISABUS4 0x24U // PCAN-ISA interface, channel 4 -#define PCAN_ISABUS5 0x25U // PCAN-ISA interface, channel 5 -#define PCAN_ISABUS6 0x26U // PCAN-ISA interface, channel 6 -#define PCAN_ISABUS7 0x27U // PCAN-ISA interface, channel 7 -#define PCAN_ISABUS8 0x28U // PCAN-ISA interface, channel 8 - -#define PCAN_DNGBUS1 0x31U // PCAN-Dongle/LPT interface, channel 1 - #define PCAN_PCIBUS1 0x41U // PCAN-PCI interface, channel 1 #define PCAN_PCIBUS2 0x42U // PCAN-PCI interface, channel 2 #define PCAN_PCIBUS3 0x43U // PCAN-PCI interface, channel 3 @@ -72,9 +61,6 @@ #define PCAN_USBBUS15 0x50FU // PCAN-USB interface, channel 15 #define PCAN_USBBUS16 0x510U // PCAN-USB interface, channel 16 -#define PCAN_PCCBUS1 0x61U // PCAN-PC Card interface, channel 1 -#define PCAN_PCCBUS2 0x62U // PCAN-PC Card interface, channel 2 - #define PCAN_LANBUS1 0x801U // PCAN-LAN interface, channel 1 #define PCAN_LANBUS2 0x802U // PCAN-LAN interface, channel 2 #define PCAN_LANBUS3 0x803U // PCAN-LAN interface, channel 3 @@ -127,13 +113,8 @@ // PCAN devices // #define PCAN_NONE 0x00U // Undefined, unknown or not selected PCAN device value -#define PCAN_PEAKCAN 0x01U // PCAN Non-PnP devices. NOT USED WITHIN PCAN-Basic API -#define PCAN_ISA 0x02U // PCAN-ISA, PCAN-PC/104, and PCAN-PC/104-Plus -#define PCAN_DNG 0x03U // PCAN-Dongle #define PCAN_PCI 0x04U // PCAN-PCI, PCAN-cPCI, PCAN-miniPCI, and PCAN-PCI Express #define PCAN_USB 0x05U // PCAN-USB and PCAN-USB Pro -#define PCAN_PCC 0x06U // PCAN-PC Card -#define PCAN_VIRTUAL 0x07U // PCAN Virtual hardware. NOT USED WITHIN PCAN-Basic API #define PCAN_LAN 0x08U // PCAN Gateway devices // PCAN parameters @@ -161,10 +142,10 @@ #define PCAN_CHANNEL_IDENTIFYING 0x15U // Physical identification of a USB based PCAN-Channel by blinking its associated LED #define PCAN_CHANNEL_FEATURES 0x16U // Capabilities of a PCAN device (FEATURE_***) #define PCAN_BITRATE_ADAPTING 0x17U // Using of an existing bit rate (PCAN-View connected to a channel) -#define PCAN_BITRATE_INFO 0x18U // Configured bit rate as Btr0Btr1 value +#define PCAN_BITRATE_INFO_BTR 0x18U // Configured bit rate as a Baud Rate Timing Register value #define PCAN_BITRATE_INFO_FD 0x19U // Configured bit rate as TPCANBitrateFD string #define PCAN_BUSSPEED_NOMINAL 0x1AU // Configured nominal CAN Bus speed as Bits per seconds -#define PCAN_BUSSPEED_DATA 0x1BU // Configured CAN data speed as Bits per seconds +#define PCAN_BUSSPEED_FD 0x1BU // Configured CAN data speed as Bits per seconds #define PCAN_IP_ADDRESS 0x1CU // Remote address of a LAN channel as string in IPv4 format #define PCAN_LAN_SERVICE_STATUS 0x1DU // Status of the Virtual PCAN-Gateway Service #define PCAN_ALLOW_STATUS_FRAMES 0x1EU // Status messages reception status within a PCAN-Channel @@ -186,10 +167,14 @@ #define PCAN_HARD_RESET_STATUS 0x2EU // Activation status of hard reset processing via CAN_Reset calls #define PCAN_LAN_CHANNEL_DIRECTION 0x2FU // Communication direction of a PCAN-Channel representing a PCAN-LAN interface #define PCAN_DEVICE_GUID 0x30U // Get the global unique device identifier (GUID) associated to a device +#define PCAN_BITRATE_INFO_CC 0x31U // Configured bit rate as TPCANBitrateCC value +#define PCAN_BITRATE_INFO_XL 0x32U // Configured bit rate as TPCANBitrateXL string +#define PCAN_BUSSPEED_XL 0x33U // Configured CAN XL Bus speed as Bits per seconds // DEPRECATED parameters // -#define PCAN_DEVICE_NUMBER PCAN_DEVICE_ID // Deprecated parameter. Use PCAN_DEVICE_ID instead +#define PCAN_BUSSPEED_DATA PCAN_BUSSPEED_FD // Deprecated parameter. Use PCAN_BUSSPEED_FD instead +#define PCAN_BITRATE_INFO PCAN_BITRATE_INFO_BTR // Deprecated parameter. Use PCAN_BITRATE_INFO_BTR instead // PCAN parameter values // @@ -218,9 +203,10 @@ #define TRACE_FILE_OVERWRITE 0x80U // Causes the overwriting of available traces (same name) #define TRACE_FILE_DATA_LENGTH 0x100U // Causes using the data length column ('l') instead of the DLC column ('L') in the trace file -#define FEATURE_FD_CAPABLE 0x01U // Device supports flexible data-rate (CAN-FD) +#define FEATURE_FD_CAPABLE 0x01U // Device supports the subsequent development of the classic CAN bus (CAN FD) #define FEATURE_DELAY_CAPABLE 0x02U // Device supports a delay between sending frames (FPGA based USB devices) #define FEATURE_IO_CAPABLE 0x04U // Device supports I/O functionality for electronic circuits (USB-Chip devices) +#define FEATURE_XL_CAPABLE 0x08U // Device supports the subsequent development of the classic CAN bus (CAN-XL) #define SERVICE_STATUS_STOPPED 0x01U // The service is not running #define SERVICE_STATUS_RUNNING 0x04U // The service is running @@ -231,20 +217,30 @@ // Other constants // -#define MAX_LENGTH_HARDWARE_NAME 33 // Maximum length of the name of a device: 32 characters + terminator -#define MAX_LENGTH_VERSION_STRING 256 // Maximum length of a version string: 255 characters + terminator +#define MAX_LENGTH_HARDWARE_NAME 33 // Maximum length of the name of a device: 32 characters + terminator +#define MAX_LENGTH_VERSION_STRING 256 // Maximum length of a version string: 255 characters + terminator +#define MAX_LENGTH_DATA_XL 2048 // Maximum amount of data bytes of a CAN-XL message +#define MAX_VALUE_STANDARD_ID 0x7FF // Maximum value for a standard CAN ID of a CAN CC/FD message +#define MAX_VALUE_EXTENDED_ID 0x1FFFFFFF // Maximum value for an extended CAN ID of a CAN CC/FD message +#define MAX_VALUE_PRIORITY_ID 0x7FF // Maximum value for a Priority ID of a CAN XL message // PCAN message types // -#define PCAN_MESSAGE_STANDARD 0x00U // The PCAN message is a CAN Standard Frame (11-bit identifier) -#define PCAN_MESSAGE_RTR 0x01U // The PCAN message is a CAN Remote-Transfer-Request Frame -#define PCAN_MESSAGE_EXTENDED 0x02U // The PCAN message is a CAN Extended Frame (29-bit identifier) -#define PCAN_MESSAGE_FD 0x04U // The PCAN message represents a FD frame in terms of CiA Specs -#define PCAN_MESSAGE_BRS 0x08U // The PCAN message represents a FD bit rate switch (CAN data at a higher bit rate) -#define PCAN_MESSAGE_ESI 0x10U // The PCAN message represents a FD error state indicator(CAN FD transmitter was error active) -#define PCAN_MESSAGE_ECHO 0x20U // The PCAN message represents an echo CAN Frame -#define PCAN_MESSAGE_ERRFRAME 0x40U // The PCAN message represents an error frame -#define PCAN_MESSAGE_STATUS 0x80U // The PCAN message represents a PCAN status message +#define PCAN_MESSAGE_STANDARD 0x00U // The PCAN message is a CAN Standard Frame (11-bit identifier) +#define PCAN_MESSAGE_RTR 0x01U // The PCAN message is a CAN Remote-Transfer-Request Frame +#define PCAN_MESSAGE_EXTENDED 0x02U // The PCAN message is a CAN Extended Frame (29-bit identifier) +#define PCAN_MESSAGE_FD 0x04U // The PCAN message represents a FD frame in terms of CiA Specs +#define PCAN_MESSAGE_BRS 0x08U // The PCAN message represents a FD bit rate switch (CAN data at a higher bit rate) +#define PCAN_MESSAGE_ESI 0x10U // The PCAN message represents a FD error state indicator(CAN FD transmitter was error active) +#define PCAN_MESSAGE_ECHO 0x20U // The PCAN message represents an echo CAN Frame +#define PCAN_MESSAGE_ERRFRAME 0x40U // The PCAN message represents an error frame +#define PCAN_MESSAGE_STATUS 0x80U // The PCAN message represents a PCAN status message + +// PCAN message types XL +// +#define PCAN_MESSAGE_XL 0x100U // The PCAN message represents a XL frame in terms of CiA Specs +#define PCAN_MESSAGE_PROTOCOL_EXCEPTION 0x200U // The PCAN message represents a protocol exception from CAN core +#define PCAN_MESSAGE_ERROR_NOTIFICATION 0x400U // The PCAN message represents an error notification from CAN core // LookUp Parameters // @@ -260,9 +256,6 @@ #define PCAN_MODE_EXTENDED PCAN_MESSAGE_EXTENDED // Baud rate codes = BTR0/BTR1 register values for the CAN controller. -// You can define your own Baud rate with the BTROBTR1 register. -// Take a look at www.peak-system.com for our free software "BAUDTOOL" -// to calculate the BTROBTR1 register for every bit rate and sample point. // #define PCAN_BAUD_1M 0x0014U // 1 MBit/s #define PCAN_BAUD_800K 0x0016U // 800 kBit/s @@ -287,28 +280,42 @@ // Example: // f_clock=80000000,nom_brp=10,nom_tseg1=5,nom_tseg2=2,nom_sjw=1,data_brp=4,data_tseg1=7,data_tseg2=2,data_sjw=1 // -#define PCAN_BR_CLOCK __T("f_clock") -#define PCAN_BR_CLOCK_MHZ __T("f_clock_mhz") -#define PCAN_BR_NOM_BRP __T("nom_brp") -#define PCAN_BR_NOM_TSEG1 __T("nom_tseg1") -#define PCAN_BR_NOM_TSEG2 __T("nom_tseg2") -#define PCAN_BR_NOM_SJW __T("nom_sjw") -#define PCAN_BR_NOM_SAMPLE __T("nom_sam") -#define PCAN_BR_DATA_BRP __T("data_brp") -#define PCAN_BR_DATA_TSEG1 __T("data_tseg1") -#define PCAN_BR_DATA_TSEG2 __T("data_tseg2") -#define PCAN_BR_DATA_SJW __T("data_sjw") -#define PCAN_BR_DATA_SAMPLE __T("data_ssp_offset") - -// Type of PCAN (Non-PnP) hardware +#define PCAN_BR_CLOCK __T("f_clock") // Clock frequency in Herz (160000000, 80000000, 60000000, 40000000, 30000000, 24000000, 20000000) +#define PCAN_BR_CLOCK_MHZ __T("f_clock_mhz") // Clock frequency in Megaherz (160, 80, 60, 40, 30, 24, 20) + +// CAN-FD Bit rate specific values +// +#define PCAN_BR_NOM_BRP __T("nom_brp") // Clock prescaler for nominal time quantum +#define PCAN_BR_NOM_TSEG1 __T("nom_tseg1") // TSEG1 segment for nominal bit rate in time quanta +#define PCAN_BR_NOM_TSEG2 __T("nom_tseg2") // TSEG2 segment for nominal bit rate in time quanta +#define PCAN_BR_NOM_SJW __T("nom_sjw") // Synchronization Jump Width for nominal bit rate in time quanta +#define PCAN_BR_NOM_SAMPLE __T("nom_sam") // Sample point for nominal bit rate +#define PCAN_BR_DATA_BRP __T("data_brp") // Clock prescaler for highspeed data time quantum +#define PCAN_BR_DATA_TSEG1 __T("data_tseg1") // TSEG1 segment for fast data bit rate in time quanta +#define PCAN_BR_DATA_TSEG2 __T("data_tseg2") // TSEG2 segment for fast data bit rate in time quanta +#define PCAN_BR_DATA_SJW __T("data_sjw") // Synchronization Jump Width for highspeed data bit rate in time quanta +#define PCAN_BR_DATA_SAMPLE __T("data_ssp_offset") // DEPRECATED: Secondary sample point delay for highspeed data bit rate in cycles + // Use "PCAN_BR_DATA_SSP_OFFSET" instead +#define PCAN_BR_DATA_SSP_OFFSET __T("data_ssp_offset") // Secondary sample point delay for highspeed data bit rate in cycles + +// CAN-XL Bit rate specific values // -#define PCAN_TYPE_ISA 0x01U // PCAN-ISA 82C200 -#define PCAN_TYPE_ISA_SJA 0x09U // PCAN-ISA SJA1000 -#define PCAN_TYPE_ISA_PHYTEC 0x04U // PHYTEC ISA -#define PCAN_TYPE_DNG 0x02U // PCAN-Dongle 82C200 -#define PCAN_TYPE_DNG_EPP 0x03U // PCAN-Dongle EPP 82C200 -#define PCAN_TYPE_DNG_SJA 0x05U // PCAN-Dongle SJA1000 -#define PCAN_TYPE_DNG_SJA_EPP 0x06U // PCAN-Dongle EPP SJA1000 +#define PCAN_BR_BRP __T("brp") // Clock prescaler for nominal, CAN FD and CAN XL bit rates +#define PCAN_BR_FD_TSEG1 __T("fd_tseg1") // Clock prescaler for fast data time quantum +#define PCAN_BR_FD_TSEG2 __T("fd_tseg2") // Clock prescaler for fast data time quantum +#define PCAN_BR_FD_SJW __T("fd_sjw") // Synchronization Jump Width for fast data bit rate in time quanta +#define PCAN_BR_FD_SSP_OFFSET __T("fd_ssp_offset") // Secondary sample point delay for fast data bit rate in cycles +#define PCAN_BR_XL_TSEG1 __T("xl_tseg1") // Clock prescaler for XL time quantum +#define PCAN_BR_XL_TSEG2 __T("xl_tseg2") // Clock prescaler for XL time quantum +#define PCAN_BR_XL_SJW __T("xl_sjw") // Synchronization Jump Width for XL bit rate in time quanta +#define PCAN_BR_XL_SSP_OFFSET __T("xl_ssp_offset") // Secondary sample point delay for XL bit rate in cycles +#define PCAN_BR_XL_PWM_OFFSET __T("xl_pwm_offset") // CAN XL PWM Offset in mtq ticks == f_cancore cycles +#define PCAN_BR_XL_PWM_SHORT __T("xl_pwm_short") // CAN XL PWM Short phase in mtq ticks == f_cancore cycles +#define PCAN_BR_XL_PWM_LONG __T("xl_pwm_long") // CAN XL PWM Long phase in mtq ticks == f_cancore cycles +#define PCAN_BR_XL_TRANSCEIVER_MODE_SWITCH __T("xl_transceiver_mode_switch") // 1 = CAN XL Data Phase uses 'fast TX' or 'fast RX' with PWM encoding + // 0 = CAN XL Data Phase uses no PWM encoding (recessive/dominant only, like CAN FD) +#define PCAN_BR_XL_ERROR_SIGNALING __T("xl_error_signaling") // 1 = Error Signaling with Error Frame in case of bus errors + // 0 = No Error Signaling //////////////////////////////////////////////////////////// // Type definitions @@ -319,11 +326,14 @@ #define TPCANParameter BYTE // Represents a PCAN parameter to be read or set #define TPCANDevice BYTE // Represents a PCAN device #define TPCANMessageType BYTE // Represents the type of a PCAN message -#define TPCANType BYTE // Represents the type of PCAN hardware to be initialized +#define TPCANMessageTypeXL WORD // Represents the type of a PCAN XL message #define TPCANMode BYTE // Represents a PCAN filter mode -#define TPCANBaudrate WORD // Represents a PCAN Baud rate register value -#define TPCANBitrateFD LPSTR // Represents a PCAN-FD bit rate string +#define TPCANBaudrate WORD // Represents a PCAN Baud Rate Timing Register value +#define TPCANBitrateCC LPSTR // Represents a PCAN classic bit rate string +#define TPCANBitrateFD LPSTR // Represents a PCAN FD bit rate string +#define TPCANBitrateXL LPSTR // Represents a PCAN XL bit rate string #define TPCANTimestampFD UINT64 // Represents a timestamp of a received PCAN FD message +#define TPCANTimestampXL TPCANTimestampFD // Represents a timestamp of a received PCAN XL message //////////////////////////////////////////////////////////// // Structure definitions @@ -359,6 +369,25 @@ typedef struct tagTPCANMsgFD BYTE DATA[64]; // Data of the message (DATA[0]..DATA[63]) } TPCANMsgFD; +// Represents a PCAN message from a XL capable hardware +// REMARKS: +// CAN-CC/CAN-FD: only the fields PID, MSGTYPE, DLC,and DATA are used. +// Additonal CAN-XL related fields are ignored +// +typedef struct tagTPCANMsgXL +{ + DWORD PID; // CAN-XL: Priority ID (physical layer) (0..0x7FF) + // CAN-CC/CAN-FD: 11/29-bit message identifier + BYTE VCID; // Virtual CAN network ID + TPCANMessageTypeXL MSGTYPE; // Type of the message + WORD DLC; // Data Length Code of the message (0..2047) + BYTE SDT; // Service Data unit(SDU) protocol Type + DWORD AF; // Acceptance Field, SDU - specific high - layer ID + BYTE RRS; // Remote Request Substitution flag (0..1) + BYTE SEC; // Simple Extended Content flag (0..1) + BYTE DATA[2048]; // Data of the message (DATA[0]..DATA[2047]) +}TPCANMsgXL; + // Describes an available PCAN channel // typedef struct tagTPCANChannelInformation @@ -389,16 +418,16 @@ extern "C" { /// /// "The handle of a PCAN Channel" /// "The speed for the communication (BTR0BTR1 code)" -/// "Non-PnP: The type of hardware and operation mode" -/// "Non-PnP: The I/O address for the parallel port" -/// "Non-PnP: Interrupt number of the parallel port" +/// "Deprecated. Parameter is ignored" +/// "Deprecated. Parameter is ignored" +/// "Deprecated. Parameter is ignored" /// "A TPCANStatus error code" TPCANStatus __stdcall CAN_Initialize( TPCANHandle Channel, TPCANBaudrate Btr0Btr1, - TPCANType HwType _DEF_ARG, - DWORD IOPort _DEF_ARG, - WORD Interrupt _DEF_ARG); + BYTE deprecated1 _DEF_ARG, + DWORD deprecated2 _DEF_ARG, + WORD deprecated3 _DEF_ARG); /// @@ -419,6 +448,26 @@ TPCANStatus __stdcall CAN_InitializeFD( TPCANHandle Channel, TPCANBitrateFD BitrateFD); +/// +/// Initializes a XL capable PCAN Channel +/// +/// The handle of a XL capable PCAN Channel" +/// "The speed for the communication (XL bit rate string)" +/// See PCAN_BR_* values +/// * Parameter and values must be separated by '=' +/// * Couples of Parameter/value must be separated by ',' +/// * Following Parameter must be filled out: f_clock, brp, nom_brp, nom_sjw, nom_tseg1, nom_tseg2. +/// If xl_transceiver_mode_switch is active, also the parameters xl_sjw, xl_tseg1, and xl_tseg2, must be present. +/// If error_signaling is active, also the parameters fd_sjw, fd_tseg1, and fd_tseg2, must be present. +/// * Following Parameters are optional: fd_ssp_offset, xl_ssp_offset, xl_transceiver_mode_switch, error_signaling, +/// xl_pwm_offset, xl_pwm_short, and xl_pwm_long +/// +/// f_clock=160000000,brp=1,nom_tseg1=255,nom_tseg2=64,nom_sjw=64,fd_tseg1=63,fd_tseg2=16,fd_sjw=16,fd_ssp_offset=0,xl_tseg1=10, +/// xl_tseg2=9,xl_sjw=9,xl_ssp_offset=10,xl_error_signaling=1,xl_transceiver_mode_switch=0 +/// "A TPCANStatus error code" +TPCANStatus __stdcall CAN_InitializeXL( + TPCANHandle Channel, + TPCANBitrateXL BitrateXL); /// /// Uninitializes one or all PCAN Channels initialized by CAN_Initialize @@ -481,6 +530,20 @@ TPCANStatus __stdcall CAN_ReadFD( TPCANMsgFD* MessageBuffer, TPCANTimestampFD *TimestampBuffer); +/// +/// Reads a CAN message from the receive queue of a XL capable PCAN Channel +/// +/// "The handle of a XL capable PCAN Channel" +/// "A TPCANMsgXL structure buffer to store the CAN message" +/// "A TPCANTimestampXL buffer to get +/// the reception time of the message. If this value is not desired, this parameter +/// should be passed as NULL" +/// "A TPCANStatus error code" +TPCANStatus __stdcall CAN_ReadXL( + TPCANHandle Channel, + TPCANMsgXL* MessageBuffer, + TPCANTimestampXL* TimestampBuffer); + /// /// Transmits a CAN message @@ -503,6 +566,15 @@ TPCANStatus __stdcall CAN_WriteFD( TPCANHandle Channel, TPCANMsgFD* MessageBuffer); +/// +/// Transmits a CAN message over a XL capable PCAN Channel +/// +/// "The handle of a XL capable PCAN Channel" +/// "A TPCANMsgXL buffer with the message to be sent" +/// +TPCANStatus __stdcall CAN_WriteXL( + TPCANHandle Channel, + TPCANMsgXL* MessageBuffer); /// /// Configures the reception filter. diff --git a/Sources/PCANBasic/ReadMe.txt b/Sources/PCANBasic/ReadMe.txt index d1aa4f6..0b3f7f0 100644 --- a/Sources/PCANBasic/ReadMe.txt +++ b/Sources/PCANBasic/ReadMe.txt @@ -1,8 +1,8 @@ =============================================================================== ReadMe.txt -PCAN-Basic V4.10.1.968 -Copyright (c) 2025 PEAK-System Technik GmbH Darmstadt, Germany +PCAN-Basic V5.1.0.1194 +Copyright (c) 2026 PEAK-System Technik GmbH Darmstadt, Germany All rights reserved. =============================================================================== @@ -149,8 +149,8 @@ Darmstadt, Germany Tel. +49 6151 / 8173-20 FAX +49 6151 / 8173-29 -support@peak-system.com -http://www.peak-system.com +support.peak@hms-networks.com +https://www.peak-system.com LIFE SUPPORT APPLIANCES diff --git a/Sources/PCANBasic/x64/PCANBasic.lib b/Sources/PCANBasic/x64/PCANBasic.lib index e7e4f61..a7f8655 100644 Binary files a/Sources/PCANBasic/x64/PCANBasic.lib and b/Sources/PCANBasic/x64/PCANBasic.lib differ diff --git a/Sources/PCANBasic/x86/PCANBasic.lib b/Sources/PCANBasic/x86/PCANBasic.lib index f88571b..4418115 100644 Binary files a/Sources/PCANBasic/x86/PCANBasic.lib and b/Sources/PCANBasic/x86/PCANBasic.lib differ diff --git a/Sources/PeakCAN.cpp b/Sources/PeakCAN.cpp index de9163a..cf68ba6 100644 --- a/Sources/PeakCAN.cpp +++ b/Sources/PeakCAN.cpp @@ -3,7 +3,7 @@ // CAN Interface API, Version 3 (for PEAK-System PCAN Interfaces) // // Copyright (c) 2005-2012 Uwe Vogt, UV Software, Friedrichshafen -// Copyright (c) 2013-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2013-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) // All rights reserved. // // This file is part of PCANBasic-Wrapper. @@ -68,8 +68,6 @@ #if defined(_WIN64) #define PLATFORM "x64" -#elif defined(_WIN32) -#define PLATFORM "x86" #elif defined(__linux__) #define PLATFORM "Linux" #elif defined(__APPLE__) diff --git a/Sources/PeakCAN.h b/Sources/PeakCAN.h index 4f9510c..99eac42 100644 --- a/Sources/PeakCAN.h +++ b/Sources/PeakCAN.h @@ -3,7 +3,7 @@ // CAN Interface API, Version 3 (for PEAK-System PCAN Interfaces) // // Copyright (c) 2005-2012 Uwe Vogt, UV Software, Friedrichshafen -// Copyright (c) 2013-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2013-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.de) // All rights reserved. // // This file is part of PCANBasic-Wrapper. @@ -62,7 +62,7 @@ #define PEAKCAN_LIBRARY_NAME CANDLL_PCANBASIC #define PEAKCAN_LIBRARY_VENDOR "UV Software, Berlin" #define PEAKCAN_LIBRARY_LICENSE "BSD-2-Clause OR GPL-2.0-or-later" -#define PEAKCAN_LIBRARY_COPYRIGHT "Copyright (c) 2005-2025 by Uwe Vogt, UV Software, Berlin" +#define PEAKCAN_LIBRARY_COPYRIGHT "Copyright (c) 2005-2026 by Uwe Vogt, UV Software, Berlin" #define PEAKCAN_LIBRARY_HAZARD_NOTE "If you connect your CAN device to a real CAN network when using this library,\n" \ "you might damage your application." /// \} diff --git a/Sources/PeakCAN_Defaults.h b/Sources/PeakCAN_Defaults.h index 5015dd9..4605498 100644 --- a/Sources/PeakCAN_Defaults.h +++ b/Sources/PeakCAN_Defaults.h @@ -3,7 +3,7 @@ * CAN Interface API, Version 3 (for PEAK-System PCAN Interfaces) * * Copyright (c) 2005-2012 Uwe Vogt, UV Software, Friedrichshafen - * Copyright (c) 2013-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) + * Copyright (c) 2013-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) * All rights reserved. * * This file is part of PCANBasic-Wrapper. @@ -159,10 +159,10 @@ extern "C" { /** @name PEAK CAN FD Bit-rate Settings w/o Bit-rate Switching * @brief Default values for long frames only (0 to 64 bytes). * @{ */ -#define PEAKCAN_FD_BR_1M(x) do {x.btr.frequency=PEAKCAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=31; x.btr.nominal.tseg2=8; x.btr.nominal.sjw=8; } while(0) -#define PEAKCAN_FD_BR_500K(x) do {x.btr.frequency=PEAKCAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=63; x.btr.nominal.tseg2=16;x.btr.nominal.sjw=16;} while(0) -#define PEAKCAN_FD_BR_250K(x) do {x.btr.frequency=PEAKCAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=127;x.btr.nominal.tseg2=32;x.btr.nominal.sjw=32;} while(0) -#define PEAKCAN_FD_BR_125K(x) do {x.btr.frequency=PEAKCAN_FD_CLOCK;x.btr.nominal.brp=2;x.btr.nominal.tseg1=255;x.btr.nominal.tseg2=64;x.btr.nominal.sjw=64;} while(0) +#define PEAKCAN_FD_BR_1M(x) do {x.btr.frequency=PEAKCAN_FD_CLOCK;x.btr.nominal.brp=2; x.btr.nominal.tseg1=31; x.btr.nominal.tseg2=8; x.btr.nominal.sjw=8;} while(0) +#define PEAKCAN_FD_BR_500K(x) do {x.btr.frequency=PEAKCAN_FD_CLOCK;x.btr.nominal.brp=4; x.btr.nominal.tseg1=31; x.btr.nominal.tseg2=8; x.btr.nominal.sjw=8;} while(0) +#define PEAKCAN_FD_BR_250K(x) do {x.btr.frequency=PEAKCAN_FD_CLOCK;x.btr.nominal.brp=8; x.btr.nominal.tseg1=31; x.btr.nominal.tseg2=8; x.btr.nominal.sjw=8;} while(0) +#define PEAKCAN_FD_BR_125K(x) do {x.btr.frequency=PEAKCAN_FD_CLOCK;x.btr.nominal.brp=16;x.btr.nominal.tseg1=31; x.btr.nominal.tseg2=8; x.btr.nominal.sjw=8;} while(0) /** @} */ /** @name PEAK CAN FD Bit-rate Settings with Bit-rate Switching diff --git a/Sources/PeakCAN_Defines.h b/Sources/PeakCAN_Defines.h index 5a4965b..b35d6b3 100644 --- a/Sources/PeakCAN_Defines.h +++ b/Sources/PeakCAN_Defines.h @@ -3,7 +3,7 @@ * CAN Interface API, Version 3 (for PEAK-System PCAN Interfaces) * * Copyright (c) 2005-2012 Uwe Vogt, UV Software, Friedrichshafen - * Copyright (c) 2013-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) + * Copyright (c) 2013-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) * All rights reserved. * * This file is part of PCANBasic-Wrapper. @@ -168,8 +168,8 @@ extern "C" { #if defined(_WIN32) || defined (_WIN64) #define PCAN_LIB_BASIC "PCANBasic.dll" #define PCAN_LIB_WRAPPER "u3canpcb.dll" - #define PCAN_LIB_MIN_MAJOR 4U - #define PCAN_LIB_MIN_MINOR 5U + #define PCAN_LIB_MIN_MAJOR 5U + #define PCAN_LIB_MIN_MINOR 0U #elif defined(__APPLE__) #define PCAN_LIB_BASIC "libPCBUSB.dylib" #define PCAN_LIB_WRAPPER "libUVCANPCB.dylib" @@ -178,7 +178,7 @@ extern "C" { #elif defined(__linux__) #define PCAN_LIB_BASIC "libpcanbasic.so" #define PCAN_LIB_WRAPPER "libuvcanpcb.so" - #define PCAN_LIB_MIN_MAJOR 8U + #define PCAN_LIB_MIN_MAJOR 9U #define PCAN_LIB_MIN_MINOR 0U #else #error Platform not supported diff --git a/Sources/Version.h b/Sources/Version.h index 9787684..b1280c8 100644 --- a/Sources/Version.h +++ b/Sources/Version.h @@ -3,7 +3,7 @@ * CAN Interface API, Version 3 (for PEAK-System PCAN Interfaces) * * Copyright (c) 2005-2012 Uwe Vogt, UV Software, Friedrichshafen - * Copyright (c) 2013-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) + * Copyright (c) 2013-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) * All rights reserved. * * This file is part of PCANBasic-Wrapper. @@ -51,15 +51,9 @@ #ifndef VERSION_H_INCLUDED #define VERSION_H_INCLUDED #include "build_no.h" -#ifdef _MSC_VER #define VERSION_MAJOR 0 #define VERSION_MINOR 6 -#define VERSION_PATCH 0 -#else -#define VERSION_MAJOR 0 -#define VERSION_MINOR 4 -#define VERSION_PATCH 0 -#endif +#define VERSION_PATCH 1 #define VERSION_BUILD BUILD_NO #if (VERSION_PATCH == 0) #define VERSION_STRING TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) " (" TOSTRING(BUILD_NO) ")" diff --git a/Sources/Wrapper/can_api.c b/Sources/Wrapper/can_api.c index 0733570..030ab93 100644 --- a/Sources/Wrapper/can_api.c +++ b/Sources/Wrapper/can_api.c @@ -3,7 +3,7 @@ * CAN Interface API, Version 3 (for PEAK-System PCAN Interfaces) * * Copyright (c) 2005-2012 Uwe Vogt, UV Software, Friedrichshafen - * Copyright (c) 2013-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) + * Copyright (c) 2013-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) * All rights reserved. * * This file is part of PCANBasic-Wrapper. @@ -59,8 +59,6 @@ #endif #if defined(_WIN64) #define PLATFORM "x64" -#elif defined(_WIN32) -#define PLATFORM "x86" #else #error Platform not supported #endif diff --git a/Sources/Wrapper/can_defs.h b/Sources/Wrapper/can_defs.h index 36854ad..9a05ae8 100644 --- a/Sources/Wrapper/can_defs.h +++ b/Sources/Wrapper/can_defs.h @@ -3,7 +3,7 @@ * CAN Interface API, Version 3 (for PEAK-System PCAN Interfaces) * * Copyright (c) 2005-2012 Uwe Vogt, UV Software, Friedrichshafen - * Copyright (c) 2013-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) + * Copyright (c) 2013-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) * All rights reserved. * * This file is part of PCANBasic-Wrapper. diff --git a/Tests/Driver.h b/Tests/Driver.h index 6715dce..4b18f67 100644 --- a/Tests/Driver.h +++ b/Tests/Driver.h @@ -133,7 +133,6 @@ typedef CPeakCAN CCanDriver; // (§10) define macros for CAN FD bit-rate settings // at least BITRATE_FD_1M8M, BITRATE_FD_500K4M, BITRATE_FD_250K2M, BITRATE_FD_125K1M, // BITRATE_FD_1M, BITRATE_FD_500K, BITRATE_FD_250K, BITRATE_FD_125K -#if (OPTION_PCAN_BIT_TIMING == 1) #define BITRATE_FD_1M(x) PEAKCAN_FD_BR_1M(x) #define BITRATE_FD_500K(x) PEAKCAN_FD_BR_500K(x) #define BITRATE_FD_250K(x) PEAKCAN_FD_BR_250K(x) @@ -142,16 +141,6 @@ typedef CPeakCAN CCanDriver; #define BITRATE_FD_500K4M(x) PEAKCAN_FD_BR_500K4M(x) #define BITRATE_FD_250K2M(x) PEAKCAN_FD_BR_250K2M(x) #define BITRATE_FD_125K1M(x) PEAKCAN_FD_BR_125K1M(x) -#else -#define BITRATE_FD_1M(x) DEFAULT_CAN_FD_BR_1M(x) -#define BITRATE_FD_500K(x) DEFAULT_CAN_FD_BR_500K(x) -#define BITRATE_FD_250K(x) DEFAULT_CAN_FD_BR_250K(x) -#define BITRATE_FD_125K(x) DEFAULT_CAN_FD_BR_125K(x) -#define BITRATE_FD_1M8M(x) DEFAULT_CAN_FD_BR_1M8M(x) -#define BITRATE_FD_500K4M(x) DEFAULT_CAN_FD_BR_500K4M(x) -#define BITRATE_FD_250K2M(x) DEFAULT_CAN_FD_BR_250K2M(x) -#define BITRATE_FD_125K1M(x) DEFAULT_CAN_FD_BR_125K1M(x) -#endif // (§11) define macros for workarounds for CAN FD operation mode (e.g. TC01_3_ISSUE_FD) #if (OPTION_REGRESSION_TEST == 0) diff --git a/Tests/GoogleTest/README.md b/Tests/GoogleTest/README.md index f50c670..b4e9b43 100644 --- a/Tests/GoogleTest/README.md +++ b/Tests/GoogleTest/README.md @@ -2,27 +2,19 @@ ### Announcements -#### Live at Head - -GoogleTest now follows the -[Abseil Live at Head philosophy](https://abseil.io/about/philosophy#upgrade-support). -We recommend -[updating to the latest commit in the `main` branch as often as possible](https://github.com/abseil/abseil-cpp/blob/master/FAQ.md#what-is-live-at-head-and-how-do-i-do-it). -We do publish occasional semantic versions, tagged with -`v${major}.${minor}.${patch}` (e.g. `v1.15.0`). - #### Documentation Updates Our documentation is now live on GitHub Pages at https://google.github.io/googletest/. We recommend browsing the documentation on GitHub Pages rather than directly in the repository. -#### Release 1.15.0 +#### Release 1.18.0 -[Release 1.15.0](https://github.com/google/googletest/releases/tag/v1.15.0) is +[Release 1.18.0](https://github.com/google/googletest/releases/tag/v1.18.0) is now available. -The 1.15.x branch requires at least C++14. +The 1.18.x branch +[requires at least C++17](https://opensource.google/documentation/policies/cplusplus-support#c_language_standard). #### Continuous Integration @@ -52,35 +44,35 @@ More information about building GoogleTest can be found at * xUnit test framework: \ Googletest is based on the [xUnit](https://en.wikipedia.org/wiki/XUnit) - testing framework, a popular architecture for unit testing + testing framework, a popular architecture for unit testing. * Test discovery: \ Googletest automatically discovers and runs your tests, eliminating the need - to manually register your tests + to manually register your tests. * Rich set of assertions: \ Googletest provides a variety of assertions, such as equality, inequality, - exceptions, and more, making it easy to test your code + exceptions, and more, making it easy to test your code. * User-defined assertions: \ You can define your own assertions with Googletest, making it simple to - write tests that are specific to your code + write tests that are specific to your code. * Death tests: \ Googletest supports death tests, which verify that your code exits in a - certain way, making it useful for testing error-handling code + certain way, making it useful for testing error-handling code. * Fatal and non-fatal failures: \ You can specify whether a test failure should be treated as fatal or non-fatal with Googletest, allowing tests to continue running even if a - failure occurs + failure occurs. * Value-parameterized tests: \ Googletest supports value-parameterized tests, which run multiple times with different input values, making it useful for testing functions that take - different inputs + different inputs. * Type-parameterized tests: \ Googletest also supports type-parameterized tests, which run with different data types, making it useful for testing functions that work with different - data types + data types. * Various options for running tests: \ Googletest provides many options for running tests including running individual tests, running tests in a specific order and running tests in - parallel + parallel. ## Supported Platforms diff --git a/Tests/GoogleTest/README.txt b/Tests/GoogleTest/README.txt index 17b392a..e3d6b75 100644 --- a/Tests/GoogleTest/README.txt +++ b/Tests/GoogleTest/README.txt @@ -7,32 +7,31 @@ released under the BSD 3-clause license and based on the xUnit architecture. CAN API V3 is a wrapper specification to have a multi-vendor, cross-platform CAN API. GoogleTest is used for testing of CAN API V3 C++ wrapper implementations. -Source Code Repositiory of GoogleTest -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Source Code Repository of GoogleTest +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ URL: https://github.com/google/googletest Current Version used by CAN API V3 C++ Testing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -v1.15.2 (https://github.com/google/googletest/releases/tag/v1.15.2) +v1.18.0 (https://github.com/google/googletest/releases/tag/v1.18.0) Installation and Usage of GoogleTest ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Clone the GoogleTest main branch or download the sources from a tag - e.g. into 'C:\Projekte\gtest' -2. Copy all header files from 'C:\Projekte\gtest\googletest\include\gtest' + e.g. into 'D:\Projekte\Testing\googletest' ($(GTESTDIR)) +2. Copy all header files from '$(GTESTDIR)\googletest\include\gtest' into '$(PROJROOT)\Tests\GoogleTest\include\gtest' -3. Build static libraries for x64 and x86 with CMake +3. Build static libraries for amd64 (_WIN64) with CMake note: GoogleMock (aka gmock) does not need to be created for this project. -4. Copy all files from 'C:\Projekte\gtest\googletest\out\build\x64-Debug\lib' - into $(PROJROOT)\Tests\GoogleTest\build\x64-Debug\lib' - and all files from 'C:\Projekte\gtest\googletest\out\build\x86-Debug\lib' - into $(PROJROOT)\Tests\GoogleTest\build\x86-Debug\lib' +4. Copy all files from '$(GTESTDIR)\build\lib\Debug' + into $(PROJROOT)\Tests\GoogleTest\Windows\lib\Debug' +*) Do not build for x86 (_WIN32) anymore! Important Notes ~~~~~~~~~~~~~~~ -- By default the GoogleTest libraries are build with option /MDt -- Since version 1.13.x Googletest requires at least C++14 +- Since version 1.17.0 Googletest requires at least C++17 (with option /MDd) +- Since version 1.13.x Googletest requires at least C++14 (with option /MDt) Last Updated ~~~~~~~~~~~~ -January 17, 2025 +August 25, 2026 diff --git a/Tests/GoogleTest/Windows/x64-Debug/lib/gtest.lib b/Tests/GoogleTest/Windows/lib/Debug/gtest.lib similarity index 60% rename from Tests/GoogleTest/Windows/x64-Debug/lib/gtest.lib rename to Tests/GoogleTest/Windows/lib/Debug/gtest.lib index 1fe91c1..2ec9ba9 100644 Binary files a/Tests/GoogleTest/Windows/x64-Debug/lib/gtest.lib and b/Tests/GoogleTest/Windows/lib/Debug/gtest.lib differ diff --git a/Tests/GoogleTest/Windows/lib/Debug/gtest.pdb b/Tests/GoogleTest/Windows/lib/Debug/gtest.pdb new file mode 100644 index 0000000..62d8780 Binary files /dev/null and b/Tests/GoogleTest/Windows/lib/Debug/gtest.pdb differ diff --git a/Tests/GoogleTest/Windows/lib/Debug/gtest_main.lib b/Tests/GoogleTest/Windows/lib/Debug/gtest_main.lib new file mode 100644 index 0000000..3903abc Binary files /dev/null and b/Tests/GoogleTest/Windows/lib/Debug/gtest_main.lib differ diff --git a/Tests/GoogleTest/Windows/lib/Debug/gtest_main.pdb b/Tests/GoogleTest/Windows/lib/Debug/gtest_main.pdb new file mode 100644 index 0000000..693ed37 Binary files /dev/null and b/Tests/GoogleTest/Windows/lib/Debug/gtest_main.pdb differ diff --git a/Tests/GoogleTest/Windows/lib/Debug/gtest_mainpdb_debug_postfix-NOTFOUND.pdb b/Tests/GoogleTest/Windows/lib/Debug/gtest_mainpdb_debug_postfix-NOTFOUND.pdb new file mode 100644 index 0000000..693ed37 Binary files /dev/null and b/Tests/GoogleTest/Windows/lib/Debug/gtest_mainpdb_debug_postfix-NOTFOUND.pdb differ diff --git a/Tests/GoogleTest/Windows/lib/Debug/gtestpdb_debug_postfix-NOTFOUND.pdb b/Tests/GoogleTest/Windows/lib/Debug/gtestpdb_debug_postfix-NOTFOUND.pdb new file mode 100644 index 0000000..62d8780 Binary files /dev/null and b/Tests/GoogleTest/Windows/lib/Debug/gtestpdb_debug_postfix-NOTFOUND.pdb differ diff --git a/Tests/GoogleTest/Windows/x64-Debug/lib/gtest_main.lib b/Tests/GoogleTest/Windows/x64-Debug/lib/gtest_main.lib deleted file mode 100644 index 0fe8081..0000000 Binary files a/Tests/GoogleTest/Windows/x64-Debug/lib/gtest_main.lib and /dev/null differ diff --git a/Tests/GoogleTest/Windows/x64-Debug/lib/gtest_mainpdb_debug_postfix-NOTFOUND.pdb b/Tests/GoogleTest/Windows/x64-Debug/lib/gtest_mainpdb_debug_postfix-NOTFOUND.pdb deleted file mode 100644 index cad960c..0000000 Binary files a/Tests/GoogleTest/Windows/x64-Debug/lib/gtest_mainpdb_debug_postfix-NOTFOUND.pdb and /dev/null differ diff --git a/Tests/GoogleTest/Windows/x64-Debug/lib/gtestpdb_debug_postfix-NOTFOUND.pdb b/Tests/GoogleTest/Windows/x64-Debug/lib/gtestpdb_debug_postfix-NOTFOUND.pdb deleted file mode 100644 index 0f98b74..0000000 Binary files a/Tests/GoogleTest/Windows/x64-Debug/lib/gtestpdb_debug_postfix-NOTFOUND.pdb and /dev/null differ diff --git a/Tests/GoogleTest/Windows/x86-Debug/lib/gtest.lib b/Tests/GoogleTest/Windows/x86-Debug/lib/gtest.lib deleted file mode 100644 index b203c8c..0000000 Binary files a/Tests/GoogleTest/Windows/x86-Debug/lib/gtest.lib and /dev/null differ diff --git a/Tests/GoogleTest/Windows/x86-Debug/lib/gtest_main.lib b/Tests/GoogleTest/Windows/x86-Debug/lib/gtest_main.lib deleted file mode 100644 index e32d62b..0000000 Binary files a/Tests/GoogleTest/Windows/x86-Debug/lib/gtest_main.lib and /dev/null differ diff --git a/Tests/GoogleTest/Windows/x86-Debug/lib/gtest_mainpdb_debug_postfix-NOTFOUND.pdb b/Tests/GoogleTest/Windows/x86-Debug/lib/gtest_mainpdb_debug_postfix-NOTFOUND.pdb deleted file mode 100644 index 4cc1520..0000000 Binary files a/Tests/GoogleTest/Windows/x86-Debug/lib/gtest_mainpdb_debug_postfix-NOTFOUND.pdb and /dev/null differ diff --git a/Tests/GoogleTest/Windows/x86-Debug/lib/gtestpdb_debug_postfix-NOTFOUND.pdb b/Tests/GoogleTest/Windows/x86-Debug/lib/gtestpdb_debug_postfix-NOTFOUND.pdb deleted file mode 100644 index 567e0f9..0000000 Binary files a/Tests/GoogleTest/Windows/x86-Debug/lib/gtestpdb_debug_postfix-NOTFOUND.pdb and /dev/null differ diff --git a/Tests/GoogleTest/include/gtest/gtest-assertion-result.h b/Tests/GoogleTest/include/gtest/gtest-assertion-result.h index 74eb2b1..a72ac93 100644 --- a/Tests/GoogleTest/include/gtest/gtest-assertion-result.h +++ b/Tests/GoogleTest/include/gtest/gtest-assertion-result.h @@ -129,8 +129,15 @@ namespace testing { // // Expected: Foo() is even // Actual: it's 5 +// + +// Returned AssertionResult objects may not be ignored. +// Note: Disabled for SWIG as it doesn't parse attributes correctly. +#if !defined(SWIG) +class [[nodiscard]] AssertionResult; +#endif // !SWIG -class GTEST_API_ AssertionResult { +class GTEST_API_ [[nodiscard]] AssertionResult { public: // Copy constructor. // Used in EXPECT_TRUE/FALSE(assertion_result). @@ -151,14 +158,18 @@ class GTEST_API_ AssertionResult { // The second parameter prevents this overload from being considered if // the argument is implicitly convertible to AssertionResult. In that case // we want AssertionResult's copy constructor to be used. - template - explicit AssertionResult( - const T& success, - typename std::enable_if< - !std::is_convertible::value>::type* - /*enabler*/ - = nullptr) - : success_(success) {} + template && + !std::is_trivially_constructible_v, + int> = 0> + explicit AssertionResult(T&& success) : success_(std::forward(success)) {} + + // Similar to the mutable overload, but for cases where mutability is + // unnecessary or problematic (e.g., bitfields). + template , + int> = 0> + explicit AssertionResult(const T& success) : success_(success) {} #if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920) GTEST_DISABLE_MSC_WARNINGS_POP_() @@ -220,6 +231,24 @@ class GTEST_API_ AssertionResult { std::unique_ptr< ::std::string> message_; }; +namespace internal { + +// A pair containing the result that an assertion is evaluating, and the +// expected result (true, false). +// +// Contains a conversion operator that indicates whether the two match. +struct AssertionResultExpectation { + testing::AssertionResult assertion_result; + bool expected_result; + + explicit operator bool() const { + bool converted(assertion_result); + return converted == expected_result; + } +}; + +} // namespace internal + // Makes a successful assertion result. GTEST_API_ AssertionResult AssertionSuccess(); diff --git a/Tests/GoogleTest/include/gtest/gtest-death-test.h b/Tests/GoogleTest/include/gtest/gtest-death-test.h index 3c61909..afd7b3a 100644 --- a/Tests/GoogleTest/include/gtest/gtest-death-test.h +++ b/Tests/GoogleTest/include/gtest/gtest-death-test.h @@ -192,7 +192,7 @@ GTEST_API_ bool InDeathTestChild(); // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*: // Tests that an exit code describes a normal exit with a given exit code. -class GTEST_API_ ExitedWithCode { +class GTEST_API_ [[nodiscard]] ExitedWithCode { public: explicit ExitedWithCode(int exit_code); ExitedWithCode(const ExitedWithCode&) = default; @@ -206,7 +206,7 @@ class GTEST_API_ ExitedWithCode { #if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA) // Tests that an exit code describes an exit due to termination by a // given signal. -class GTEST_API_ KilledBySignal { +class GTEST_API_ [[nodiscard]] KilledBySignal { public: explicit KilledBySignal(int signum); bool operator()(int exit_status) const; @@ -317,7 +317,7 @@ class GTEST_API_ KilledBySignal { GTEST_LOG_(WARNING) << "Death tests are not supported on this platform.\n" \ << "Statement '" #statement "' cannot be verified."; \ } else if (::testing::internal::AlwaysFalse()) { \ - ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ + (void)::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ terminator; \ } else \ diff --git a/Tests/GoogleTest/include/gtest/gtest-matchers.h b/Tests/GoogleTest/include/gtest/gtest-matchers.h index eae210e..b595042 100644 --- a/Tests/GoogleTest/include/gtest/gtest-matchers.h +++ b/Tests/GoogleTest/include/gtest/gtest-matchers.h @@ -40,10 +40,12 @@ #define GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_ #include +#include #include #include #include #include +#include #include #include "gtest/gtest-printers.h" @@ -67,15 +69,15 @@ namespace testing { // To implement a matcher Foo for type T, define: // 1. a class FooMatcherMatcher that implements the matcher interface: // using is_gtest_matcher = void; -// bool MatchAndExplain(const T&, std::ostream*); +// bool MatchAndExplain(const T&, std::ostream*) const; // (MatchResultListener* can also be used instead of std::ostream*) -// void DescribeTo(std::ostream*); -// void DescribeNegationTo(std::ostream*); +// void DescribeTo(std::ostream*) const; +// void DescribeNegationTo(std::ostream*) const; // // 2. a factory function that creates a Matcher object from a // FooMatcherMatcher. -class MatchResultListener { +class [[nodiscard]] MatchResultListener { public: // Creates a listener object with the given underlying ostream. The // listener does not own the ostream, and does not dereference it @@ -111,7 +113,7 @@ inline MatchResultListener::~MatchResultListener() = default; // An instance of a subclass of this knows how to describe itself as a // matcher. -class GTEST_API_ MatcherDescriberInterface { +class GTEST_API_ [[nodiscard]] MatcherDescriberInterface { public: virtual ~MatcherDescriberInterface() = default; @@ -137,7 +139,7 @@ class GTEST_API_ MatcherDescriberInterface { // The implementation of a matcher. template -class MatcherInterface : public MatcherDescriberInterface { +class [[nodiscard]] MatcherInterface : public MatcherDescriberInterface { public: // Returns true if and only if the matcher matches x; also explains the // match result to 'listener' if necessary (see the next paragraph), in @@ -180,7 +182,7 @@ class MatcherInterface : public MatcherDescriberInterface { namespace internal { // A match result listener that ignores the explanation. -class DummyMatchResultListener : public MatchResultListener { +class [[nodiscard]] DummyMatchResultListener : public MatchResultListener { public: DummyMatchResultListener() : MatchResultListener(nullptr) {} @@ -192,7 +194,7 @@ class DummyMatchResultListener : public MatchResultListener { // A match result listener that forwards the explanation to a given // ostream. The difference between this and MatchResultListener is // that the former is concrete. -class StreamMatchResultListener : public MatchResultListener { +class [[nodiscard]] StreamMatchResultListener : public MatchResultListener { public: explicit StreamMatchResultListener(::std::ostream* os) : MatchResultListener(os) {} @@ -225,7 +227,7 @@ struct SharedPayload : SharedPayloadBase { // from it. We put functionalities common to all Matcher // specializations here to avoid code duplication. template -class MatcherBase : private MatcherDescriberInterface { +class [[nodiscard]] MatcherBase : private MatcherDescriberInterface { public: // Returns true if and only if the matcher matches x; also explains the // match result to 'listener'. @@ -276,8 +278,8 @@ class MatcherBase : private MatcherDescriberInterface { Init(impl); } - template ::type::is_gtest_matcher> + template ::is_gtest_matcher> MatcherBase(M&& m) : vtable_(nullptr), buffer_() { // NOLINT Init(std::forward(m)); } @@ -296,12 +298,12 @@ class MatcherBase : private MatcherDescriberInterface { return *this; } - MatcherBase(MatcherBase&& other) + MatcherBase(MatcherBase&& other) noexcept : vtable_(other.vtable_), buffer_(other.buffer_) { other.vtable_ = nullptr; } - MatcherBase& operator=(MatcherBase&& other) { + MatcherBase& operator=(MatcherBase&& other) noexcept { if (this == &other) return *this; Destroy(); vtable_ = other.vtable_; @@ -362,11 +364,10 @@ class MatcherBase : private MatcherDescriberInterface { // from the impl, but some users really want to get their impl back when // they call GetDescriber(). // We use std::get on a tuple as a workaround of not having `if constexpr`. - return std::get<( - std::is_convertible::value - ? 1 - : 0)>(std::make_tuple(&m, &P::Get(m))); + return std::get<(std::is_convertible_v + ? 1 + : 0)>(std::make_tuple(&m, &P::Get(m))); } template @@ -395,8 +396,8 @@ class MatcherBase : private MatcherDescriberInterface { template static constexpr bool IsInlined() { return sizeof(M) <= sizeof(Buffer) && alignof(M) <= alignof(Buffer) && - std::is_trivially_copy_constructible::value && - std::is_trivially_destructible::value; + std::is_trivially_copy_constructible_v && + std::is_trivially_destructible_v; } template ()> @@ -443,7 +444,7 @@ class MatcherBase : private MatcherDescriberInterface { template void Init(M&& m) { - using MM = typename std::decay::type; + using MM = std::decay_t; using Policy = ValuePolicy; vtable_ = GetVTable(); Policy::Init(*this, std::forward(m)); @@ -460,7 +461,7 @@ class MatcherBase : private MatcherDescriberInterface { // implementation of Matcher is just a std::shared_ptr to const // MatcherInterface. Don't inherit from Matcher! template -class Matcher : public internal::MatcherBase { +class [[nodiscard]] Matcher : public internal::MatcherBase { public: // Constructs a null matcher. Needed for storing Matcher objects in STL // containers. A default-constructed matcher is not yet initialized. You @@ -472,35 +473,42 @@ class Matcher : public internal::MatcherBase { : internal::MatcherBase(impl) {} template - explicit Matcher( - const MatcherInterface* impl, - typename std::enable_if::value>::type* = - nullptr) + explicit Matcher(const MatcherInterface* impl, + std::enable_if_t>* = nullptr) : internal::MatcherBase(impl) {} - template ::type::is_gtest_matcher> + template ::is_gtest_matcher> Matcher(M&& m) : internal::MatcherBase(std::forward(m)) {} // NOLINT // Implicit constructor here allows people to write // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes Matcher(T value); // NOLINT + + // Implicit constructor here allows people to write + // EXPECT_THAT(foo, nullptr) instead of EXPECT_THAT(foo, IsNull()) for smart + // pointer types. + // + // The second argument is needed to avoid capturing literal '0'. + template + Matcher(U, // NOLINT + std::enable_if_t>* = nullptr); }; // The following two specializations allow the user to write str // instead of Eq(str) and "foo" instead of Eq("foo") when a std::string // matcher is expected. template <> -class GTEST_API_ Matcher - : public internal::MatcherBase { +class GTEST_API_ [[nodiscard]] +Matcher : public internal::MatcherBase { public: Matcher() = default; explicit Matcher(const MatcherInterface* impl) : internal::MatcherBase(impl) {} - template ::type::is_gtest_matcher> + template ::is_gtest_matcher> Matcher(M&& m) // NOLINT : internal::MatcherBase(std::forward(m)) {} @@ -513,8 +521,8 @@ class GTEST_API_ Matcher }; template <> -class GTEST_API_ Matcher - : public internal::MatcherBase { +class GTEST_API_ [[nodiscard]] +Matcher : public internal::MatcherBase { public: Matcher() = default; @@ -523,8 +531,8 @@ class GTEST_API_ Matcher explicit Matcher(const MatcherInterface* impl) : internal::MatcherBase(impl) {} - template ::type::is_gtest_matcher> + template ::is_gtest_matcher> Matcher(M&& m) // NOLINT : internal::MatcherBase(std::forward(m)) {} @@ -536,12 +544,11 @@ class GTEST_API_ Matcher Matcher(const char* s); // NOLINT }; -#if GTEST_INTERNAL_HAS_STRING_VIEW // The following two specializations allow the user to write str -// instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view +// instead of Eq(str) and "foo" instead of Eq("foo") when a std::string_view // matcher is expected. template <> -class GTEST_API_ Matcher +class GTEST_API_ [[nodiscard]] Matcher : public internal::MatcherBase { public: Matcher() = default; @@ -549,8 +556,8 @@ class GTEST_API_ Matcher explicit Matcher(const MatcherInterface* impl) : internal::MatcherBase(impl) {} - template ::type::is_gtest_matcher> + template ::is_gtest_matcher> Matcher(M&& m) // NOLINT : internal::MatcherBase(std::forward(m)) { } @@ -562,12 +569,12 @@ class GTEST_API_ Matcher // Allows the user to write "foo" instead of Eq("foo") sometimes. Matcher(const char* s); // NOLINT - // Allows the user to pass absl::string_views or std::string_views directly. + // Allows the user to pass std::string_views directly. Matcher(internal::StringView s); // NOLINT }; template <> -class GTEST_API_ Matcher +class GTEST_API_ [[nodiscard]] Matcher : public internal::MatcherBase { public: Matcher() = default; @@ -577,8 +584,8 @@ class GTEST_API_ Matcher explicit Matcher(const MatcherInterface* impl) : internal::MatcherBase(impl) {} - template ::type::is_gtest_matcher> + template ::is_gtest_matcher> Matcher(M&& m) // NOLINT : internal::MatcherBase(std::forward(m)) {} @@ -589,10 +596,9 @@ class GTEST_API_ Matcher // Allows the user to write "foo" instead of Eq("foo") sometimes. Matcher(const char* s); // NOLINT - // Allows the user to pass absl::string_views or std::string_views directly. + // Allows the user to pass std::string_views directly. Matcher(internal::StringView s); // NOLINT }; -#endif // GTEST_INTERNAL_HAS_STRING_VIEW // Prints a matcher in a human-readable format. template @@ -614,7 +620,7 @@ std::ostream& operator<<(std::ostream& os, const Matcher& matcher) { // // See the definition of NotNull() for a complete example. template -class PolymorphicMatcher { +class [[nodiscard]] PolymorphicMatcher { public: explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {} @@ -689,7 +695,7 @@ namespace internal { // The following template definition assumes that the Rhs parameter is // a "bare" type (i.e. neither 'const T' nor 'T&'). template -class ComparisonBase { +class [[nodiscard]] ComparisonBase { public: explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {} @@ -722,7 +728,8 @@ class ComparisonBase { }; template -class EqMatcher : public ComparisonBase, Rhs, std::equal_to<>> { +class [[nodiscard]] EqMatcher + : public ComparisonBase, Rhs, std::equal_to<>> { public: explicit EqMatcher(const Rhs& rhs) : ComparisonBase, Rhs, std::equal_to<>>(rhs) {} @@ -730,7 +737,7 @@ class EqMatcher : public ComparisonBase, Rhs, std::equal_to<>> { static const char* NegatedDesc() { return "isn't equal to"; } }; template -class NeMatcher +class [[nodiscard]] NeMatcher : public ComparisonBase, Rhs, std::not_equal_to<>> { public: explicit NeMatcher(const Rhs& rhs) @@ -739,7 +746,8 @@ class NeMatcher static const char* NegatedDesc() { return "is equal to"; } }; template -class LtMatcher : public ComparisonBase, Rhs, std::less<>> { +class [[nodiscard]] LtMatcher + : public ComparisonBase, Rhs, std::less<>> { public: explicit LtMatcher(const Rhs& rhs) : ComparisonBase, Rhs, std::less<>>(rhs) {} @@ -747,7 +755,8 @@ class LtMatcher : public ComparisonBase, Rhs, std::less<>> { static const char* NegatedDesc() { return "isn't <"; } }; template -class GtMatcher : public ComparisonBase, Rhs, std::greater<>> { +class [[nodiscard]] GtMatcher + : public ComparisonBase, Rhs, std::greater<>> { public: explicit GtMatcher(const Rhs& rhs) : ComparisonBase, Rhs, std::greater<>>(rhs) {} @@ -755,7 +764,7 @@ class GtMatcher : public ComparisonBase, Rhs, std::greater<>> { static const char* NegatedDesc() { return "isn't >"; } }; template -class LeMatcher +class [[nodiscard]] LeMatcher : public ComparisonBase, Rhs, std::less_equal<>> { public: explicit LeMatcher(const Rhs& rhs) @@ -764,7 +773,7 @@ class LeMatcher static const char* NegatedDesc() { return "isn't <="; } }; template -class GeMatcher +class [[nodiscard]] GeMatcher : public ComparisonBase, Rhs, std::greater_equal<>> { public: explicit GeMatcher(const Rhs& rhs) @@ -773,24 +782,68 @@ class GeMatcher static const char* NegatedDesc() { return "isn't >="; } }; -template ::value>::type> -using StringLike = T; +// Same as `EqMatcher`, except that the `rhs` is stored as `StoredRhs` and +// must be implicitly convertible to `Rhs`. +template +class [[nodiscard]] ImplicitCastEqMatcher { + public: + explicit ImplicitCastEqMatcher(const StoredRhs& rhs) : stored_rhs_(rhs) {} + + using is_gtest_matcher = void; + + template + bool MatchAndExplain(const Lhs& lhs, std::ostream*) const { + return lhs == rhs(); + } + + void DescribeTo(std::ostream* os) const { + *os << "is equal to "; + UniversalPrint(rhs(), os); + } + void DescribeNegationTo(std::ostream* os) const { + *os << "isn't equal to "; + UniversalPrint(rhs(), os); + } + + private: + Rhs rhs() const { return ImplicitCast_(stored_rhs_); } + + StoredRhs stored_rhs_; +}; + +// Dummy function (never defined) whose return type evaluates to std::string if +// the given type is a string-like type that can be converted to std::string, +// either directly or through an intermediate std::string_view. +template +extern std::enable_if_t, std::string> +ResolveAsString(const void* /* preferred */); + +#if GTEST_HAS_STD_WSTRING +// Same as above, but for std::wstring. In cases where both conversions are +// possible, this overload takes lower priority. +template +extern std::enable_if_t, std::wstring> +ResolveAsString(... /* fallback */); +#endif + +// Evaluates to the std::basic_string type that the given string-like type can +// be converted to. Prefers std::string over std::wstring if both are possible. +// Fails in a SFINAE-friendly way if no conversion was viable. +template +using StringType = decltype(ResolveAsString(nullptr)); // Implements polymorphic matchers MatchesRegex(regex) and // ContainsRegex(regex), which can be used as a Matcher as long as // T can be converted to a string. -class MatchesRegexMatcher { +class [[nodiscard]] MatchesRegexMatcher { public: MatchesRegexMatcher(const RE* regex, bool full_match) : regex_(regex), full_match_(full_match) {} -#if GTEST_INTERNAL_HAS_STRING_VIEW bool MatchAndExplain(const internal::StringView& s, MatchResultListener* listener) const { return MatchAndExplain(std::string(s), listener); } -#endif // GTEST_INTERNAL_HAS_STRING_VIEW // Accepts pointer types, particularly: // const char* @@ -805,7 +858,7 @@ class MatchesRegexMatcher { // Matches anything that can convert to std::string. // // This is a template, not just a plain function with const std::string&, - // because absl::string_view has some interfering non-explicit constructors. + // because std::string_view has some interfering non-explicit constructors. template bool MatchAndExplain(const MatcheeStringType& s, MatchResultListener* /* listener */) const { @@ -838,9 +891,10 @@ inline PolymorphicMatcher MatchesRegex( return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true)); } template -PolymorphicMatcher MatchesRegex( - const internal::StringLike& regex) { - return MatchesRegex(new internal::RE(std::string(regex))); +std::enable_if_t>, + PolymorphicMatcher> +MatchesRegex(const T& regex) { + return MatchesRegex(new internal::RE(internal::StringType(regex))); } // Matches a string that contains regular expression 'regex'. @@ -850,9 +904,10 @@ inline PolymorphicMatcher ContainsRegex( return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false)); } template -PolymorphicMatcher ContainsRegex( - const internal::StringLike& regex) { - return ContainsRegex(new internal::RE(std::string(regex))); +std::enable_if_t>, + PolymorphicMatcher> +ContainsRegex(const T& regex) { + return ContainsRegex(new internal::RE(internal::StringType(regex))); } // Creates a polymorphic matcher that matches anything equal to x. @@ -863,13 +918,21 @@ inline internal::EqMatcher Eq(T x) { return internal::EqMatcher(x); } -// Constructs a Matcher from a 'value' of type T. The constructed +// Constructs a Matcher from a 'value' of type T. The constructed // matcher matches any value that's equal to 'value'. template Matcher::Matcher(T value) { *this = Eq(value); } +// Constructs a Matcher from nullptr. The constructed matcher matches any +// value that is equal to nullptr. +template +template +Matcher::Matcher(U, std::enable_if_t>*) { + *this = Eq(nullptr); +} + // Creates a monomorphic matcher that matches anything with type Lhs // and equal to rhs. A user may need to use this instead of Eq(...) // in order to resolve an overloading ambiguity. diff --git a/Tests/GoogleTest/include/gtest/gtest-message.h b/Tests/GoogleTest/include/gtest/gtest-message.h index 448ac6b..065ed07 100644 --- a/Tests/GoogleTest/include/gtest/gtest-message.h +++ b/Tests/GoogleTest/include/gtest/gtest-message.h @@ -129,7 +129,7 @@ class GTEST_API_ Message { int>::type = 0 #endif // GTEST_HAS_ABSL > - inline Message& operator<<(const T& val) { + Message& operator<<(const T& val) { // Some libraries overload << for STL containers. These // overloads are defined in the global namespace instead of ::std. // @@ -155,7 +155,7 @@ class GTEST_API_ Message { template ::value, // NOLINT int>::type = 0> - inline Message& operator<<(const T& val) { + Message& operator<<(const T& val) { // ::operator<< is needed here for a similar reason as with the non-Abseil // version above using ::operator<<; diff --git a/Tests/GoogleTest/include/gtest/gtest-param-test.h b/Tests/GoogleTest/include/gtest/gtest-param-test.h index 55ee088..9e023f9 100644 --- a/Tests/GoogleTest/include/gtest/gtest-param-test.h +++ b/Tests/GoogleTest/include/gtest/gtest-param-test.h @@ -174,6 +174,7 @@ TEST_P(DerivedTest, DoesBlah) { #endif // 0 +#include #include #include @@ -413,7 +414,8 @@ internal::CartesianProductHolder Combine(const Generator&... g) { // Synopsis: // ConvertGenerator(gen) // - returns a generator producing the same elements as generated by gen, but -// each element is static_cast to type T before being returned +// each T-typed element is static_cast to a type deduced from the interface +// that accepts this generator, and then returned // // It is useful when using the Combine() function to get the generated // parameters in a custom type instead of std::tuple @@ -441,10 +443,65 @@ internal::CartesianProductHolder Combine(const Generator&... g) { // Combine(Values("cat", "dog"), // Values(BLACK, WHITE)))); // -template -internal::ParamConverterGenerator ConvertGenerator( - internal::ParamGenerator gen) { - return internal::ParamConverterGenerator(gen); +template +internal::ParamConverterGenerator ConvertGenerator( + internal::ParamGenerator gen) { + return internal::ParamConverterGenerator(std::move(gen)); +} + +// As above, but takes a callable as a second argument. The callable converts +// the generated parameter to the test fixture's parameter type. This allows you +// to use a parameter type that does not have a converting constructor from the +// generated type. +// +// Example: +// +// This will instantiate tests in test suite AnimalTest each one with +// the parameter values tuple("cat", BLACK), tuple("cat", WHITE), +// tuple("dog", BLACK), and tuple("dog", WHITE): +// +// enum Color { BLACK, GRAY, WHITE }; +// struct ParamType { +// std::string animal; +// Color color; +// }; +// class AnimalTest +// : public testing::TestWithParam {...}; +// +// TEST_P(AnimalTest, AnimalLooksNice) {...} +// +// INSTANTIATE_TEST_SUITE_P( +// AnimalVariations, AnimalTest, +// ConvertGenerator(Combine(Values("cat", "dog"), Values(BLACK, WHITE)), +// [](std::tuple t) { +// return ParamType{.animal = std::get<0>(t), +// .color = std::get<1>(t)}; +// })); +// +template ()))> +internal::ParamConverterGenerator ConvertGenerator(Gen&& gen, + Func&& f) { + return internal::ParamConverterGenerator( + std::forward(gen), std::forward(f)); +} + +// As above, but infers the T from the supplied std::function instead of +// having the caller specify it. +template ()))> +auto ConvertGenerator(Gen&& gen, Func&& f) { + constexpr bool is_single_arg_std_function = + internal::IsSingleArgStdFunction::value; + if constexpr (is_single_arg_std_function) { + return ConvertGenerator< + typename internal::FuncSingleParamType::type>( + std::forward(gen), std::forward(f)); + } else { + static_assert(is_single_arg_std_function, + "The call signature must contain a single argument."); + } } #define TEST_P(test_suite_name, test_name) \ @@ -469,7 +526,7 @@ internal::ParamConverterGenerator ConvertGenerator( ::testing::internal::CodeLocation(__FILE__, __LINE__)); \ return 0; \ } \ - GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static int gtest_registering_dummy_; \ + [[maybe_unused]] static int gtest_registering_dummy_; \ }; \ int GTEST_TEST_CLASS_NAME_(test_suite_name, \ test_name)::gtest_registering_dummy_ = \ @@ -493,39 +550,38 @@ internal::ParamConverterGenerator ConvertGenerator( #define GTEST_GET_FIRST_(first, ...) first #define GTEST_GET_SECOND_(first, second, ...) second -#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \ - static ::testing::internal::ParamGenerator \ - gtest_##prefix##test_suite_name##_EvalGenerator_() { \ - return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \ - } \ - static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \ - const ::testing::TestParamInfo& info) { \ - if (::testing::internal::AlwaysFalse()) { \ - ::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_( \ - __VA_ARGS__, \ - ::testing::internal::DefaultParamName, \ - DUMMY_PARAM_))); \ - auto t = std::make_tuple(__VA_ARGS__); \ - static_assert(std::tuple_size::value <= 2, \ - "Too Many Args!"); \ - } \ - return ((GTEST_EXPAND_(GTEST_GET_SECOND_( \ - __VA_ARGS__, \ - ::testing::internal::DefaultParamName, \ - DUMMY_PARAM_))))(info); \ - } \ - GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static int \ - gtest_##prefix##test_suite_name##_dummy_ = \ - ::testing::UnitTest::GetInstance() \ - ->parameterized_test_registry() \ - .GetTestSuitePatternHolder( \ - GTEST_STRINGIFY_(test_suite_name), \ - ::testing::internal::CodeLocation(__FILE__, __LINE__)) \ - ->AddTestSuiteInstantiation( \ - GTEST_STRINGIFY_(prefix), \ - >est_##prefix##test_suite_name##_EvalGenerator_, \ - >est_##prefix##test_suite_name##_EvalGenerateName_, \ - __FILE__, __LINE__) +#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \ + static ::testing::internal::ParamGenerator \ + gtest_##prefix##test_suite_name##_EvalGenerator_() { \ + return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \ + } \ + static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \ + const ::testing::TestParamInfo& info) { \ + if (::testing::internal::AlwaysFalse()) { \ + ::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_( \ + __VA_ARGS__, \ + ::testing::internal::DefaultParamName, \ + DUMMY_PARAM_))); \ + auto t = std::make_tuple(__VA_ARGS__); \ + static_assert(std::tuple_size::value <= 2, \ + "Too Many Args!"); \ + } \ + return ((GTEST_EXPAND_(GTEST_GET_SECOND_( \ + __VA_ARGS__, \ + ::testing::internal::DefaultParamName, \ + DUMMY_PARAM_))))(info); \ + } \ + [[maybe_unused]] static int gtest_##prefix##test_suite_name##_dummy_ = \ + ::testing::UnitTest::GetInstance() \ + ->parameterized_test_registry() \ + .GetTestSuitePatternHolder( \ + GTEST_STRINGIFY_(test_suite_name), \ + ::testing::internal::CodeLocation(__FILE__, __LINE__)) \ + ->AddTestSuiteInstantiation( \ + GTEST_STRINGIFY_(prefix), \ + >est_##prefix##test_suite_name##_EvalGenerator_, \ + >est_##prefix##test_suite_name##_EvalGenerateName_, __FILE__, \ + __LINE__) // Allow Marking a Parameterized test class as not needing to be instantiated. #define GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(T) \ diff --git a/Tests/GoogleTest/include/gtest/gtest-printers.h b/Tests/GoogleTest/include/gtest/gtest-printers.h index b2822bc..315ce0a 100644 --- a/Tests/GoogleTest/include/gtest/gtest-printers.h +++ b/Tests/GoogleTest/include/gtest/gtest-printers.h @@ -104,15 +104,19 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ +#include #include #include +#include #include // NOLINT #include #include +#include #include #include #include #include +#include #include #ifdef GTEST_HAS_ABSL @@ -126,6 +130,10 @@ #include // NOLINT #endif // GTEST_INTERNAL_HAS_STD_SPAN +#if GTEST_INTERNAL_HAS_COMPARE_LIB +#include // NOLINT +#endif // GTEST_INTERNAL_HAS_COMPARE_LIB + namespace testing { // Definitions in the internal* namespaces are subject to change without notice. @@ -241,8 +249,8 @@ struct StreamPrinter { // ADL (possibly involving implicit conversions). // (Use SFINAE via return type, because it seems GCC < 12 doesn't handle name // lookup properly when we do it in the template parameter list.) - static auto PrintValue(const T& value, - ::std::ostream* os) -> decltype((void)(*os << value)) { + static auto PrintValue(const T& value, ::std::ostream* os) + -> decltype((void)(*os << value)) { // Call streaming operator found by ADL, possibly with implicit conversions // of the arguments. *os << value; @@ -283,11 +291,9 @@ struct ConvertibleToIntegerPrinter { }; struct ConvertibleToStringViewPrinter { -#if GTEST_INTERNAL_HAS_STRING_VIEW static void PrintValue(internal::StringView value, ::std::ostream* os) { internal::UniversalPrint(value, os); } -#endif }; #ifdef GTEST_HAS_ABSL @@ -374,7 +380,7 @@ void PrintWithFallback(const T& value, ::std::ostream* os) { // The default case. template -class FormatForComparison { +class [[nodiscard]] FormatForComparison { public: static ::std::string Format(const ToPrint& value) { return ::testing::PrintToString(value); @@ -383,7 +389,7 @@ class FormatForComparison { // Array. template -class FormatForComparison { +class [[nodiscard]] FormatForComparison { public: static ::std::string Format(const ToPrint* value) { return FormatForComparison::Format(value); @@ -469,7 +475,7 @@ std::string FormatForComparisonFailureMessage(const T1& value, // function template), as we need to partially specialize it for // reference types, which cannot be done with function templates. template -class UniversalPrinter; +class [[nodiscard]] UniversalPrinter; // Prints the given value using the << operator if it has one; // otherwise prints the bytes in it. This is what @@ -517,11 +523,15 @@ GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os); GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os); inline void PrintTo(char16_t c, ::std::ostream* os) { - PrintTo(ImplicitCast_(c), os); + // TODO(b/418738869): Incorrect for values not representing valid codepoints. + // Also see https://github.com/google/googletest/issues/4762. + PrintTo(static_cast(c), os); } #ifdef __cpp_lib_char8_t inline void PrintTo(char8_t c, ::std::ostream* os) { - PrintTo(ImplicitCast_(c), os); + // TODO(b/418738869): Incorrect for values not representing valid codepoints. + // Also see https://github.com/google/googletest/issues/4762. + PrintTo(static_cast(c), os); } #endif @@ -691,46 +701,63 @@ void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) { } } -// Overloads for ::std::string. -GTEST_API_ void PrintStringTo(const ::std::string& s, ::std::ostream* os); +// Overloads for ::std::string and std::string_view +GTEST_API_ void PrintStringTo(std::string_view s, ::std::ostream* os); inline void PrintTo(const ::std::string& s, ::std::ostream* os) { PrintStringTo(s, os); } +inline void PrintTo(std::string_view s, ::std::ostream* os) { + PrintStringTo(s, os); +} -// Overloads for ::std::u8string +// Overloads for ::std::u8string and ::std::u8string_view #ifdef __cpp_lib_char8_t -GTEST_API_ void PrintU8StringTo(const ::std::u8string& s, ::std::ostream* os); +GTEST_API_ void PrintU8StringTo(::std::u8string_view s, ::std::ostream* os); inline void PrintTo(const ::std::u8string& s, ::std::ostream* os) { PrintU8StringTo(s, os); } +inline void PrintTo(::std::u8string_view s, ::std::ostream* os) { + PrintU8StringTo(s, os); +} #endif -// Overloads for ::std::u16string -GTEST_API_ void PrintU16StringTo(const ::std::u16string& s, ::std::ostream* os); +// Overloads for ::std::u16string and ::std::u16string_view +GTEST_API_ void PrintU16StringTo(::std::u16string_view s, ::std::ostream* os); inline void PrintTo(const ::std::u16string& s, ::std::ostream* os) { PrintU16StringTo(s, os); } +inline void PrintTo(::std::u16string_view s, ::std::ostream* os) { + PrintU16StringTo(s, os); +} -// Overloads for ::std::u32string -GTEST_API_ void PrintU32StringTo(const ::std::u32string& s, ::std::ostream* os); +// Overloads for ::std::u32string and ::std::u32string_view +GTEST_API_ void PrintU32StringTo(::std::u32string_view s, ::std::ostream* os); inline void PrintTo(const ::std::u32string& s, ::std::ostream* os) { PrintU32StringTo(s, os); } +inline void PrintTo(::std::u32string_view s, ::std::ostream* os) { + PrintU32StringTo(s, os); +} -// Overloads for ::std::wstring. +// Overloads for ::std::wstring and ::std::wstring_view #if GTEST_HAS_STD_WSTRING -GTEST_API_ void PrintWideStringTo(const ::std::wstring& s, ::std::ostream* os); +GTEST_API_ void PrintWideStringTo(::std::wstring_view s, ::std::ostream* os); inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) { PrintWideStringTo(s, os); } +inline void PrintTo(::std::wstring_view s, ::std::ostream* os) { + PrintWideStringTo(s, os); +} #endif // GTEST_HAS_STD_WSTRING -#if GTEST_INTERNAL_HAS_STRING_VIEW -// Overload for internal::StringView. +// Overload for internal::StringView. Needed for build configurations where +// internal::StringView is an alias for absl::string_view, but absl::string_view +// is a distinct type from std::string_view. +template , int> = 0> inline void PrintTo(internal::StringView sp, ::std::ostream* os) { - PrintTo(::std::string(sp), os); + PrintStringTo(sp, os); } -#endif // GTEST_INTERNAL_HAS_STRING_VIEW inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; } @@ -782,6 +809,41 @@ void PrintTo(const std::shared_ptr& ptr, std::ostream* os) { (PrintSmartPointer)(ptr, os, 0); } +#if GTEST_INTERNAL_HAS_COMPARE_LIB +template +void PrintOrderingHelper(T ordering, std::ostream* os) { + if (ordering == T::less) { + *os << "(less)"; + } else if (ordering == T::greater) { + *os << "(greater)"; + } else if (ordering == T::equivalent) { + *os << "(equivalent)"; + } else { + *os << "(unknown ordering)"; + } +} + +inline void PrintTo(std::strong_ordering ordering, std::ostream* os) { + if (ordering == std::strong_ordering::equal) { + *os << "(equal)"; + } else { + PrintOrderingHelper(ordering, os); + } +} + +inline void PrintTo(std::partial_ordering ordering, std::ostream* os) { + if (ordering == std::partial_ordering::unordered) { + *os << "(unordered)"; + } else { + PrintOrderingHelper(ordering, os); + } +} + +inline void PrintTo(std::weak_ordering ordering, std::ostream* os) { + PrintOrderingHelper(ordering, os); +} +#endif + // Helper function for printing a tuple. T must be instantiated with // a tuple type. template @@ -797,8 +859,8 @@ void PrintTupleTo(const T& t, std::integral_constant, GTEST_INTENTIONAL_CONST_COND_POP_() *os << ", "; } - UniversalPrinter::type>::Print( - std::get(t), os); + UniversalPrinter>::Print(std::get(t), + os); } template @@ -823,7 +885,7 @@ void PrintTo(const ::std::pair& value, ::std::ostream* os) { // Implements printing a non-reference type T by letting the compiler // pick the right overload of PrintTo() for T. template -class UniversalPrinter { +class [[nodiscard]] UniversalPrinter { public: // MSVC warns about adding const to a function type, so we want to // disable the warning. @@ -849,16 +911,13 @@ class UniversalPrinter { // Remove any const-qualifiers before passing a type to UniversalPrinter. template -class UniversalPrinter : public UniversalPrinter {}; - -#if GTEST_INTERNAL_HAS_ANY - -// Printer for std::any / absl::any +class [[nodiscard]] UniversalPrinter : public UniversalPrinter {}; +// Printer for std::any template <> -class UniversalPrinter { +class [[nodiscard]] UniversalPrinter { public: - static void Print(const Any& value, ::std::ostream* os) { + static void Print(const std::any& value, ::std::ostream* os) { if (value.has_value()) { *os << "value of type " << GetTypeName(value); } else { @@ -867,7 +926,7 @@ class UniversalPrinter { } private: - static std::string GetTypeName(const Any& value) { + static std::string GetTypeName(const std::any& value) { #if GTEST_HAS_RTTI return internal::GetTypeName(value.type()); #else @@ -877,67 +936,60 @@ class UniversalPrinter { } }; -#endif // GTEST_INTERNAL_HAS_ANY - -#if GTEST_INTERNAL_HAS_OPTIONAL - -// Printer for std::optional / absl::optional - +// Printer for std::optional template -class UniversalPrinter> { +class [[nodiscard]] UniversalPrinter> { public: - static void Print(const Optional& value, ::std::ostream* os) { - *os << '('; + static void Print(const std::optional& value, ::std::ostream* os) { if (!value) { - *os << "nullopt"; + UniversalPrint(std::nullopt, os); } else { + *os << '('; UniversalPrint(*value, os); + *os << ')'; } - *os << ')'; } }; template <> -class UniversalPrinter { +class [[nodiscard]] UniversalPrinter { public: - static void Print(decltype(Nullopt()), ::std::ostream* os) { - *os << "(nullopt)"; - } + static void Print(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; } }; -#endif // GTEST_INTERNAL_HAS_OPTIONAL - -#if GTEST_INTERNAL_HAS_VARIANT - -// Printer for std::variant / absl::variant +struct UniversalPrinterVisitor { + template + void operator()(const T& arg) const { + *os << "'" << GetTypeName() << "(index = " << index << ")' with value "; + UniversalPrint(arg, os); + } + ::std::ostream* os; + std::size_t index; +}; +// Printer for std::variant template -class UniversalPrinter> { +class [[nodiscard]] UniversalPrinter> { public: - static void Print(const Variant& value, ::std::ostream* os) { - *os << '('; -#ifdef GTEST_HAS_ABSL - absl::visit(Visitor{os, value.index()}, value); -#else - std::visit(Visitor{os, value.index()}, value); -#endif // GTEST_HAS_ABSL - *os << ')'; - } - - private: - struct Visitor { - template - void operator()(const U& u) const { - *os << "'" << GetTypeName() << "(index = " << index - << ")' with value "; - UniversalPrint(u, os); + static void Print(const std::variant& value, ::std::ostream* os) { + if (value.valueless_by_exception()) { + *os << "(valueless)"; + } else { + *os << '('; + std::visit(UniversalPrinterVisitor{os, value.index()}, value); + *os << ')'; } - ::std::ostream* os; - std::size_t index; - }; + } }; -#endif // GTEST_INTERNAL_HAS_VARIANT +// Printer for std::monostate +template <> +class [[nodiscard]] UniversalPrinter { + public: + static void Print(std::monostate, ::std::ostream* os) { + *os << "(monostate)"; + } +}; // UniversalPrintArray(begin, len, os) prints an array of 'len' // elements, starting at address 'begin'. @@ -986,7 +1038,7 @@ GTEST_API_ void UniversalPrintArray(const wchar_t* begin, size_t len, // Implements printing an array type T[N]. template -class UniversalPrinter { +class [[nodiscard]] UniversalPrinter { public: // Prints the given array, omitting some elements when there are too // many. @@ -997,7 +1049,7 @@ class UniversalPrinter { // Implements printing a reference type T&. template -class UniversalPrinter { +class [[nodiscard]] UniversalPrinter { public: // MSVC warns about adding const to a function type, so we want to // disable the warning. @@ -1020,35 +1072,35 @@ class UniversalPrinter { // NUL-terminated string (but not the pointer) is printed. template -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const T& value, ::std::ostream* os) { UniversalPrint(value, os); } }; template -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const T& value, ::std::ostream* os) { UniversalPrint(value, os); } }; template -class UniversalTersePrinter> { +class [[nodiscard]] UniversalTersePrinter> { public: static void Print(std::reference_wrapper value, ::std::ostream* os) { UniversalTersePrinter::Print(value.get(), os); } }; template -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const T (&value)[N], ::std::ostream* os) { UniversalPrinter::Print(value, os); } }; template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const char* str, ::std::ostream* os) { if (str == nullptr) { @@ -1059,12 +1111,12 @@ class UniversalTersePrinter { } }; template <> -class UniversalTersePrinter : public UniversalTersePrinter { -}; +class [[nodiscard]] +UniversalTersePrinter : public UniversalTersePrinter {}; #ifdef __cpp_lib_char8_t template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const char8_t* str, ::std::ostream* os) { if (str == nullptr) { @@ -1075,12 +1127,12 @@ class UniversalTersePrinter { } }; template <> -class UniversalTersePrinter +class [[nodiscard]] UniversalTersePrinter : public UniversalTersePrinter {}; #endif template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const char16_t* str, ::std::ostream* os) { if (str == nullptr) { @@ -1091,11 +1143,11 @@ class UniversalTersePrinter { } }; template <> -class UniversalTersePrinter +class [[nodiscard]] UniversalTersePrinter : public UniversalTersePrinter {}; template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const char32_t* str, ::std::ostream* os) { if (str == nullptr) { @@ -1106,12 +1158,12 @@ class UniversalTersePrinter { } }; template <> -class UniversalTersePrinter +class [[nodiscard]] UniversalTersePrinter : public UniversalTersePrinter {}; #if GTEST_HAS_STD_WSTRING template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const wchar_t* str, ::std::ostream* os) { if (str == nullptr) { @@ -1124,7 +1176,7 @@ class UniversalTersePrinter { #endif template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(wchar_t* str, ::std::ostream* os) { UniversalTersePrinter::Print(str, os); @@ -1173,7 +1225,7 @@ template Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) { Strings result; TersePrintPrefixToStrings( - value, std::integral_constant::value>(), + value, std::integral_constant>(), &result); return result; } diff --git a/Tests/GoogleTest/include/gtest/gtest-spi.h b/Tests/GoogleTest/include/gtest/gtest-spi.h index c0613b6..27c2d66 100644 --- a/Tests/GoogleTest/include/gtest/gtest-spi.h +++ b/Tests/GoogleTest/include/gtest/gtest-spi.h @@ -51,7 +51,7 @@ namespace testing { // generated in the same thread that created this object or it can intercept // all generated failures. The scope of this mock object can be controlled with // the second argument to the two arguments constructor. -class GTEST_API_ ScopedFakeTestPartResultReporter +class GTEST_API_ [[nodiscard]] ScopedFakeTestPartResultReporter : public TestPartResultReporterInterface { public: // The two possible mocking modes of this object. @@ -100,7 +100,7 @@ namespace internal { // TestPartResultArray contains exactly one failure that has the given // type and contains the given substring. If that's not the case, a // non-fatal failure will be generated. -class GTEST_API_ SingleFailureChecker { +class GTEST_API_ [[nodiscard]] SingleFailureChecker { public: // The constructor remembers the arguments. SingleFailureChecker(const TestPartResultArray* results, diff --git a/Tests/GoogleTest/include/gtest/gtest-test-part.h b/Tests/GoogleTest/include/gtest/gtest-test-part.h index 41c8a9a..ce1e219 100644 --- a/Tests/GoogleTest/include/gtest/gtest-test-part.h +++ b/Tests/GoogleTest/include/gtest/gtest-test-part.h @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "gtest/internal/gtest-internal.h" @@ -51,7 +52,7 @@ namespace testing { // assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()). // // Don't inherit from TestPartResult as its destructor is not virtual. -class GTEST_API_ TestPartResult { +class GTEST_API_ [[nodiscard]] TestPartResult { public: // The possible outcomes of a test part (i.e. an assertion or an // explicit SUCCEED(), FAIL(), or ADD_FAILURE()). @@ -65,10 +66,10 @@ class GTEST_API_ TestPartResult { // C'tor. TestPartResult does NOT have a default constructor. // Always use this constructor (with parameters) to create a // TestPartResult object. - TestPartResult(Type a_type, const char* a_file_name, int a_line_number, - const char* a_message) + TestPartResult(Type a_type, std::string_view a_file_name, int a_line_number, + std::string_view a_message) : type_(a_type), - file_name_(a_file_name == nullptr ? "" : a_file_name), + file_name_(a_file_name), line_number_(a_line_number), summary_(ExtractSummary(a_message)), message_(a_message) {} @@ -112,7 +113,7 @@ class GTEST_API_ TestPartResult { // Gets the summary of the failure message by omitting the stack // trace in it. - static std::string ExtractSummary(const char* message); + static std::string ExtractSummary(std::string_view message); // The name of the source file where the test part took place, or // "" if the source file is unknown. @@ -131,7 +132,7 @@ std::ostream& operator<<(std::ostream& os, const TestPartResult& result); // // Don't inherit from TestPartResultArray as its destructor is not // virtual. -class GTEST_API_ TestPartResultArray { +class GTEST_API_ [[nodiscard]] TestPartResultArray { public: TestPartResultArray() = default; @@ -152,7 +153,7 @@ class GTEST_API_ TestPartResultArray { }; // This interface knows how to report a test part result. -class GTEST_API_ TestPartResultReporterInterface { +class GTEST_API_ [[nodiscard]] TestPartResultReporterInterface { public: virtual ~TestPartResultReporterInterface() = default; @@ -167,7 +168,7 @@ namespace internal { // reported, it only delegates the reporting to the former result reporter. // The original result reporter is restored in the destructor. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. -class GTEST_API_ HasNewFatalFailureHelper +class GTEST_API_ [[nodiscard]] HasNewFatalFailureHelper : public TestPartResultReporterInterface { public: HasNewFatalFailureHelper(); diff --git a/Tests/GoogleTest/include/gtest/gtest-typed-test.h b/Tests/GoogleTest/include/gtest/gtest-typed-test.h index 305b0b5..8575a41 100644 --- a/Tests/GoogleTest/include/gtest/gtest-typed-test.h +++ b/Tests/GoogleTest/include/gtest/gtest-typed-test.h @@ -45,18 +45,18 @@ // First, define a fixture class template. It should be parameterized // by a type. Remember to derive it from testing::Test. template -class FooTest : public testing::Test { +class [[nodiscard]] FooTest : public testing::Test { public: ... - typedef std::list List; + using List = ::std::list; static T shared_; T value_; }; // Next, associate a list of types with the test suite, which will be -// repeated for each type in the list. The typedef is necessary for +// repeated for each type in the list. The using-declaration is necessary for // the macro to parse correctly. -typedef testing::Types MyTypes; +using MyTypes = ::testing::Types; TYPED_TEST_SUITE(FooTest, MyTypes); // If the type list contains only one type, you can write that type @@ -123,7 +123,7 @@ TYPED_TEST(FooTest, HasPropertyA) { ... } // First, define a fixture class template. It should be parameterized // by a type. Remember to derive it from testing::Test. template -class FooTest : public testing::Test { +class [[nodiscard]] FooTest : public testing::Test { ... }; @@ -157,7 +157,7 @@ REGISTER_TYPED_TEST_SUITE_P(FooTest, // argument to the INSTANTIATE_* macro is a prefix that will be added // to the actual test suite name. Remember to pick unique prefixes for // different instances. -typedef testing::Types MyTypes; +using MyTypes = ::testing::Types; INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); // If the type list contains only one type, you can write that type @@ -194,34 +194,33 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \ GTEST_NAME_GENERATOR_(CaseName) -#define TYPED_TEST(CaseName, TestName) \ - static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1, \ - "test-name must not be empty"); \ - template \ - class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \ - : public CaseName { \ - private: \ - typedef CaseName TestFixture; \ - typedef gtest_TypeParam_ TypeParam; \ - void TestBody() override; \ - }; \ - GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool \ - gtest_##CaseName##_##TestName##_registered_ = \ - ::testing::internal::TypeParameterizedTest< \ - CaseName, \ - ::testing::internal::TemplateSel, \ - GTEST_TYPE_PARAMS_( \ - CaseName)>::Register("", \ - ::testing::internal::CodeLocation( \ - __FILE__, __LINE__), \ - GTEST_STRINGIFY_(CaseName), \ - GTEST_STRINGIFY_(TestName), 0, \ - ::testing::internal::GenerateNames< \ - GTEST_NAME_GENERATOR_(CaseName), \ - GTEST_TYPE_PARAMS_(CaseName)>()); \ - template \ - void GTEST_TEST_CLASS_NAME_(CaseName, \ +#define TYPED_TEST(CaseName, TestName) \ + static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1, \ + "test-name must not be empty"); \ + template \ + class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \ + : public CaseName { \ + private: \ + typedef CaseName TestFixture; \ + typedef gtest_TypeParam_ TypeParam; \ + void TestBody() override; \ + }; \ + [[maybe_unused]] static bool gtest_##CaseName##_##TestName##_registered_ = \ + ::testing::internal::TypeParameterizedTest< \ + CaseName, \ + ::testing::internal::TemplateSel, \ + GTEST_TYPE_PARAMS_( \ + CaseName)>::Register("", \ + ::testing::internal::CodeLocation( \ + __FILE__, __LINE__), \ + GTEST_STRINGIFY_(CaseName), \ + GTEST_STRINGIFY_(TestName), 0, \ + ::testing::internal::GenerateNames< \ + GTEST_NAME_GENERATOR_(CaseName), \ + GTEST_TYPE_PARAMS_(CaseName)>()); \ + template \ + void GTEST_TEST_CLASS_NAME_(CaseName, \ TestName)::TestBody() // Legacy API is deprecated but still available @@ -268,23 +267,22 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); TYPED_TEST_SUITE_P #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ -#define TYPED_TEST_P(SuiteName, TestName) \ - namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ - template \ - class TestName : public SuiteName { \ - private: \ - typedef SuiteName TestFixture; \ - typedef gtest_TypeParam_ TypeParam; \ - void TestBody() override; \ - }; \ - GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool \ - gtest_##TestName##_defined_ = \ - GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \ - __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \ - GTEST_STRINGIFY_(TestName)); \ - } \ - template \ - void GTEST_SUITE_NAMESPACE_( \ +#define TYPED_TEST_P(SuiteName, TestName) \ + namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ + template \ + class TestName : public SuiteName { \ + private: \ + typedef SuiteName TestFixture; \ + typedef gtest_TypeParam_ TypeParam; \ + void TestBody() override; \ + }; \ + [[maybe_unused]] static bool gtest_##TestName##_defined_ = \ + GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \ + __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \ + GTEST_STRINGIFY_(TestName)); \ + } \ + template \ + void GTEST_SUITE_NAMESPACE_( \ SuiteName)::TestName::TestBody() // Note: this won't work correctly if the trailing arguments are macros. @@ -292,8 +290,8 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \ } \ - GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static const char* const \ - GTEST_REGISTERED_TEST_NAMES_(SuiteName) = \ + [[maybe_unused]] static const char* const GTEST_REGISTERED_TEST_NAMES_( \ + SuiteName) = \ GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \ GTEST_STRINGIFY_(SuiteName), __FILE__, __LINE__, #__VA_ARGS__) @@ -305,24 +303,22 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); REGISTER_TYPED_TEST_SUITE_P #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ -#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \ - static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \ - "test-suit-prefix must not be empty"); \ - GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool \ - gtest_##Prefix##_##SuiteName = \ - ::testing::internal::TypeParameterizedTestSuite< \ - SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \ - ::testing::internal::GenerateTypeList::type>:: \ - Register( \ - GTEST_STRINGIFY_(Prefix), \ - ::testing::internal::CodeLocation(__FILE__, __LINE__), \ - >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \ - GTEST_STRINGIFY_(SuiteName), \ - GTEST_REGISTERED_TEST_NAMES_(SuiteName), \ - ::testing::internal::GenerateNames< \ - ::testing::internal::NameGeneratorSelector< \ - __VA_ARGS__>::type, \ - ::testing::internal::GenerateTypeList::type>()) +#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \ + static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \ + "test-suit-prefix must not be empty"); \ + [[maybe_unused]] static bool gtest_##Prefix##_##SuiteName = \ + ::testing::internal::TypeParameterizedTestSuite< \ + SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \ + ::testing::internal::GenerateTypeList::type>:: \ + Register(GTEST_STRINGIFY_(Prefix), \ + ::testing::internal::CodeLocation(__FILE__, __LINE__), \ + >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \ + GTEST_STRINGIFY_(SuiteName), \ + GTEST_REGISTERED_TEST_NAMES_(SuiteName), \ + ::testing::internal::GenerateNames< \ + ::testing::internal::NameGeneratorSelector< \ + __VA_ARGS__>::type, \ + ::testing::internal::GenerateTypeList::type>()) // Legacy API is deprecated but still available #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ diff --git a/Tests/GoogleTest/include/gtest/gtest.h b/Tests/GoogleTest/include/gtest/gtest.h index c899669..089b10e 100644 --- a/Tests/GoogleTest/include/gtest/gtest.h +++ b/Tests/GoogleTest/include/gtest/gtest.h @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -136,6 +137,10 @@ GTEST_DECLARE_int32_(repeat); // only torn down once, for the last. GTEST_DECLARE_bool_(recreate_environments_when_repeating); +// Together these flags determine which tests are run if the test is sharded. +GTEST_DECLARE_int32_(shard_index); +GTEST_DECLARE_int32_(total_shards); + // This flag controls whether Google Test includes Google Test internal // stack frames in failure stack traces. GTEST_DECLARE_bool_(show_internal_stack_frames); @@ -193,7 +198,7 @@ std::set* GetIgnoredParameterizedTestSuites(); // A base class that prevents subclasses from being copyable. // We do this instead of using '= delete' so as to avoid triggering warnings // inside user code regarding any of our declarations. -class GTestNonCopyable { +class [[nodiscard]] GTestNonCopyable { public: GTestNonCopyable() = default; GTestNonCopyable(const GTestNonCopyable&) = delete; @@ -206,15 +211,15 @@ class GTestNonCopyable { // The friend relationship of some of these classes is cyclic. // If we don't forward declare them the compiler might confuse the classes // in friendship clauses with same named classes on the scope. -class Test; -class TestSuite; +class [[nodiscard]] Test; +class [[nodiscard]] TestSuite; // Old API is still available but deprecated #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ using TestCase = TestSuite; #endif -class TestInfo; -class UnitTest; +class [[nodiscard]] TestInfo; +class [[nodiscard]] UnitTest; // The abstract class that all tests inherit from. // @@ -239,7 +244,7 @@ class UnitTest; // TEST_F(FooTest, Baz) { ... } // // Test is not copyable. -class GTEST_API_ Test { +class GTEST_API_ [[nodiscard]] Test { public: friend class TestInfo; @@ -366,7 +371,7 @@ typedef internal::TimeInMillis TimeInMillis; // output as a key/value string pair. // // Don't inherit from TestProperty as its destructor is not virtual. -class TestProperty { +class [[nodiscard]] TestProperty { public: // C'tor. TestProperty does NOT have a default constructor. // Always use this constructor (with parameters) to create a @@ -396,7 +401,7 @@ class TestProperty { // the Test. // // TestResult is not copyable. -class GTEST_API_ TestResult { +class GTEST_API_ [[nodiscard]] TestResult { public: // Creates an empty TestResult. TestResult(); @@ -530,7 +535,7 @@ class GTEST_API_ TestResult { // The constructor of TestInfo registers itself with the UnitTest // singleton such that the RUN_ALL_TESTS() macro knows which tests to // run. -class GTEST_API_ TestInfo { +class GTEST_API_ [[nodiscard]] TestInfo { public: // Destructs a TestInfo object. This function is not virtual, so // don't inherit from TestInfo. @@ -669,7 +674,7 @@ class GTEST_API_ TestInfo { // A test suite, which consists of a vector of TestInfos. // // TestSuite is not copyable. -class GTEST_API_ TestSuite { +class GTEST_API_ [[nodiscard]] TestSuite { public: // Creates a TestSuite with the given name. // @@ -890,7 +895,7 @@ class GTEST_API_ TestSuite { // available. // 2. You cannot use ASSERT_* directly in a constructor or // destructor. -class Environment { +class [[nodiscard]] Environment { public: // The d'tor is virtual as we need to subclass Environment. virtual ~Environment() = default; @@ -911,7 +916,7 @@ class Environment { #if GTEST_HAS_EXCEPTIONS // Exception which can be thrown from TestEventListener::OnTestPartResult. -class GTEST_API_ AssertionException +class GTEST_API_ [[nodiscard]] AssertionException : public internal::GoogleTestFailureException { public: explicit AssertionException(const TestPartResult& result) @@ -922,7 +927,7 @@ class GTEST_API_ AssertionException // The interface for tracing execution of tests. The methods are organized in // the order the corresponding events are fired. -class TestEventListener { +class [[nodiscard]] TestEventListener { public: virtual ~TestEventListener() = default; @@ -989,7 +994,7 @@ class TestEventListener { // the methods they override will not be caught during the build. For // comments about each method please see the definition of TestEventListener // above. -class EmptyTestEventListener : public TestEventListener { +class [[nodiscard]] EmptyTestEventListener : public TestEventListener { public: void OnTestProgramStart(const UnitTest& /*unit_test*/) override {} void OnTestIterationStart(const UnitTest& /*unit_test*/, @@ -1019,7 +1024,7 @@ class EmptyTestEventListener : public TestEventListener { }; // TestEventListeners lets users add listeners to track events in Google Test. -class GTEST_API_ TestEventListeners { +class GTEST_API_ [[nodiscard]] TestEventListeners { public: TestEventListeners(); ~TestEventListeners(); @@ -1110,7 +1115,7 @@ class GTEST_API_ TestEventListeners { // // This class is thread-safe as long as the methods are called // according to their specification. -class GTEST_API_ UnitTest { +class GTEST_API_ [[nodiscard]] UnitTest { public: // Gets the singleton UnitTest object. The first time this method // is called, a UnitTest object is constructed and returned. @@ -1123,7 +1128,7 @@ class GTEST_API_ UnitTest { // This method can only be called from the main thread. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. - int Run() GTEST_MUST_USE_RESULT_; + [[nodiscard]] int Run(); // Returns the working directory when the first TEST() or TEST_F() // was executed. The UnitTest object owns the string. @@ -1246,7 +1251,7 @@ class GTEST_API_ UnitTest { // eventually call this to report their results. The user code // should use the assertion macros instead of calling this directly. void AddTestPartResult(TestPartResult::Type result_type, - const char* file_name, int line_number, + std::string_view file_name, int line_number, const std::string& message, const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_); @@ -1398,7 +1403,7 @@ AssertionResult CmpHelperEQ(const char* lhs_expression, return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs); } -class EqHelper { +class [[nodiscard]] EqHelper { public: // This templatized version is for the general case. template < @@ -1610,18 +1615,23 @@ GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1, double val1, double val2, double abs_error); +using GoogleTest_NotSupported_OnFunctionReturningNonVoid = void; + // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // A class that enables one to stream messages to assertion macros -class GTEST_API_ AssertHelper { +class GTEST_API_ [[nodiscard]] AssertHelper { public: // Constructor. AssertHelper(TestPartResult::Type type, const char* file, int line, const char* message); + AssertHelper(TestPartResult::Type type, std::string_view file, int line, + std::string_view message); ~AssertHelper(); // Message assignment is a semantic trick to enable assertion // streaming; see the GTEST_MESSAGE_ macro below. - void operator=(const Message& message) const; + GoogleTest_NotSupported_OnFunctionReturningNonVoid operator=( + const Message& message) const; private: // We put our data in a struct so that the size of the AssertHelper class can @@ -1629,12 +1639,12 @@ class GTEST_API_ AssertHelper { // re-using stack space even for temporary variables, so every EXPECT_EQ // reserves stack space for another AssertHelper. struct AssertHelperData { - AssertHelperData(TestPartResult::Type t, const char* srcfile, int line_num, - const char* msg) + AssertHelperData(TestPartResult::Type t, std::string_view srcfile, + int line_num, std::string_view msg) : type(t), file(srcfile), line(line_num), message(msg) {} TestPartResult::Type const type; - const char* const file; + const std::string_view file; int const line; std::string const message; @@ -1686,14 +1696,14 @@ class GTEST_API_ AssertHelper { // INSTANTIATE_TEST_SUITE_P(OneToTenRange, FooTest, ::testing::Range(1, 10)); template -class WithParamInterface { +class [[nodiscard]] WithParamInterface { public: typedef T ParamType; virtual ~WithParamInterface() = default; // The current parameter value. Is also available in the test fixture's // constructor. - static const ParamType& GetParam() { + [[nodiscard]] static const ParamType& GetParam() { GTEST_CHECK_(parameter_ != nullptr) << "GetParam() can only be called inside a value-parameterized test " << "-- did you intend to write TEST_P instead of TEST_F?"; @@ -1720,7 +1730,8 @@ const T* WithParamInterface::parameter_ = nullptr; // WithParamInterface, and can just inherit from ::testing::TestWithParam. template -class TestWithParam : public Test, public WithParamInterface {}; +class [[nodiscard]] TestWithParam : public Test, + public WithParamInterface {}; // Macros for indicating success/failure in test code. @@ -1807,14 +1818,13 @@ class TestWithParam : public Test, public WithParamInterface {}; #define GTEST_EXPECT_TRUE(condition) \ GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ GTEST_NONFATAL_FAILURE_) -#define GTEST_EXPECT_FALSE(condition) \ - GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ +#define GTEST_EXPECT_FALSE(condition) \ + GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \ GTEST_NONFATAL_FAILURE_) #define GTEST_ASSERT_TRUE(condition) \ GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_) -#define GTEST_ASSERT_FALSE(condition) \ - GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ - GTEST_FATAL_FAILURE_) +#define GTEST_ASSERT_FALSE(condition) \ + GTEST_TEST_BOOLEAN_(condition, #condition, true, false, GTEST_FATAL_FAILURE_) // Define these macros to 1 to omit the definition of the corresponding // EXPECT or ASSERT, which clashes with some users' own code. @@ -2068,7 +2078,7 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, // Example: // testing::ScopedTrace trace("file.cc", 123, "message"); // -class GTEST_API_ ScopedTrace { +class GTEST_API_ [[nodiscard]] ScopedTrace { public: // The c'tor pushes the given source file location and message onto // a trace stack maintained by Google Test. @@ -2153,7 +2163,7 @@ class GTEST_API_ ScopedTrace { // to cause a compiler error. template constexpr bool StaticAssertTypeEq() noexcept { - static_assert(std::is_same::value, "T1 and T2 are not the same type"); + static_assert(std::is_same_v, "T1 and T2 are not the same type"); return true; } @@ -2299,7 +2309,7 @@ template TestInfo* RegisterTest(const char* test_suite_name, const char* test_name, const char* type_param, const char* value_param, const char* file, int line, Factory factory) { - using TestT = typename std::remove_pointer::type; + using TestT = std::remove_pointer_t; class FactoryImpl : public internal::TestFactoryBase { public: @@ -2329,7 +2339,7 @@ TestInfo* RegisterTest(const char* test_suite_name, const char* test_name, // // This function was formerly a macro; thus, it is in the global // namespace and has an all-caps name. -int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_; +[[nodiscard]] int RUN_ALL_TESTS(); inline int RUN_ALL_TESTS() { return ::testing::UnitTest::GetInstance()->Run(); } diff --git a/Tests/GoogleTest/include/gtest/internal/gtest-death-test-internal.h b/Tests/GoogleTest/include/gtest/internal/gtest-death-test-internal.h index b363259..f0f93e5 100644 --- a/Tests/GoogleTest/include/gtest/internal/gtest-death-test-internal.h +++ b/Tests/GoogleTest/include/gtest/internal/gtest-death-test-internal.h @@ -43,6 +43,7 @@ #include #include +#include #include "gtest/gtest-matchers.h" #include "gtest/internal/gtest-internal.h" @@ -63,6 +64,10 @@ inline Matcher MakeDeathTestMatcher( ::testing::internal::RE regex) { return ContainsRegex(regex.pattern()); } +inline Matcher MakeDeathTestMatcher( + std::string_view regex) { + return ContainsRegex(regex); +} inline Matcher MakeDeathTestMatcher(const char* regex) { return ContainsRegex(regex); } @@ -96,7 +101,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ // by wait(2) // exit code: The integer code passed to exit(3), _Exit(2), or // returned from main() -class GTEST_API_ DeathTest { +class GTEST_API_ [[nodiscard]] DeathTest { public: // Create returns false if there was an error determining the // appropriate action to take for the current death test; for example, @@ -172,7 +177,7 @@ class GTEST_API_ DeathTest { GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 // Factory interface for death tests. May be mocked out for testing. -class DeathTestFactory { +class [[nodiscard]] DeathTestFactory { public: virtual ~DeathTestFactory() = default; virtual bool Create(const char* statement, @@ -181,7 +186,7 @@ class DeathTestFactory { }; // A concrete DeathTestFactory implementation for normal use. -class DefaultDeathTestFactory : public DeathTestFactory { +class [[nodiscard]] DefaultDeathTestFactory : public DeathTestFactory { public: bool Create(const char* statement, Matcher matcher, const char* file, int line, DeathTest** test) override; @@ -229,7 +234,8 @@ GTEST_API_ bool ExitedUnsuccessfully(int exit_status); goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \ } \ if (gtest_dt != nullptr) { \ - std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr(gtest_dt); \ + const std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr( \ + gtest_dt); \ switch (gtest_dt->AssumeRole()) { \ case ::testing::internal::DeathTest::OVERSEE_TEST: \ if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \ @@ -256,19 +262,19 @@ GTEST_API_ bool ExitedUnsuccessfully(int exit_status); // must accept a streamed message even though the message is never printed. // The regex object is not evaluated, but it is used to prevent "unused" // warnings and to avoid an expression that doesn't compile in debug mode. -#define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::AlwaysTrue()) { \ - GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ - } else if (!::testing::internal::AlwaysTrue()) { \ - ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ - } else \ +#define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } else if (!::testing::internal::AlwaysTrue()) { \ + (void)::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ + } else \ ::testing::Message() // A class representing the parsed contents of the // --gtest_internal_run_death_test flag, as it existed when // RUN_ALL_TESTS was called. -class InternalRunDeathTestFlag { +class [[nodiscard]] InternalRunDeathTestFlag { public: InternalRunDeathTestFlag(const std::string& a_file, int a_line, int an_index, int a_write_fd) diff --git a/Tests/GoogleTest/include/gtest/internal/gtest-filepath.h b/Tests/GoogleTest/include/gtest/internal/gtest-filepath.h index 6dc47be..4dc00ee 100644 --- a/Tests/GoogleTest/include/gtest/internal/gtest-filepath.h +++ b/Tests/GoogleTest/include/gtest/internal/gtest-filepath.h @@ -67,7 +67,7 @@ namespace internal { // Names are NOT checked for syntax correctness -- no checking for illegal // characters, malformed paths, etc. -class GTEST_API_ FilePath { +class GTEST_API_ [[nodiscard]] FilePath { public: FilePath() : pathname_("") {} FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {} diff --git a/Tests/GoogleTest/include/gtest/internal/gtest-internal.h b/Tests/GoogleTest/include/gtest/internal/gtest-internal.h index 7e55dc6..55e9966 100644 --- a/Tests/GoogleTest/include/gtest/internal/gtest-internal.h +++ b/Tests/GoogleTest/include/gtest/internal/gtest-internal.h @@ -95,7 +95,13 @@ #define GTEST_STRINGIFY_(...) GTEST_STRINGIFY_HELPER_(__VA_ARGS__, ) namespace proto2 { -class MessageLite; +class [[nodiscard]] MessageLite; + +// Dummy forward declaration of `DynamicCastMessage`. Does not match any actual +// overloads of `DynamicCastMessage`, but can be used to assist name resolution +// in templates. +template +T DynamicCastMessage() = delete; } namespace testing { @@ -115,15 +121,15 @@ ::std::string PrintToString(const T& value); namespace internal { struct TraceInfo; // Information about a trace point. -class TestInfoImpl; // Opaque implementation of TestInfo -class UnitTestImpl; // Opaque implementation of UnitTest +class [[nodiscard]] TestInfoImpl; // Opaque implementation of TestInfo +class [[nodiscard]] UnitTestImpl; // Opaque implementation of UnitTest // The text used in failure messages to indicate the start of the // stack trace. GTEST_API_ extern const char kStackTraceMarker[]; // An IgnoredValue object can be implicitly constructed from ANY value. -class IgnoredValue { +class [[nodiscard]] IgnoredValue { struct Sink {}; public: @@ -155,7 +161,8 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_( // errors presumably detectable only at run time. Since // std::runtime_error inherits from std::exception, many testing // frameworks know how to extract and print the message inside it. -class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error { +class GTEST_API_ [[nodiscard]] GoogleTestFailureException + : public ::std::runtime_error { public: explicit GoogleTestFailureException(const TestPartResult& failure); }; @@ -242,7 +249,7 @@ GTEST_API_ std::string GetBoolAssertionFailureMessage( // // RawType: the raw floating-point type (either float or double) template -class FloatingPoint { +class [[nodiscard]] FloatingPoint { public: // Defines the unsigned integer type that has the same size as the // floating point number. @@ -290,17 +297,17 @@ class FloatingPoint { // around may change its bits, although the new value is guaranteed // to be also a NAN. Therefore, don't expect this constructor to // preserve the bits in x when x is a NAN. - explicit FloatingPoint(const RawType& x) { u_.value_ = x; } + explicit FloatingPoint(RawType x) { memcpy(&bits_, &x, sizeof(x)); } // Static methods // Reinterprets a bit pattern as a floating-point number. // // This function is needed to test the AlmostEquals() method. - static RawType ReinterpretBits(const Bits bits) { - FloatingPoint fp(0); - fp.u_.bits_ = bits; - return fp.u_.value_; + static RawType ReinterpretBits(Bits bits) { + RawType fp; + memcpy(&fp, &bits, sizeof(fp)); + return fp; } // Returns the floating-point number that represent positive infinity. @@ -309,16 +316,16 @@ class FloatingPoint { // Non-static methods // Returns the bits that represents this number. - const Bits& bits() const { return u_.bits_; } + const Bits& bits() const { return bits_; } // Returns the exponent bits of this number. - Bits exponent_bits() const { return kExponentBitMask & u_.bits_; } + Bits exponent_bits() const { return kExponentBitMask & bits_; } // Returns the fraction bits of this number. - Bits fraction_bits() const { return kFractionBitMask & u_.bits_; } + Bits fraction_bits() const { return kFractionBitMask & bits_; } // Returns the sign bit of this number. - Bits sign_bit() const { return kSignBitMask & u_.bits_; } + Bits sign_bit() const { return kSignBitMask & bits_; } // Returns true if and only if this is NAN (not a number). bool is_nan() const { @@ -332,23 +339,16 @@ class FloatingPoint { // // - returns false if either number is (or both are) NAN. // - treats really large numbers as almost equal to infinity. - // - thinks +0.0 and -0.0 are 0 DLP's apart. + // - thinks +0.0 and -0.0 are 0 ULP's apart. bool AlmostEquals(const FloatingPoint& rhs) const { // The IEEE standard says that any comparison operation involving // a NAN must return false. if (is_nan() || rhs.is_nan()) return false; - return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_) <= - kMaxUlps; + return DistanceBetweenSignAndMagnitudeNumbers(bits_, rhs.bits_) <= kMaxUlps; } private: - // The data type used to store the actual floating-point number. - union FloatingPointUnion { - RawType value_; // The raw floating-point number. - Bits bits_; // The bits that represent the number. - }; - // Converts an integer from the sign-and-magnitude representation to // the biased representation. More precisely, let N be 2 to the // power of (kBitCount - 1), an integer x is represented by the @@ -364,7 +364,7 @@ class FloatingPoint { // // Read https://en.wikipedia.org/wiki/Signed_number_representations // for more details on signed number representations. - static Bits SignAndMagnitudeToBiased(const Bits& sam) { + static Bits SignAndMagnitudeToBiased(Bits sam) { if (kSignBitMask & sam) { // sam represents a negative number. return ~sam + 1; @@ -376,14 +376,13 @@ class FloatingPoint { // Given two numbers in the sign-and-magnitude representation, // returns the distance between them as an unsigned number. - static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits& sam1, - const Bits& sam2) { + static Bits DistanceBetweenSignAndMagnitudeNumbers(Bits sam1, Bits sam2) { const Bits biased1 = SignAndMagnitudeToBiased(sam1); const Bits biased2 = SignAndMagnitudeToBiased(sam2); return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1); } - FloatingPointUnion u_; + Bits bits_; // The bits that represent the number. }; // Typedefs the instances of the FloatingPoint template class that we @@ -400,7 +399,7 @@ typedef FloatingPoint Double; typedef const void* TypeId; template -class TypeIdHelper { +class [[nodiscard]] TypeIdHelper { public: // dummy_ must not have a const type. Otherwise an overly eager // compiler (e.g. MSVC 7.1 & 8.0) may try to merge @@ -432,7 +431,7 @@ GTEST_API_ TypeId GetTestTypeId(); // Defines the abstract factory interface that creates instances // of a Test object. -class TestFactoryBase { +class [[nodiscard]] TestFactoryBase { public: virtual ~TestFactoryBase() = default; @@ -451,7 +450,7 @@ class TestFactoryBase { // This class provides implementation of TestFactoryBase interface. // It is used in TEST and TEST_F macros. template -class TestFactoryImpl : public TestFactoryBase { +class [[nodiscard]] TestFactoryImpl : public TestFactoryBase { public: Test* CreateTest() override { return new TestClass; } }; @@ -578,7 +577,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ /* class A needs to have dll-interface to be used by clients of class B */) // State of the definition of a type-parameterized test suite. -class GTEST_API_ TypedTestSuitePState { +class GTEST_API_ [[nodiscard]] TypedTestSuitePState { public: TypedTestSuitePState() : registered_(false) {} @@ -693,7 +692,7 @@ std::vector GenerateNames() { // Implementation note: The GTEST_TEMPLATE_ macro declares a template // template parameter. It's defined in gtest-type-util.h. template -class TypeParameterizedTest { +class [[nodiscard]] TypeParameterizedTest { public: // 'index' is the index of the test in the type list 'Types' // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite, @@ -731,7 +730,7 @@ class TypeParameterizedTest { // The base case for the compile time recursion. template -class TypeParameterizedTest { +class [[nodiscard]] TypeParameterizedTest { public: static bool Register(const char* /*prefix*/, CodeLocation, const char* /*case_name*/, const char* /*test_names*/, @@ -752,7 +751,7 @@ GTEST_API_ void RegisterTypeParameterizedTestSuiteInstantiation( // Test. The return value is insignificant - we just need to return // something such that we can call this function in a namespace scope. template -class TypeParameterizedTestSuite { +class [[nodiscard]] TypeParameterizedTestSuite { public: static bool Register(const char* prefix, CodeLocation code_location, const TypedTestSuitePState* state, const char* case_name, @@ -790,7 +789,7 @@ class TypeParameterizedTestSuite { // The base case for the compile time recursion. template -class TypeParameterizedTestSuite { +class [[nodiscard]] TypeParameterizedTestSuite { public: static bool Register(const char* /*prefix*/, const CodeLocation&, const TypedTestSuitePState* /*state*/, @@ -846,7 +845,7 @@ struct TrueWithString { // doesn't use global state (and therefore can't interfere with user // code). Unlike rand_r(), it's portable. An LCG isn't very random, // but it's good enough for our purposes. -class GTEST_API_ Random { +class GTEST_API_ [[nodiscard]] Random { public: static const uint32_t kMaxRange = 1u << 31; @@ -872,7 +871,7 @@ class GTEST_API_ Random { // that's true if and only if T has methods DebugString() and ShortDebugString() // that return std::string. template -class HasDebugStringAndShortDebugString { +class [[nodiscard]] HasDebugStringAndShortDebugString { private: template static auto CheckDebugString(C*) -> typename std::is_same< @@ -894,11 +893,6 @@ class HasDebugStringAndShortDebugString { HasDebugStringType::value && HasShortDebugStringType::value; }; -#ifdef GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL -template -constexpr bool HasDebugStringAndShortDebugString::value; -#endif - // When the compiler sees expression IsContainerTest(0), if C is an // STL-style container class, the first overload of IsContainerTest // will be viable (since both C::iterator* and C::const_iterator* are @@ -1077,7 +1071,7 @@ struct RelationToSourceCopy {}; // this requirement. Element can be an array type itself (hence // multi-dimensional arrays are supported). template -class NativeArray { +class [[nodiscard]] NativeArray { public: // STL-style container typedefs. typedef Element value_type; @@ -1163,7 +1157,7 @@ struct ElemFromList { struct FlatTupleConstructTag {}; template -class FlatTuple; +class [[nodiscard]] FlatTuple; template struct FlatTupleElemBase; @@ -1222,7 +1216,7 @@ struct FlatTupleBase, std::index_sequence> // std::make_index_sequence, on the other hand, it is recursive but with an // instantiation depth of O(ln(N)). template -class FlatTuple +class [[nodiscard]] FlatTuple : private FlatTupleBase, std::make_index_sequence> { using Indices = @@ -1241,30 +1235,40 @@ class FlatTuple // Utility functions to be called with static_assert to induce deprecation // warnings. -GTEST_INTERNAL_DEPRECATED( +[[deprecated( "INSTANTIATE_TEST_CASE_P is deprecated, please use " - "INSTANTIATE_TEST_SUITE_P") -constexpr bool InstantiateTestCase_P_IsDeprecated() { return true; } + "INSTANTIATE_TEST_SUITE_P")]] +constexpr bool InstantiateTestCase_P_IsDeprecated() { + return true; +} -GTEST_INTERNAL_DEPRECATED( +[[deprecated( "TYPED_TEST_CASE_P is deprecated, please use " - "TYPED_TEST_SUITE_P") -constexpr bool TypedTestCase_P_IsDeprecated() { return true; } + "TYPED_TEST_SUITE_P")]] +constexpr bool TypedTestCase_P_IsDeprecated() { + return true; +} -GTEST_INTERNAL_DEPRECATED( +[[deprecated( "TYPED_TEST_CASE is deprecated, please use " - "TYPED_TEST_SUITE") -constexpr bool TypedTestCaseIsDeprecated() { return true; } + "TYPED_TEST_SUITE")]] +constexpr bool TypedTestCaseIsDeprecated() { + return true; +} -GTEST_INTERNAL_DEPRECATED( +[[deprecated( "REGISTER_TYPED_TEST_CASE_P is deprecated, please use " - "REGISTER_TYPED_TEST_SUITE_P") -constexpr bool RegisterTypedTestCase_P_IsDeprecated() { return true; } + "REGISTER_TYPED_TEST_SUITE_P")]] +constexpr bool RegisterTypedTestCase_P_IsDeprecated() { + return true; +} -GTEST_INTERNAL_DEPRECATED( +[[deprecated( "INSTANTIATE_TYPED_TEST_CASE_P is deprecated, please use " - "INSTANTIATE_TYPED_TEST_SUITE_P") -constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; } + "INSTANTIATE_TYPED_TEST_SUITE_P")]] +constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { + return true; +} } // namespace internal } // namespace testing @@ -1320,7 +1324,7 @@ struct tuple_size> namespace testing { namespace internal { -class NeverThrown { +class [[nodiscard]] NeverThrown { public: const char* what() const noexcept { return "this exception should never be thrown"; @@ -1447,15 +1451,14 @@ class NeverThrown { // Implements Boolean test assertions such as EXPECT_TRUE. expression can be // either a boolean expression or an AssertionResult. text is a textual // representation of expression as it was passed into the EXPECT_TRUE. -#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (const ::testing::AssertionResult gtest_ar_ = \ - ::testing::AssertionResult(expression)) \ - ; \ - else \ - fail(::testing::internal::GetBoolAssertionFailureMessage( \ - gtest_ar_, text, #actual, #expected) \ - .c_str()) +#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (const ::testing::internal::AssertionResultExpectation gtest_are_ = { \ + ::testing::AssertionResult(expression), expected}) \ + ; \ + else /* NOLINT */ \ + fail(::testing::internal::GetBoolAssertionFailureMessage( \ + gtest_are_.assertion_result, text, #actual, #expected)) #define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ @@ -1501,8 +1504,7 @@ class NeverThrown { \ private: \ void TestBody() override; \ - GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static ::testing::TestInfo* const \ - test_info_; \ + [[maybe_unused]] static ::testing::TestInfo* const test_info_; \ }; \ \ ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \ diff --git a/Tests/GoogleTest/include/gtest/internal/gtest-param-util.h b/Tests/GoogleTest/include/gtest/internal/gtest-param-util.h index cc7ea53..7167793 100644 --- a/Tests/GoogleTest/include/gtest/internal/gtest-param-util.h +++ b/Tests/GoogleTest/include/gtest/internal/gtest-param-util.h @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -89,14 +90,14 @@ GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name, const CodeLocation& code_location); template -class ParamGeneratorInterface; +class [[nodiscard]] ParamGeneratorInterface; template -class ParamGenerator; +class [[nodiscard]] ParamGenerator; // Interface for iterating over elements provided by an implementation // of ParamGeneratorInterface. template -class ParamIteratorInterface { +class [[nodiscard]] ParamIteratorInterface { public: virtual ~ParamIteratorInterface() = default; // A pointer to the base generator instance. @@ -126,7 +127,7 @@ class ParamIteratorInterface { // ParamGeneratorInterface. It wraps ParamIteratorInterface // and implements the const forward iterator concept. template -class ParamIterator { +class [[nodiscard]] ParamIterator { public: typedef T value_type; typedef const T& reference; @@ -168,7 +169,7 @@ class ParamIterator { // ParamGeneratorInterface is the binary interface to access generators // defined in other translation units. template -class ParamGeneratorInterface { +class [[nodiscard]] ParamGeneratorInterface { public: typedef T ParamType; @@ -185,7 +186,7 @@ class ParamGeneratorInterface { // ParamGeneratorInterface instance is shared among all copies // of the original object. This is possible because that instance is immutable. template -class ParamGenerator { +class [[nodiscard]] ParamGenerator { public: typedef ParamIterator iterator; @@ -209,7 +210,7 @@ class ParamGenerator { // operator<(). // This class is used in the Range() function. template -class RangeGenerator : public ParamGeneratorInterface { +class [[nodiscard]] RangeGenerator : public ParamGeneratorInterface { public: RangeGenerator(T begin, T end, IncrementT step) : begin_(begin), @@ -295,7 +296,8 @@ class RangeGenerator : public ParamGeneratorInterface { // since the source can be located on the stack, and the generator // is likely to persist beyond that stack frame. template -class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface { +class [[nodiscard]] ValuesInIteratorRangeGenerator + : public ParamGeneratorInterface { public: template ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end) @@ -395,7 +397,7 @@ void TestNotEmpty(const T&) {} // Stores a parameter value and later creates tests parameterized with that // value. template -class ParameterizedTestFactory : public TestFactoryBase { +class [[nodiscard]] ParameterizedTestFactory : public TestFactoryBase { public: typedef typename TestClass::ParamType ParamType; explicit ParameterizedTestFactory(ParamType parameter) @@ -417,7 +419,7 @@ class ParameterizedTestFactory : public TestFactoryBase { // TestMetaFactoryBase is a base class for meta-factories that create // test factories for passing into MakeAndRegisterTestInfo function. template -class TestMetaFactoryBase { +class [[nodiscard]] TestMetaFactoryBase { public: virtual ~TestMetaFactoryBase() = default; @@ -433,7 +435,7 @@ class TestMetaFactoryBase { // it for each Test/Parameter value combination. Thus it needs meta factory // creator class. template -class TestMetaFactory +class [[nodiscard]] TestMetaFactory : public TestMetaFactoryBase { public: using ParamType = typename TestSuite::ParamType; @@ -459,7 +461,7 @@ class TestMetaFactory // in RegisterTests method. The ParameterizeTestSuiteRegistry class holds // a collection of pointers to the ParameterizedTestSuiteInfo objects // and calls RegisterTests() on each of them when asked. -class ParameterizedTestSuiteInfoBase { +class [[nodiscard]] ParameterizedTestSuiteInfoBase { public: virtual ~ParameterizedTestSuiteInfoBase() = default; @@ -502,7 +504,8 @@ GTEST_API_ void InsertSyntheticTestCase(const std::string& name, // test suite. It registers tests with all values generated by all // generators when asked. template -class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { +class [[nodiscard]] ParameterizedTestSuiteInfo + : public ParameterizedTestSuiteInfoBase { public: // ParamType and GeneratorCreationFunc are private types but are required // for declarations of public methods AddTestPattern() and @@ -529,8 +532,7 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { // prefix). test_base_name is the name of an individual test without // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is // test suite base name and DoBar is test base name. - void AddTestPattern(const char*, - const char* test_base_name, + void AddTestPattern(const char*, const char* test_base_name, TestMetaFactoryBase* meta_factory, CodeLocation code_location) { tests_.emplace_back( @@ -688,7 +690,7 @@ using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo; // ParameterizedTestSuiteInfoBase classes accessed by test suite names. TEST_P // and INSTANTIATE_TEST_SUITE_P macros use it to locate their corresponding // ParameterizedTestSuiteInfo descriptors. -class ParameterizedTestSuiteRegistry { +class [[nodiscard]] ParameterizedTestSuiteRegistry { public: ParameterizedTestSuiteRegistry() = default; ~ParameterizedTestSuiteRegistry() { @@ -762,7 +764,7 @@ class ParameterizedTestSuiteRegistry { // Keep track of what type-parameterized test suite are defined and // where as well as which are intatiated. This allows susequently // identifying suits that are defined but never used. -class TypeParameterizedTestSuiteRegistry { +class [[nodiscard]] TypeParameterizedTestSuiteRegistry { public: // Add a suite definition void RegisterTestSuite(const char* test_suite_name, @@ -801,7 +803,7 @@ namespace internal { GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100) template -class ValueArray { +class [[nodiscard]] ValueArray { public: explicit ValueArray(Ts... v) : v_(FlatTupleConstructTag{}, std::move(v)...) {} @@ -822,7 +824,7 @@ class ValueArray { GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 template -class CartesianProductGenerator +class [[nodiscard]] CartesianProductGenerator : public ParamGeneratorInterface<::std::tuple> { public: typedef ::std::tuple ParamType; @@ -939,7 +941,7 @@ class CartesianProductGenerator }; template -class CartesianProductHolder { +class [[nodiscard]] CartesianProductHolder { public: CartesianProductHolder(const Gen&... g) : generators_(g...) {} template @@ -952,11 +954,12 @@ class CartesianProductHolder { std::tuple generators_; }; -template -class ParamGeneratorConverter : public ParamGeneratorInterface { +template +class [[nodiscard]] ParamGeneratorConverter + : public ParamGeneratorInterface { public: - ParamGeneratorConverter(ParamGenerator gen) // NOLINT - : generator_(std::move(gen)) {} + ParamGeneratorConverter(ParamGenerator gen, Func converter) // NOLINT + : generator_(std::move(gen)), converter_(std::move(converter)) {} ParamIteratorInterface* Begin() const override { return new Iterator(this, generator_.begin(), generator_.end()); @@ -965,13 +968,21 @@ class ParamGeneratorConverter : public ParamGeneratorInterface { return new Iterator(this, generator_.end(), generator_.end()); } + // Returns the std::function wrapping the user-supplied converter callable. It + // is used by the iterator (see class Iterator below) to convert the object + // (of type FROM) returned by the ParamGenerator to an object of a type that + // can be static_cast to type TO. + const Func& TypeConverter() const { return converter_; } + private: class Iterator : public ParamIteratorInterface { public: - Iterator(const ParamGeneratorInterface* base, ParamIterator it, + Iterator(const ParamGeneratorConverter* base, ParamIterator it, ParamIterator end) : base_(base), it_(it), end_(end) { - if (it_ != end_) value_ = std::make_shared(static_cast(*it_)); + if (it_ != end_) + value_ = + std::make_shared(static_cast(base->TypeConverter()(*it_))); } ~Iterator() override = default; @@ -980,7 +991,9 @@ class ParamGeneratorConverter : public ParamGeneratorInterface { } void Advance() override { ++it_; - if (it_ != end_) value_ = std::make_shared(static_cast(*it_)); + if (it_ != end_) + value_ = + std::make_shared(static_cast(base_->TypeConverter()(*it_))); } ParamIteratorInterface* Clone() const override { return new Iterator(*this); @@ -1000,30 +1013,54 @@ class ParamGeneratorConverter : public ParamGeneratorInterface { private: Iterator(const Iterator& other) = default; - const ParamGeneratorInterface* const base_; + const ParamGeneratorConverter* const base_; ParamIterator it_; ParamIterator end_; std::shared_ptr value_; }; // class ParamGeneratorConverter::Iterator ParamGenerator generator_; + Func converter_; }; // class ParamGeneratorConverter -template -class ParamConverterGenerator { +template > +class [[nodiscard]] ParamConverterGenerator { public: - ParamConverterGenerator(ParamGenerator g) // NOLINT - : generator_(std::move(g)) {} + ParamConverterGenerator(ParamGenerator g) // NOLINT + : generator_(std::move(g)), converter_(Identity) {} + + ParamConverterGenerator(ParamGenerator g, StdFunction converter) + : generator_(std::move(g)), converter_(std::move(converter)) {} template operator ParamGenerator() const { // NOLINT - return ParamGenerator(new ParamGeneratorConverter(generator_)); + return ParamGenerator( + new ParamGeneratorConverter(generator_, + converter_)); } private: - ParamGenerator generator_; + static const GeneratedT& Identity(const GeneratedT& v) { return v; } + + ParamGenerator generator_; + StdFunction converter_; +}; + +// Template to determine the param type of a single-param std::function. +template +struct FuncSingleParamType; +template +struct FuncSingleParamType> { + using type = std::remove_cv_t>; }; +template +struct IsSingleArgStdFunction : public std::false_type {}; +template +struct IsSingleArgStdFunction> : public std::true_type {}; + } // namespace internal } // namespace testing diff --git a/Tests/GoogleTest/include/gtest/internal/gtest-port-arch.h b/Tests/GoogleTest/include/gtest/internal/gtest-port-arch.h index 7ec968f..fbffc95 100644 --- a/Tests/GoogleTest/include/gtest/internal/gtest-port-arch.h +++ b/Tests/GoogleTest/include/gtest/internal/gtest-port-arch.h @@ -119,6 +119,8 @@ #define GTEST_OS_NXP_QN9090 1 #elif defined(NRF52) #define GTEST_OS_NRF52 1 +#elif defined(__EMSCRIPTEN__) +#define GTEST_OS_EMSCRIPTEN 1 #endif // __CYGWIN__ #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ diff --git a/Tests/GoogleTest/include/gtest/internal/gtest-port.h b/Tests/GoogleTest/include/gtest/internal/gtest-port.h index 8d27c2c..92e6591 100644 --- a/Tests/GoogleTest/include/gtest/internal/gtest-port.h +++ b/Tests/GoogleTest/include/gtest/internal/gtest-port.h @@ -194,26 +194,12 @@ // // Macros for basic C++ coding: // GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning. -// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used. // GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is // suppressed (constant conditional). // GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127 // is suppressed. -// GTEST_INTERNAL_HAS_ANY - for enabling UniversalPrinter or -// UniversalPrinter specializations. -// Always defined to 0 or 1. -// GTEST_INTERNAL_HAS_OPTIONAL - for enabling UniversalPrinter -// or -// UniversalPrinter -// specializations. Always defined to 0 or 1. // GTEST_INTERNAL_HAS_STD_SPAN - for enabling UniversalPrinter // specializations. Always defined to 0 or 1 -// GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher or -// Matcher -// specializations. Always defined to 0 or 1. -// GTEST_INTERNAL_HAS_VARIANT - for enabling UniversalPrinter or -// UniversalPrinter -// specializations. Always defined to 0 or 1. // GTEST_USE_OWN_FLAGFILE_FLAG_ - Always defined to 0 or 1. // GTEST_HAS_CXXABI_H_ - Always defined to 0 or 1. // GTEST_CAN_STREAM_RESULTS_ - Always defined to 0 or 1. @@ -260,11 +246,6 @@ // BoolFromGTestEnv() - parses a bool environment variable. // Int32FromGTestEnv() - parses an int32_t environment variable. // StringFromGTestEnv() - parses a string environment variable. -// -// Deprecation warnings: -// GTEST_INTERNAL_DEPRECATED(message) - attribute marking a function as -// deprecated; calling a marked function -// should generate a compiler warning // The definition of GTEST_INTERNAL_CPLUSPLUS_LANG comes first because it can // potentially be used as an #include guard. @@ -275,8 +256,8 @@ #endif #if !defined(GTEST_INTERNAL_CPLUSPLUS_LANG) || \ - GTEST_INTERNAL_CPLUSPLUS_LANG < 201402L -#error C++ versions less than C++14 are not supported. + GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L +#error C++ versions less than C++17 are not supported. #endif // MSVC >= 19.11 (VS 2017 Update 3) supports __has_include. @@ -288,10 +269,14 @@ // Detect C++ feature test macros as gracefully as possible. // MSVC >= 19.15, Clang >= 3.4.1, and GCC >= 4.1.2 support feature test macros. -#if GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L && \ - (!defined(__has_include) || GTEST_INTERNAL_HAS_INCLUDE()) -#include // C++20 and later -#elif (!defined(__has_include) || GTEST_INTERNAL_HAS_INCLUDE()) +// +// GCC15 warns that is deprecated in C++17 and suggests using +// instead, even though is not available in C++17 mode prior +// to GCC9. +#if GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L || \ + GTEST_INTERNAL_HAS_INCLUDE() +#include // C++20 or support. +#else #include // Pre-C++20 #endif @@ -308,9 +293,10 @@ #include #include #include +// #include // Guarded by GTEST_IS_THREADSAFE below #include #include -// #include // Guarded by GTEST_IS_THREADSAFE below +#include #include #include #include @@ -378,18 +364,24 @@ #define GTEST_DISABLE_MSC_WARNINGS_POP_() #endif -// Clang on Windows does not understand MSVC's pragma warning. -// We need clang-specific way to disable function deprecation warning. -#ifdef __clang__ -#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ +// Pragmas to disable function deprecation warnings. +#if defined(__clang__) +#define GTEST_DISABLE_DEPRECATED_PUSH_() \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \ _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"") -#define GTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop") +#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop") +#elif defined(__GNUC__) +#define GTEST_DISABLE_DEPRECATED_PUSH_() \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop") +#elif defined(_MSC_VER) +#define GTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) +#define GTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_() #else -#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ - GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) -#define GTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_() +#define GTEST_DISABLE_DEPRECATED_PUSH_() +#define GTEST_DISABLE_DEPRECATED_POP_() #endif // Brings in definitions for functions used in the testing::internal::posix @@ -608,7 +600,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_GNU_KFREEBSD) || \ defined(GTEST_OS_OPENBSD) || defined(GTEST_OS_HAIKU) || \ defined(GTEST_OS_GNU_HURD) || defined(GTEST_OS_SOLARIS) || \ - defined(GTEST_OS_AIX) || defined(GTEST_OS_ZOS)) + defined(GTEST_OS_AIX) || defined(GTEST_OS_ZOS) || \ + (defined(GTEST_OS_EMSCRIPTEN) && defined(__EMSCRIPTEN_PTHREADS__))) #define GTEST_HAS_PTHREAD 1 #else #define GTEST_HAS_PTHREAD 0 @@ -679,12 +672,22 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; defined(GTEST_OS_NETBSD) || defined(GTEST_OS_FUCHSIA) || \ defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_GNU_KFREEBSD) || \ defined(GTEST_OS_HAIKU) || defined(GTEST_OS_GNU_HURD)) + // Death tests require a file system to work properly. #if GTEST_HAS_FILE_SYSTEM #define GTEST_HAS_DEATH_TEST 1 #endif // GTEST_HAS_FILE_SYSTEM #endif +// Determines whether the Premature Exit file can be created. +// Created by default when Death tests are supported, but other platforms can +// use the Premature exit file without Death test support (e.g. for detecting +// crashes). +#if GTEST_HAS_DEATH_TEST || \ + (defined(GTEST_OS_EMSCRIPTEN) && GTEST_HAS_FILE_SYSTEM) +#define GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE 1 +#endif + // Determines whether to support type-driven tests. // Typed tests need and variadic macros, which GCC, VC++ 8.0, @@ -772,25 +775,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #define GTEST_HAVE_FEATURE_(x) 0 #endif -// Use this annotation after a variable or parameter declaration to tell the -// compiler the variable/parameter may be used. -// Example: -// -// GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED int foo = bar(); -// -// This can be removed once we only support only C++17 or newer and -// [[maybe_unused]] is available on all supported platforms. -#if GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(maybe_unused) -#define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED [[maybe_unused]] -#elif GTEST_HAVE_ATTRIBUTE_(unused) -// This is inferior to [[maybe_unused]] as it can produce a -// -Wused-but-marked-unused warning on optionally used symbols, but it is all we -// have. -#define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED __attribute__((__unused__)) -#else -#define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED -#endif - // Use this annotation before a function that takes a printf format string. #if GTEST_HAVE_ATTRIBUTE_(format) && defined(__MINGW_PRINTF_FORMAT) // MinGW has two different printf implementations. Ensure the format macro @@ -805,17 +789,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) #endif -// Tell the compiler to warn about unused return values for functions declared -// with this macro. The macro should be used on function declarations -// following the argument list: -// -// Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_; -#if GTEST_HAVE_ATTRIBUTE_(warn_unused_result) -#define GTEST_MUST_USE_RESULT_ __attribute__((warn_unused_result)) -#else -#define GTEST_MUST_USE_RESULT_ -#endif - // MS C++ compiler emits warning when a conditional expression is compile time // constant. In some contexts this warning is false positive and needs to be // suppressed. Use the following two macros in such cases: @@ -867,11 +840,13 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #ifndef GTEST_API_ #ifdef _MSC_VER -#if defined(GTEST_LINKED_AS_SHARED_LIBRARY) && GTEST_LINKED_AS_SHARED_LIBRARY -#define GTEST_API_ __declspec(dllimport) -#elif defined(GTEST_CREATE_SHARED_LIBRARY) && GTEST_CREATE_SHARED_LIBRARY +#if defined(GTEST_CREATE_SHARED_LIBRARY) && GTEST_CREATE_SHARED_LIBRARY #define GTEST_API_ __declspec(dllexport) +#elif defined(GTEST_LINKED_AS_SHARED_LIBRARY) && GTEST_LINKED_AS_SHARED_LIBRARY +#define GTEST_API_ __declspec(dllimport) #endif +#elif GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(gnu::visibility) +#define GTEST_API_ [[gnu::visibility("default")]] #elif GTEST_HAVE_ATTRIBUTE_(visibility) #define GTEST_API_ __attribute__((visibility("default"))) #endif // _MSC_VER @@ -962,7 +937,7 @@ namespace internal { // A secret type that Google Test users don't know about. It has no // accessible constructors on purpose. Therefore it's impossible to create a // Secret object, which is what we want. -class Secret { +class [[nodiscard]] Secret { Secret(const Secret&) = delete; }; @@ -975,21 +950,21 @@ GTEST_API_ bool IsTrue(bool condition); #ifdef GTEST_USES_RE2 // This is almost `using RE = ::RE2`, except it is copy-constructible, and it -// needs to disambiguate the `std::string`, `absl::string_view`, and `const +// needs to disambiguate the `std::string`, `std::string_view`, and `const // char*` constructors. -class GTEST_API_ RE { +class GTEST_API_ [[nodiscard]] RE { public: - RE(absl::string_view regex) : regex_(regex) {} // NOLINT - RE(const char* regex) : RE(absl::string_view(regex)) {} // NOLINT - RE(const std::string& regex) : RE(absl::string_view(regex)) {} // NOLINT + RE(std::string_view regex) : regex_(regex) {} // NOLINT + RE(const char* regex) : RE(std::string_view(regex)) {} // NOLINT + RE(const std::string& regex) : RE(std::string_view(regex)) {} // NOLINT RE(const RE& other) : RE(other.pattern()) {} const std::string& pattern() const { return regex_.pattern(); } - static bool FullMatch(absl::string_view str, const RE& re) { + static bool FullMatch(std::string_view str, const RE& re) { return RE2::FullMatch(str, re.regex_); } - static bool PartialMatch(absl::string_view str, const RE& re) { + static bool PartialMatch(std::string_view str, const RE& re) { return RE2::PartialMatch(str, re.regex_); } @@ -1003,7 +978,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ // A simple C++ wrapper for . It uses the POSIX Extended // Regular Expression syntax. -class GTEST_API_ RE { +class GTEST_API_ [[nodiscard]] RE { public: // A copy constructor is required by the Standard to initialize object // references from r-values. @@ -1072,7 +1047,7 @@ enum GTestLogSeverity { GTEST_INFO, GTEST_WARNING, GTEST_ERROR, GTEST_FATAL }; // Formats log entry severity, provides a stream object for streaming the // log message, and terminates the message with a newline when going out of // scope. -class GTEST_API_ GTestLog { +class GTEST_API_ [[nodiscard]] GTestLog { public: GTestLog(GTestLogSeverity severity, const char* file, int line); @@ -1235,7 +1210,7 @@ void ClearInjectableArgvs(); #ifdef GTEST_OS_WINDOWS // Provides leak-safe Windows kernel handle ownership. // Used in death tests and in threading support. -class GTEST_API_ AutoHandle { +class GTEST_API_ [[nodiscard]] AutoHandle { public: // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to // avoid including in this header file. Including is @@ -1269,9 +1244,6 @@ class GTEST_API_ AutoHandle { // Nothing to do here. #else -GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ -/* class A needs to have dll-interface to be used by clients of class B */) - // Allows a controller thread to pause execution of newly created // threads until notified. Instances of this class must be created // and destroyed in the controller thread. @@ -1279,7 +1251,40 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ // This class is only for testing Google Test's own constructs. Do not // use it in user tests, either directly or indirectly. // TODO(b/203539622): Replace unconditionally with absl::Notification. -class GTEST_API_ Notification { +#ifdef GTEST_OS_WINDOWS_MINGW +// GCC version < 13 with the win32 thread model does not provide std::mutex and +// std::condition_variable in the and headers. So +// we implement the Notification class using a Windows manual-reset event. See +// https://gcc.gnu.org/gcc-13/changes.html#windows. +class GTEST_API_ [[nodiscard]] Notification { + public: + Notification(); + Notification(const Notification&) = delete; + Notification& operator=(const Notification&) = delete; + ~Notification(); + + // Notifies all threads created with this notification to start. Must + // be called from the controller thread. + void Notify(); + + // Blocks until the controller thread notifies. Must be called from a test + // thread. + void WaitForNotification(); + + private: + // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to + // avoid including in this header file. Including is + // undesirable because it defines a lot of symbols and macros that tend to + // conflict with client code. This assumption is verified by + // WindowsTypesTest.HANDLEIsVoidStar. + typedef void* Handle; + Handle event_; +}; +#else +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + +class GTEST_API_ [[nodiscard]] Notification { public: Notification() : notified_(false) {} Notification(const Notification&) = delete; @@ -1306,6 +1311,7 @@ class GTEST_API_ Notification { bool notified_; }; GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 +#endif // GTEST_OS_WINDOWS_MINGW #endif // GTEST_HAS_NOTIFICATION_ // On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD @@ -1318,7 +1324,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 // in order to call its Run(). Introducing ThreadWithParamBase as a // non-templated base class for ThreadWithParam allows us to bypass this // problem. -class ThreadWithParamBase { +class [[nodiscard]] ThreadWithParamBase { public: virtual ~ThreadWithParamBase() = default; virtual void Run() = 0; @@ -1348,7 +1354,7 @@ extern "C" inline void* ThreadFuncWithCLinkage(void* thread) { // These classes are only for testing Google Test's own constructs. Do // not use them in user tests, either directly or indirectly. template -class ThreadWithParam : public ThreadWithParamBase { +class [[nodiscard]] ThreadWithParam : public ThreadWithParamBase { public: typedef void UserThreadFunc(T); @@ -1414,7 +1420,7 @@ class ThreadWithParam : public ThreadWithParamBase { // GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex); // // (A non-static Mutex is defined/declared in the usual way). -class GTEST_API_ Mutex { +class GTEST_API_ [[nodiscard]] Mutex { public: enum MutexType { kStatic = 0, kDynamic = 1 }; // We rely on kStaticMutex being 0 as it is to what the linker initializes @@ -1430,9 +1436,9 @@ class GTEST_API_ Mutex { Mutex(); ~Mutex(); - void Lock(); + void lock(); - void Unlock(); + void unlock(); // Does nothing if the current thread holds the mutex. Otherwise, crashes // with high probability. @@ -1467,14 +1473,13 @@ class GTEST_API_ Mutex { // platforms. That macro is used as a defensive measure to prevent against // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than // "MutexLock l(&mu)". Hence the typedef trick below. -class GTestMutexLock { +class [[nodiscard]] GTestMutexLock { public: - explicit GTestMutexLock(Mutex* mutex) : mutex_(mutex) { mutex_->Lock(); } - - ~GTestMutexLock() { mutex_->Unlock(); } + explicit GTestMutexLock(Mutex& mutex) : mutex_(mutex) { mutex_.lock(); } + ~GTestMutexLock() { mutex_.unlock(); } private: - Mutex* const mutex_; + Mutex& mutex_; GTestMutexLock(const GTestMutexLock&) = delete; GTestMutexLock& operator=(const GTestMutexLock&) = delete; @@ -1484,14 +1489,14 @@ typedef GTestMutexLock MutexLock; // Base class for ValueHolder. Allows a caller to hold and delete a value // without knowing its type. -class ThreadLocalValueHolderBase { +class [[nodiscard]] ThreadLocalValueHolderBase { public: - virtual ~ThreadLocalValueHolderBase() {} + virtual ~ThreadLocalValueHolderBase() = default; }; // Provides a way for a thread to send notifications to a ThreadLocal // regardless of its parameter type. -class ThreadLocalBase { +class [[nodiscard]] ThreadLocalBase { public: // Creates a new ValueHolder object holding a default value passed to // this ThreadLocal's constructor and returns it. It is the caller's @@ -1500,8 +1505,8 @@ class ThreadLocalBase { virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0; protected: - ThreadLocalBase() {} - virtual ~ThreadLocalBase() {} + ThreadLocalBase() = default; + virtual ~ThreadLocalBase() = default; private: ThreadLocalBase(const ThreadLocalBase&) = delete; @@ -1511,7 +1516,7 @@ class ThreadLocalBase { // Maps a thread to a set of ThreadLocals that have values instantiated on that // thread and notifies them when the thread exits. A ThreadLocal instance is // expected to persist until all threads it has values on have terminated. -class GTEST_API_ ThreadLocalRegistry { +class GTEST_API_ [[nodiscard]] ThreadLocalRegistry { public: // Registers thread_local_instance as having value on the current thread. // Returns a value that can be used to identify the thread from other threads. @@ -1523,14 +1528,14 @@ class GTEST_API_ ThreadLocalRegistry { const ThreadLocalBase* thread_local_instance); }; -class GTEST_API_ ThreadWithParamBase { +class GTEST_API_ [[nodiscard]] ThreadWithParamBase { public: void Join(); protected: class Runnable { public: - virtual ~Runnable() {} + virtual ~Runnable() = default; virtual void Run() = 0; }; @@ -1543,20 +1548,20 @@ class GTEST_API_ ThreadWithParamBase { // Helper class for testing Google Test's multi-threading constructs. template -class ThreadWithParam : public ThreadWithParamBase { +class [[nodiscard]] ThreadWithParam : public ThreadWithParamBase { public: typedef void UserThreadFunc(T); ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start) : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {} - virtual ~ThreadWithParam() {} + ~ThreadWithParam() override = default; private: class RunnableImpl : public Runnable { public: RunnableImpl(UserThreadFunc* func, T param) : func_(func), param_(param) {} - virtual ~RunnableImpl() {} - virtual void Run() { func_(param_); } + ~RunnableImpl() override = default; + void Run() override { func_(param_); } private: UserThreadFunc* const func_; @@ -1598,7 +1603,7 @@ class ThreadWithParam : public ThreadWithParamBase { // object managed by Google Test will be leaked as long as all threads // using Google Test have exited when main() returns. template -class ThreadLocal : public ThreadLocalBase { +class [[nodiscard]] ThreadLocal : public ThreadLocalBase { public: ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {} explicit ThreadLocal(const T& value) @@ -1639,8 +1644,8 @@ class ThreadLocal : public ThreadLocalBase { class ValueHolderFactory { public: - ValueHolderFactory() {} - virtual ~ValueHolderFactory() {} + ValueHolderFactory() = default; + virtual ~ValueHolderFactory() = default; virtual ValueHolder* MakeNewHolder() const = 0; private: @@ -1650,7 +1655,7 @@ class ThreadLocal : public ThreadLocalBase { class DefaultValueHolderFactory : public ValueHolderFactory { public: - DefaultValueHolderFactory() {} + DefaultValueHolderFactory() = default; ValueHolder* MakeNewHolder() const override { return new ValueHolder(); } private: @@ -1683,17 +1688,17 @@ class ThreadLocal : public ThreadLocalBase { #elif GTEST_HAS_PTHREAD // MutexBase and Mutex implement mutex on pthreads-based platforms. -class MutexBase { +class [[nodiscard]] MutexBase { public: // Acquires this mutex. - void Lock() { + void lock() { GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_)); owner_ = pthread_self(); has_owner_ = true; } // Releases this mutex. - void Unlock() { + void unlock() { // Since the lock is being released the owner_ field should no longer be // considered valid. We don't protect writing to has_owner_ here, as it's // the caller's responsibility to ensure that the current thread holds the @@ -1741,7 +1746,7 @@ class MutexBase { // The Mutex class can only be used for mutexes created at runtime. It // shares its API with MutexBase otherwise. -class Mutex : public MutexBase { +class [[nodiscard]] Mutex : public MutexBase { public: Mutex() { GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr)); @@ -1759,14 +1764,13 @@ class Mutex : public MutexBase { // platforms. That macro is used as a defensive measure to prevent against // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than // "MutexLock l(&mu)". Hence the typedef trick below. -class GTestMutexLock { +class [[nodiscard]] GTestMutexLock { public: - explicit GTestMutexLock(MutexBase* mutex) : mutex_(mutex) { mutex_->Lock(); } - - ~GTestMutexLock() { mutex_->Unlock(); } + explicit GTestMutexLock(MutexBase& mutex) : mutex_(mutex) { mutex_.lock(); } + ~GTestMutexLock() { mutex_.unlock(); } private: - MutexBase* const mutex_; + MutexBase& mutex_; GTestMutexLock(const GTestMutexLock&) = delete; GTestMutexLock& operator=(const GTestMutexLock&) = delete; @@ -1780,7 +1784,7 @@ typedef GTestMutexLock MutexLock; // C-linkage. Therefore it cannot be templatized to access // ThreadLocal. Hence the need for class // ThreadLocalValueHolderBase. -class GTEST_API_ ThreadLocalValueHolderBase { +class GTEST_API_ [[nodiscard]] ThreadLocalValueHolderBase { public: virtual ~ThreadLocalValueHolderBase() = default; }; @@ -1793,7 +1797,7 @@ extern "C" inline void DeleteThreadLocalValue(void* value_holder) { // Implements thread-local storage on pthreads-based systems. template -class GTEST_API_ ThreadLocal { +class GTEST_API_ [[nodiscard]] ThreadLocal { public: ThreadLocal() : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {} @@ -1906,11 +1910,11 @@ class GTEST_API_ ThreadLocal { // mutex is not supported - using Google Test in multiple threads is not // supported on such platforms. -class Mutex { +class [[nodiscard]] Mutex { public: Mutex() {} - void Lock() {} - void Unlock() {} + void lock() {} + void unlock() {} void AssertHeld() const {} }; @@ -1924,15 +1928,15 @@ class Mutex { // platforms. That macro is used as a defensive measure to prevent against // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than // "MutexLock l(&mu)". Hence the typedef trick below. -class GTestMutexLock { +class [[nodiscard]] GTestMutexLock { public: - explicit GTestMutexLock(Mutex*) {} // NOLINT + explicit GTestMutexLock(Mutex&) {} // NOLINT }; typedef GTestMutexLock MutexLock; template -class GTEST_API_ ThreadLocal { +class GTEST_API_ [[nodiscard]] ThreadLocal { public: ThreadLocal() : value_() {} explicit ThreadLocal(const T& value) : value_(value) {} @@ -2122,7 +2126,7 @@ inline int IsATTY(int fd) { // Functions deprecated by MSVC 8.0. -GTEST_DISABLE_MSC_DEPRECATED_PUSH_() +GTEST_DISABLE_DEPRECATED_PUSH_() // ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and // StrError() aren't needed on Windows CE at this time and thus not @@ -2184,7 +2188,7 @@ inline const char* GetEnv(const char* name) { #endif } -GTEST_DISABLE_MSC_DEPRECATED_POP_() +GTEST_DISABLE_DEPRECATED_POP_() #ifdef GTEST_OS_WINDOWS_MOBILE // Windows CE has no C library. The abort() function is used in @@ -2240,7 +2244,7 @@ constexpr BiggestInt kMaxBiggestInt = (std::numeric_limits::max)(); // needs. Other types can be easily added in the future if need // arises. template -class TypeWithSize { +class [[nodiscard]] TypeWithSize { public: // This prevents the user from using TypeWithSize with incorrect // values of N. @@ -2249,7 +2253,7 @@ class TypeWithSize { // The specialization for size 4. template <> -class TypeWithSize<4> { +class [[nodiscard]] TypeWithSize<4> { public: using Int = std::int32_t; using UInt = std::uint32_t; @@ -2257,7 +2261,7 @@ class TypeWithSize<4> { // The specialization for size 8. template <> -class TypeWithSize<8> { +class [[nodiscard]] TypeWithSize<8> { public: using Int = std::int64_t; using UInt = std::uint64_t; @@ -2287,11 +2291,11 @@ using TimeInMillis = int64_t; // Represents time in milliseconds. // Macros for declaring flags. #define GTEST_DECLARE_bool_(name) \ - ABSL_DECLARE_FLAG(bool, GTEST_FLAG_NAME_(name)) + GTEST_API_ ABSL_DECLARE_FLAG(bool, GTEST_FLAG_NAME_(name)) #define GTEST_DECLARE_int32_(name) \ - ABSL_DECLARE_FLAG(int32_t, GTEST_FLAG_NAME_(name)) + GTEST_API_ ABSL_DECLARE_FLAG(int32_t, GTEST_FLAG_NAME_(name)) #define GTEST_DECLARE_string_(name) \ - ABSL_DECLARE_FLAG(std::string, GTEST_FLAG_NAME_(name)) + GTEST_API_ ABSL_DECLARE_FLAG(std::string, GTEST_FLAG_NAME_(name)) #define GTEST_FLAG_SAVER_ ::absl::FlagSaver @@ -2305,22 +2309,29 @@ using TimeInMillis = int64_t; // Represents time in milliseconds. // Macros for defining flags. #define GTEST_DEFINE_bool_(name, default_val, doc) \ + GTEST_DECLARE_bool_(name); \ namespace testing { \ GTEST_API_ bool GTEST_FLAG(name) = (default_val); \ } \ static_assert(true, "no-op to require trailing semicolon") #define GTEST_DEFINE_int32_(name, default_val, doc) \ + GTEST_DECLARE_int32_(name); \ namespace testing { \ GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val); \ } \ static_assert(true, "no-op to require trailing semicolon") #define GTEST_DEFINE_string_(name, default_val, doc) \ + GTEST_DECLARE_string_(name); \ namespace testing { \ GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val); \ } \ static_assert(true, "no-op to require trailing semicolon") // Macros for declaring flags. +// +// We also need to declare the flag in the public namespace to avoid triggering +// -Wmissing-variable-declarations warnings, as reported here: +// https://github.com/google/googletest/issues/4897 #define GTEST_DECLARE_bool_(name) \ namespace testing { \ GTEST_API_ extern bool GTEST_FLAG(name); \ @@ -2367,91 +2378,11 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val); } // namespace internal } // namespace testing -#if !defined(GTEST_INTERNAL_DEPRECATED) - -// Internal Macro to mark an API deprecated, for googletest usage only -// Usage: class GTEST_INTERNAL_DEPRECATED(message) MyClass or -// GTEST_INTERNAL_DEPRECATED(message) myFunction(); Every usage of -// a deprecated entity will trigger a warning when compiled with -// `-Wdeprecated-declarations` option (clang, gcc, any __GNUC__ compiler). -// For msvc /W3 option will need to be used -// Note that for 'other' compilers this macro evaluates to nothing to prevent -// compilations errors. -#if defined(_MSC_VER) -#define GTEST_INTERNAL_DEPRECATED(message) __declspec(deprecated(message)) -#elif defined(__GNUC__) -#define GTEST_INTERNAL_DEPRECATED(message) __attribute__((deprecated(message))) -#else -#define GTEST_INTERNAL_DEPRECATED(message) -#endif - -#endif // !defined(GTEST_INTERNAL_DEPRECATED) - -#ifdef GTEST_HAS_ABSL -// Always use absl::any for UniversalPrinter<> specializations if googletest -// is built with absl support. -#define GTEST_INTERNAL_HAS_ANY 1 -#include "absl/types/any.h" -namespace testing { -namespace internal { -using Any = ::absl::any; -} // namespace internal -} // namespace testing -#else -#if defined(__cpp_lib_any) || (GTEST_INTERNAL_HAS_INCLUDE() && \ - GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L && \ - (!defined(_MSC_VER) || GTEST_HAS_RTTI)) -// Otherwise for C++17 and higher use std::any for UniversalPrinter<> -// specializations. -#define GTEST_INTERNAL_HAS_ANY 1 -#include -namespace testing { -namespace internal { -using Any = ::std::any; -} // namespace internal -} // namespace testing -// The case where absl is configured NOT to alias std::any is not -// supported. -#endif // __cpp_lib_any -#endif // GTEST_HAS_ABSL - -#ifndef GTEST_INTERNAL_HAS_ANY -#define GTEST_INTERNAL_HAS_ANY 0 -#endif - -#ifdef GTEST_HAS_ABSL -// Always use absl::optional for UniversalPrinter<> specializations if -// googletest is built with absl support. -#define GTEST_INTERNAL_HAS_OPTIONAL 1 -#include "absl/types/optional.h" -namespace testing { -namespace internal { -template -using Optional = ::absl::optional; -inline ::absl::nullopt_t Nullopt() { return ::absl::nullopt; } -} // namespace internal -} // namespace testing +#if GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(clang::annotate) +#define GTEST_INTERNAL_DEPRECATE_AND_INLINE(msg) \ + [[deprecated(msg), clang::annotate("inline-me")]] #else -#if defined(__cpp_lib_optional) || (GTEST_INTERNAL_HAS_INCLUDE() && \ - GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L) -// Otherwise for C++17 and higher use std::optional for UniversalPrinter<> -// specializations. -#define GTEST_INTERNAL_HAS_OPTIONAL 1 -#include -namespace testing { -namespace internal { -template -using Optional = ::std::optional; -inline ::std::nullopt_t Nullopt() { return ::std::nullopt; } -} // namespace internal -} // namespace testing -// The case where absl is configured NOT to alias std::optional is not -// supported. -#endif // __cpp_lib_optional -#endif // GTEST_HAS_ABSL - -#ifndef GTEST_INTERNAL_HAS_OPTIONAL -#define GTEST_INTERNAL_HAS_OPTIONAL 0 +#define GTEST_INTERNAL_DEPRECATE_AND_INLINE(msg) [[deprecated(msg)]] #endif #if defined(__cpp_lib_span) || (GTEST_INTERNAL_HAS_INCLUDE() && \ @@ -2466,7 +2397,6 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; } #ifdef GTEST_HAS_ABSL // Always use absl::string_view for Matcher<> specializations if googletest // is built with absl support. -#define GTEST_INTERNAL_HAS_STRING_VIEW 1 #include "absl/strings/string_view.h" namespace testing { namespace internal { @@ -2474,63 +2404,20 @@ using StringView = ::absl::string_view; } // namespace internal } // namespace testing #else -#if defined(__cpp_lib_string_view) || \ - (GTEST_INTERNAL_HAS_INCLUDE() && \ - GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L) // Otherwise for C++17 and higher use std::string_view for Matcher<> // specializations. -#define GTEST_INTERNAL_HAS_STRING_VIEW 1 -#include namespace testing { namespace internal { -using StringView = ::std::string_view; +using StringView = std::string_view; } // namespace internal } // namespace testing -// The case where absl is configured NOT to alias std::string_view is not -// supported. -#endif // __cpp_lib_string_view #endif // GTEST_HAS_ABSL +#define GTEST_INTERNAL_HAS_STRING_VIEW 1 -#ifndef GTEST_INTERNAL_HAS_STRING_VIEW -#define GTEST_INTERNAL_HAS_STRING_VIEW 0 -#endif - -#ifdef GTEST_HAS_ABSL -// Always use absl::variant for UniversalPrinter<> specializations if googletest -// is built with absl support. -#define GTEST_INTERNAL_HAS_VARIANT 1 -#include "absl/types/variant.h" -namespace testing { -namespace internal { -template -using Variant = ::absl::variant; -} // namespace internal -} // namespace testing +#if defined(__cpp_lib_three_way_comparison) +#define GTEST_INTERNAL_HAS_COMPARE_LIB 1 #else -#if defined(__cpp_lib_variant) || (GTEST_INTERNAL_HAS_INCLUDE() && \ - GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L) -// Otherwise for C++17 and higher use std::variant for UniversalPrinter<> -// specializations. -#define GTEST_INTERNAL_HAS_VARIANT 1 -#include -namespace testing { -namespace internal { -template -using Variant = ::std::variant; -} // namespace internal -} // namespace testing -// The case where absl is configured NOT to alias std::variant is not supported. -#endif // __cpp_lib_variant -#endif // GTEST_HAS_ABSL - -#ifndef GTEST_INTERNAL_HAS_VARIANT -#define GTEST_INTERNAL_HAS_VARIANT 0 -#endif - -#if (defined(__cpp_constexpr) && !defined(__cpp_inline_variables)) || \ - (defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \ - GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L) -#define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1 +#define GTEST_INTERNAL_HAS_COMPARE_LIB 0 #endif #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ diff --git a/Tests/GoogleTest/include/gtest/internal/gtest-string.h b/Tests/GoogleTest/include/gtest/internal/gtest-string.h index 7c05b58..2363034 100644 --- a/Tests/GoogleTest/include/gtest/internal/gtest-string.h +++ b/Tests/GoogleTest/include/gtest/internal/gtest-string.h @@ -60,7 +60,7 @@ namespace testing { namespace internal { // String - an abstract class holding static string utilities. -class GTEST_API_ String { +class GTEST_API_ [[nodiscard]] String { public: // Static utility methods @@ -166,7 +166,7 @@ class GTEST_API_ String { private: String(); // Not meant to be instantiated. -}; // class String +}; // class String // Gets the content of the stringstream's buffer as an std::string. Each '\0' // character in the buffer is replaced with "\\0". diff --git a/Tests/README.md b/Tests/README.md index e305f6e..294b2a5 100644 --- a/Tests/README.md +++ b/Tests/README.md @@ -1,6 +1,6 @@ ### CAN API V3 Testing with GoogleTest -_Copyright © 2004-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com)_ \ +_Copyright © 2004-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de)_ \ _All rights reserved._ # CAN Interface Wrapper Specification @@ -182,5 +182,5 @@ All company, product and service names mentioned herein may be trademarks, regis ### Contact -E-Mail: mailto://info@uv-software.com \ +E-Mail: mailto://info@uv-software.de \ Internet: https://www.uv-software.com diff --git a/Tests/Sources/Device.cpp b/Tests/Sources/Device.cpp index c2120f0..cb72307 100644 --- a/Tests/Sources/Device.cpp +++ b/Tests/Sources/Device.cpp @@ -62,6 +62,12 @@ #else #define MESSAGE(n,i,l,d) do{ }while(0) #endif +#if (OPTION_CANTCP_ENABLED != 0) +#define DISCONNECT_CLIENT(client) do { if(g_CanServer.IsRunning()) (void)client.Disconnect(); } while(0) +#define CLIENT_READ_TIMEOUT 100U +#else +#define DISCONNECT_CLIENT(client) do { } while(0) +#endif CCanDevice::CCanDevice(int32_t library, int32_t channel, CANAPI_OpMode_t opMode, CANAPI_Bitrate_t bitRate, void *param) { m_nLibraryId = library; @@ -104,8 +110,21 @@ int32_t CCanDevice::SendSomeFrames(CCanDevice &other, int32_t frames) { } PCBUSB_INIT_DELAY(); } +#if (OPTION_CANTCP_ENABLED != 0) + if (g_CanServer.IsRunning()) { + if (!g_CanServer.AttachDevice(this)) { + if (!initialized) + (void)other.TeardownChannel(); + return (int32_t)CCanApi::FatalError; + } + } +#endif int32_t result = SendAndReceiveFrames(this, &other, frames); - +#if (OPTION_CANTCP_ENABLED != 0) + if (g_CanServer.IsRunning()) { + (void)g_CanServer.DetachDevice(); + } +#endif if (!started) { if ((retVal = other.ResetController()) != CCanApi::NoError) { if (!initialized) @@ -148,8 +167,21 @@ int32_t CCanDevice::ReceiveSomeFrames(CCanDevice &other, int32_t frames) { } PCBUSB_INIT_DELAY(); } +#if (OPTION_CANTCP_ENABLED != 0) + if (g_CanServer.IsRunning()) { + if (!g_CanServer.AttachDevice(&other)) { + if (!initialized) + (void)other.TeardownChannel(); + return (int32_t)CCanApi::FatalError; + } + } +#endif int32_t result = SendAndReceiveFrames(&other, this, frames); - +#if (OPTION_CANTCP_ENABLED != 0) + if (g_CanServer.IsRunning()) { + (void)g_CanServer.DetachDevice(); + } +#endif if (!started) { if ((retVal = other.ResetController()) != CCanApi::NoError) { if (!initialized) @@ -180,18 +212,26 @@ int32_t CCanDevice::SendAndReceiveFrames(CCanDevice *sender, CCanDevice *receive #endif txMessage.xtd = 0; txMessage.rtr = 0; + txMessage.err = 0; txMessage.sts = 0; txMessage.dlc = 0U; -#if (DEVICE_DEBUG != 0) - // time spec - struct timespec t0 = {}; - struct timespec t1 = {}; - struct timespec t2 = {}; - struct timespec m0 = {}; - struct timespec m1 = {}; - // get current time: start of transmission - t0 = CTimer::GetTime(); +#if (OPTION_CANTCP_ENABLED != 0) + CANAPI_Message_t ipMessage = {}; + + CCanTcpClient txClient = CCanTcpClient(); + CCanTcpClient rxClient = CCanTcpClient(); + + if (g_CanServer.IsRunning()) { + if ((retVal = txClient.Connect(CCanTcpClient::localhost(g_Options.GetCanServerService()))) != CCanApi::NoError) { + //printf("txClient.Connect() failed with %d\n", retVal); + return (int32_t)retVal; + } + if ((retVal = rxClient.Connect(CCanTcpClient::localhost(g_Options.GetCanServerService()))) != CCanApi::NoError) { + //printf("rxClient.Connect() failed with %d\n", retVal); + return (int32_t)retVal; + } + } #endif // send the messages CProgress progress = CProgress(frames); @@ -205,14 +245,25 @@ int32_t CCanDevice::SendAndReceiveFrames(CCanDevice *sender, CCanDevice *receive txMessage.data[5] = (uint8_t)((uint64_t)i >> 40); if ((uint64_t)i > (uint64_t)0x0FFFFFFFFFF) txMessage.dlc = 6U; txMessage.data[6] = (uint8_t)((uint64_t)i >> 48); if ((uint64_t)i > (uint64_t)0x0FFFFFFFFFFFF) txMessage.dlc = 7U; txMessage.data[7] = (uint8_t)((uint64_t)i >> 56); if ((uint64_t)i > (uint64_t)0x0FFFFFFFFFFFFFF) txMessage.dlc = 8U; - // send one message (retry if busy) - do { - retVal = sender->WriteMessage(txMessage, DEVICE_SEND_TIMEOUT); - if (retVal == CCanApi::TransmitterBusy) - PCBUSB_QXMT_DELAY(); - } while (retVal == CCanApi::TransmitterBusy); + // send the message +#if (OPTION_CANTCP_ENABLED != 0) + if (g_CanServer.IsRunning()) { + // send via RocketCAN interface + retVal = txClient.Send(txMessage); + } else +#endif + { + // send via CAN bus (retry if busy) + do { + retVal = sender->WriteMessage(txMessage, DEVICE_SEND_TIMEOUT); + if (retVal == CCanApi::TransmitterBusy) + PCBUSB_QXMT_DELAY(); + } while (retVal == CCanApi::TransmitterBusy); + } // on error abort if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); progress.Clear(); return (int32_t)retVal; } @@ -223,41 +274,79 @@ int32_t CCanDevice::SendAndReceiveFrames(CCanDevice *sender, CCanDevice *receive retVal = receiver->ReadMessage(rxMessage, 0U); if (retVal == CCanApi::NoError) { // ignore status messages/error frames - if (!rxMessage.sts) { + if (!rxMessage.sts && !rxMessage.err) { // update number of received CAN messages progress.Update((int)(i + 1), (int)(n + 1)); // check the message (id, length, up-counting number) retVal = CheckMessage(rxMessage, (uint64_t)n, txMessage.id); if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); progress.Clear(); MESSAGE(n, rxMessage.id, rxMessage.dlc, rxMessage.data); return (int32_t)retVal; } -#if (DEVICE_DEBUG != 0) - if (n == 0) // first message - m0 = rxMessage.timestamp; +#if (OPTION_CANTCP_ENABLED != 0) + if (g_CanServer.IsRunning()) { + // re-send via RocketCAN server + retVal = g_CanServer.Send(rxMessage); + if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); + progress.Clear(); + return (int32_t)retVal; + } + // read the re-sent message on receiver's client + retVal = rxClient.Receive(ipMessage, CLIENT_READ_TIMEOUT); + if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); + progress.Clear(); + return (int32_t)retVal; + } + // check the re-sent message (id, length, up-counting number) + retVal = CheckMessage(ipMessage, (uint64_t)n, txMessage.id); + if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); + progress.Clear(); + MESSAGE(n, ipMessage.id, ipMessage.dlc, ipMessage.data); + return (int32_t)retVal + 10; + } + // read the re-send message on sender's client + retVal = txClient.Receive(ipMessage, CLIENT_READ_TIMEOUT); + if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); + progress.Clear(); + return (int32_t)retVal; + } + // check the re-sent message (id, length, up-counting number) + retVal = CheckMessage(ipMessage, (uint64_t)n, txMessage.id); + if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); + progress.Clear(); + MESSAGE(n, ipMessage.id, ipMessage.dlc, ipMessage.data); + return (int32_t)retVal + 20; + } + } #endif n++; } } else if (retVal != CCanApi::ReceiverEmpty) { if (++rxRetry > DEVICE_READ_RETRIES) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); progress.Clear(); return (int32_t)retVal; } } } -#if (DEVICE_DEBUG != 0) - // get current time: end of transmission - t1 = CTimer::GetTime(); -#endif // finish the plate int32_t remaining = (int32_t)(frames - n); -#if (0) //defined(_WIN32) || defined(_WIN64) - uint32_t timeout = ((uint64_t)remaining * DEVICE_LOOP_TIMEOUT * CTimer::MSEC); // FIXME: does not work for all bit-rates -#else uint64_t timeout = (((uint64_t)TransmissionTime(receiver->GetBitrate(), (remaining + DEVICE_LOOP_EXTRA)) * (uint64_t)DEVICE_LOOP_FACTOR) / (uint64_t)DEVICE_LOOP_DIVISOR); // bit-rate dependent timeout -#endif if (n < frames) { CTimer timer = CTimer(timeout); while ((n < frames) && !timer.Timeout()) { @@ -265,55 +354,91 @@ int32_t CCanDevice::SendAndReceiveFrames(CCanDevice *sender, CCanDevice *receive retVal = receiver->ReadMessage(rxMessage, DEVICE_READ_TIMEOUT); if (retVal == CCanApi::NoError) { // ignore status messages/error frames - if (!rxMessage.sts) { + if (!rxMessage.sts && !rxMessage.err) { // update number of received CAN messages progress.Update((int)frames, (int)(n + 1)); // check the message (id, length, up-counting number) retVal = CheckMessage(rxMessage, (uint64_t)n, txMessage.id); if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); progress.Clear(); MESSAGE(n, rxMessage.id, rxMessage.dlc, rxMessage.data); return (int32_t)retVal; } -#if (DEVICE_DEBUG != 0) - if (n == 0) // first message - m0 = rxMessage.timestamp; +#if (OPTION_CANTCP_ENABLED != 0) + if (g_CanServer.IsRunning()) { + // re-send via RocketCAN server + retVal = g_CanServer.Send(rxMessage); + if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); + progress.Clear(); + return (int32_t)retVal; + } + // read the re-sent message on receiver's client + retVal = rxClient.Receive(ipMessage, CLIENT_READ_TIMEOUT); + if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); + progress.Clear(); + return (int32_t)retVal; + } + // check the re-sent message (id, length, up-counting number) + retVal = CheckMessage(ipMessage, (uint64_t)n, txMessage.id); + if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); + progress.Clear(); + MESSAGE(n, ipMessage.id, ipMessage.dlc, ipMessage.data); + return (int32_t)retVal + 10; + } + // read the re-send message on sender's client + retVal = txClient.Receive(ipMessage, CLIENT_READ_TIMEOUT); + if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); + progress.Clear(); + return (int32_t)retVal; + } + // check the re-sent message (id, length, up-counting number) + retVal = CheckMessage(ipMessage, (uint64_t)n, txMessage.id); + if (retVal != CCanApi::NoError) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); + progress.Clear(); + MESSAGE(n, ipMessage.id, ipMessage.dlc, ipMessage.data); + return (int32_t)retVal + 20; + } + } #endif n++; -#if (DEVICE_DEBUG != 0) - if (n == frames) // last message - m1 = rxMessage.timestamp; -#endif } } else if (retVal != CCanApi::ReceiverEmpty) { if (++rxRetry > DEVICE_READ_RETRIES) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); progress.Clear(); return (int32_t)retVal; } } } if (timer.Timeout()) { + DISCONNECT_CLIENT(txClient); + DISCONNECT_CLIENT(rxClient); progress.Clear(); return (int32_t)CANERR_TIMEOUT; } } -#if (DEVICE_DEBUG != 0) - // get current time: end of reception - t2 = CTimer::GetTime(); +#if (OPTION_CANTCP_ENABLED != 0) + if (g_CanServer.IsRunning()) { + (void)txClient.Disconnect(); + (void)rxClient.Disconnect(); + } #endif // return the number of received messages progress.Clear(); -#if (DEVICE_DEBUG != 0) - if (frames > 0) { - std::cout << " " << frames << " total sent frames in " << ((float)CTimer::DiffTime(t0, t1) * 1000.f) << "ms"; - if (remaining > 0) - std::cout << " + " << remaining << " remaining frames in " << ((float)CTimer::DiffTime(t1, t2) * 1000.f) << "ms w/ timeout " << ((float)timeout / 1000.f) << "ms"; - if (remaining > 1) - std::cout << " : reception of " << n << " frames in " << ((float)CTimer::DiffTime(m0, m1) * 1000.f) << "ms"; - std::cout << std::endl; - } -#endif return (int32_t)n; } @@ -355,6 +480,7 @@ bool CCanDevice::CompareMessages(CANAPI_Message_t message1, CANAPI_Message_t mes if(message1.id != message2.id) return false; if(message1.xtd != message2.xtd) return false; if(message1.rtr != message2.rtr) return false; + if(message1.err != message2.err) return false; if(message1.sts != message2.sts) return false; #if (OPTION_CAN_2_0_ONLY == OPTION_DISABLED) if(message1.fdf != message2.fdf) return false; @@ -610,4 +736,4 @@ void CCanDevice::ShowChannelCapabilities(const char* prefix) { std::cout << std::endl; } -// $Id: Device.cpp 1411 2025-01-17 18:59:07Z quaoar $ Copyright (c) UV Software, Berlin // +// $Id: Device.cpp 1493 2025-03-07 18:25:36Z sedna $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Options.cpp b/Tests/Sources/Options.cpp index 7025be0..330bd5d 100644 --- a/Tests/Sources/Options.cpp +++ b/Tests/Sources/Options.cpp @@ -76,6 +76,11 @@ #define OPTION_RUN_ALL "--run_all" #define OPTION_RUN_QUICK "--run_quick" #define OPTION_RUN_CALLSEQUENCES "--run_callsequences" +#define OPTION_INTERACTIVE_START "--interactive_start" +#if (OPTION_CANTCP_ENABLED != 0) +#define OPTION_GATEWAY "--gateway" +#define OPTION_LOGGING "--logging" +#endif static const bool c_fCanClassic = false; static const bool c_f3rdDevice = false; @@ -83,6 +88,10 @@ static const bool c_fRtrDevice = false; static const bool c_fRunQuick = false; static const bool c_fCallSequences = false; static const bool c_fBitrateConverter = false; +static const bool c_fStartInteractive = false; +#if (OPTION_CANTCP_ENABLED != 0) +static const char c_szService[] = "60000"; +#endif #if (OPTION_CANAPI_LIBRARY != 0) static const char c_szDefaultSearchPath[] = "."; #endif @@ -115,6 +124,7 @@ COptions::COptions() { // test options m_s32TestFrames = (int32_t)TEST_FRAMES; m_s32SmokeTestFrames = (int32_t)TEST_TRAFFIC; + m_fStartInteractive = c_fStartInteractive; m_fCallSequences = c_fCallSequences; m_fBitrateConverter = c_fBitrateConverter; m_fCanClassic = c_fCanClassic; @@ -122,6 +132,12 @@ COptions::COptions() { m_fRtrDevice = c_fRtrDevice; m_fRunQuick = c_fRunQuick; m_fShowHelp = false; +#if (OPTION_CANTCP_ENABLED != 0) + // server options + m_Server.m_fEnable = false; + m_Server.m_szService = (char*)c_szService; + m_Server.m_nLogging = 0; +#endif } bool COptions::GetChannelInfoByDeviceName(const char *name, CCanApi::SChannelInfo &info) { @@ -183,6 +199,11 @@ int COptions::ScanOptions(int argc, char* argv[], char* err, size_t len) { int rtr_device = 0; int run_callsequences = 0; int run_quick = 0; + #if (OPTION_CANTCP_ENABLED != 0) + int opt_gateway = 0; + int opt_logging = 0; +#endif + int opt_interactive = 0; char* opt = NULL; //char *arg = NULL; #if (CAN_FD_SUPPORTED == FEATURE_SUPPORTED) @@ -191,7 +212,6 @@ int COptions::ScanOptions(int argc, char* argv[], char* err, size_t len) { #endif long baudrate = 0; long frames = 0; - for (int i = 1; i < argc; i++) { // option: --can_help [to be scanned first] if (strcmp(argv[i], OPTION_HELP) == 0) { @@ -300,7 +320,7 @@ int COptions::ScanOptions(int argc, char* argv[], char* err, size_t len) { return false; } } - // option: --can_mode=(CAN2.0|CANFD[+BRS]) + // option: --can_mode=(CANCC|CANFD[+BRS]) #if (CAN_FD_SUPPORTED == FEATURE_SUPPORTED) else if (strncmp(argv[i], OPTION_MODE, strlen(OPTION_MODE)) == 0) { @@ -321,7 +341,9 @@ int COptions::ScanOptions(int argc, char* argv[], char* err, size_t len) { !strcasecmp(opt, "classic") || !strcasecmp(opt, "CAN2.0") || !strcasecmp(opt, "CAN20") || - !strcasecmp(opt, "2.0")) { + !strcasecmp(opt, "2.0") || + !strcasecmp(opt, "CC") || + !strcasecmp(opt, "CCF")) { m_Dut[DUT1].m_OpMode.fdoe = m_Dut[DUT2].m_OpMode.fdoe = 0; m_Dut[DUT1].m_OpMode.brse = m_Dut[DUT2].m_OpMode.brse = 0; } @@ -664,6 +686,82 @@ int COptions::ScanOptions(int argc, char* argv[], char* err, size_t len) { else m_fRunQuick = true; } +#if (OPTION_CANTCP_ENABLED != 0) + // option: --gateway= + else if (strncmp(argv[i], OPTION_GATEWAY, strlen(OPTION_GATEWAY)) == 0) + { + if (opt_gateway++) { + if (err) + snprintf(err, len, "duplicated option %s", OPTION_GATEWAY); + return false; + } + if (((opt = strchr(argv[i], '=')) != NULL) && + (argv[i][strlen(OPTION_GATEWAY)] == '=')) { + if (strlen(++opt) == 0) { + if (err) + snprintf(err, len, "missing argument for option %s", OPTION_GATEWAY); + return false; + } + m_Server.m_szService = opt; + m_Server.m_fEnable = true; + } + else { + if (err) + snprintf(err, len, "missing argument for option %s", OPTION_GATEWAY); + return false; + } + } + // option: --logging= (with >= 0) + else if (strncmp(argv[i], OPTION_LOGGING, strlen(OPTION_LOGGING)) == 0) + { + if (opt_logging++) { + if (err) + snprintf(err, len, "duplicated option %s", OPTION_LOGGING); + return false; + } + if (((opt = strchr(argv[i], '=')) != NULL) && + (argv[i][strlen(OPTION_LOGGING)] == '=')) { + if (strlen(++opt) == 0) { + if (err) + snprintf(err, len, "missing argument for option %s", OPTION_LOGGING); + return false; + } + if ((sscanf(opt, "%d", &m_Server.m_nLogging) != 1) || (m_Server.m_nLogging < 0)) { + snprintf(err, len, "illegal argument in option %s", OPTION_LOGGING); + return false; + } + } + else { + if (err) + snprintf(err, len, "missing argument for option %s", OPTION_LOGGING); + return false; + } + } +#endif + // option: --interactive[=(YES|NO)] + else if (strncmp(argv[i], OPTION_INTERACTIVE_START, strlen(OPTION_INTERACTIVE_START)) == 0) + { + if (opt_interactive++) { + if (err) + snprintf(err, len, "duplicated option %s", OPTION_INTERACTIVE_START); + return false; + } + if (((opt = strchr(argv[i], '=')) != NULL) && + (argv[i][strlen(OPTION_INTERACTIVE_START)] == '=')) { + if (strlen(++opt) == 0) { + if (err) + snprintf(err, len, "missing argument for option %s", OPTION_INTERACTIVE_START); + return false; + } + if ((strcasecmp(opt, "YES") == 0) || (strcasecmp(opt, "ON") == 0) || + (strcasecmp(opt, "Y") == 0) || (strcasecmp(opt, "1") == 0)) + m_fStartInteractive = true; + else + m_fStartInteractive = false; + } + else + m_fStartInteractive = true; + } // unknown option (note: GoogleTest does not eat option '--help') else if (strcmp(argv[i], "--help") != 0) { if (err) @@ -687,9 +785,9 @@ int COptions::ShowHelp() { std::cout << " This option must be given before option " << OPTION_DUT1 << " and " << OPTION_DUT2 << "." << std::endl; #endif #if (CAN_FD_SUPPORTED == FEATURE_SUPPORTED) - std::cout << " " << OPTION_MODE << "=(CAN2.0|CANFD[+BRS])" << std::endl; + std::cout << " " << OPTION_MODE << "=(CANCC|CANFD[+BRS])" << std::endl; std::cout << " CAN operation mode: CAN 2.0 or CAN FD format." << std::endl; - std::cout << " CAN2.0 = CAN classic (default)" << std::endl; + std::cout << " CANCC = CAN classic (default)" << std::endl; std::cout << " CANFD = CAN FD long frames only" << std::endl; std::cout << " CANFD+BRS = CAN FD long and fast frames" << std::endl; #endif @@ -740,19 +838,32 @@ int COptions::ShowHelp() { std::cout << " Disables or enables the execution of test cases with non-default bit-rate settings (default=" << (c_f3rdDevice ? "yes" : "no") << ")." << std::endl; std::cout << " " << OPTION_RTR_DEVICE << "[=(NO|YES)]" << std::endl; std::cout << " Enables or disables the execution of test cases for which a RTR answering device is required (default=" << (c_fRtrDevice ? "yes" : "no") << ")." << std::endl; +#if (OPTION_CANTCP_ENABLED != 0) + std::cout << " " << OPTION_GATEWAY << "=" << std::endl; + std::cout << " Starts the RocketCAN server on the specified port." << std::endl; + std::cout << " " << OPTION_LOGGING << "=" << std::endl; + std::cout << " Sets the logging level of the RocketCAN server (0 = no logging)." << std::endl; +#endif std::cout << " " << OPTION_RUN_CALLSEQUENCES << "[=(NO|YES)]" << std::endl; std::cout << " Enables or disables the execution of test cases from suite 'CallSequences' (default=" << (c_fCallSequences ? "yes" : "no") << ")." << std::endl; std::cout << " " << OPTION_RUN_ALL << "[=(NO|YES)]" << std::endl; std::cout << " Enables or disables the execution all optional tests (default=no)." << std::endl; std::cout << " " << OPTION_RUN_QUICK << "[=(NO|YES)]" << std::endl; std::cout << " Disables or enables the execution of long lasting test cases (default=" << (c_fRunQuick ? "yes" : "no") << ")." << std::endl; + std::cout << " " << OPTION_INTERACTIVE_START << "[=(NO|YES)]" << std::endl; + std::cout << " Starts test execution only when the Anykey is pressed (default=" << (c_fStartInteractive ? "yes" : "no") << ")." << std::endl; std::cout << std::endl; std::cout << "Hazard Note:" << std::endl; std::cout << " If you connect your CAN device to a real CAN network when using this program," << std::endl; std::cout << " you might damage your application." << std::endl; + #if (OPTION_CANTCP_ENABLED != 0) + std::cout << " If you open a port for socket communication while using this program, it may" << std::endl; + std::cout << " expose your computer to security vulnerabilities, unauthorized access, data" << std::endl; + std::cout << " interception, denial of service attacks, and resource exhaustion." << std::endl; + #endif std::cout << std::endl; } return m_fShowHelp; } -// $Id: Options.cpp 1411 2025-01-17 18:59:07Z quaoar $ Copyright (c) UV Software, Berlin // +// $Id: Options.cpp 1486 2025-03-02 15:50:07Z quaoar $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Options.h b/Tests/Sources/Options.h index d34993f..95944d5 100644 --- a/Tests/Sources/Options.h +++ b/Tests/Sources/Options.h @@ -55,7 +55,9 @@ #endif #include "Driver.h" - +#if (OPTION_CANTCP_ENABLED != 0) +#include "Server.h" +#endif #define NUM_DUTS 2 // number of devices under test #define DUT1 0 // device under test #1 #define DUT2 1 // device under test #2 @@ -79,6 +81,7 @@ class COptions { // test options int32_t m_s32TestFrames; // number of CAN frames to be sent during tests int32_t m_s32SmokeTestFrames; // number of CAN frames to be sent during smoketest + bool m_fStartInteractive; // start test execution only when the Anykey is pressed bool m_fCallSequences; // execute test cases from suite 'CallSequences' bool m_fBitrateConverter; // execute test cases from suite 'BitrateConverter' bool m_fCanClassic; // execute only test cases in CAN Classic mode @@ -86,6 +89,14 @@ class COptions { bool m_fRtrDevice; // a device that can answer RTR frames is connected bool m_fRunQuick; // omit some long lasting test cases bool m_fShowHelp; // show help and exit +#if (OPTION_CANTCP_ENABLED != 0) + // server options + struct SServer { + bool m_fEnable; // enable RocketCAN server + char *m_szService; // service name or port number + int m_nLogging; // logging level + } m_Server; +#endif public: // constructor / destructor COptions(); @@ -138,6 +149,28 @@ class COptions { bool IsRtrDevicePresent() { return m_fRtrDevice; } + bool StartInteractive() { + return m_fStartInteractive; + } +#if (OPTION_CANTCP_ENABLED != 0) + bool IsCanServerEnabled() { + return m_Server.m_fEnable; + } + const char *GetCanServerService() { + return (const char*)m_Server.m_szService; + } +#if (0) + CCanServer::EFrameFormat GetCanServerFormat() { + return m_Server.m_eFormat; + } + CCanServer::EIpcProtocol GetCanServerProtocol() { + return m_Server.m_eProtocol; + } +#endif + int GetCanServerLoggingLevel() { + return m_Server.m_nLogging; + } +#endif // scan commandline arguments int ScanOptions(int argc, char* argv[], char* err = NULL, size_t len = 0); int ShowHelp(); @@ -150,4 +183,4 @@ extern COptions g_Options; // global access to testing options #endif // OPTIONS_H_INCLUDED -// $Id: Options.h 1411 2025-01-17 18:59:07Z quaoar $ Copyright (c) UV Software, Berlin. +// $Id: Options.h 1486 2025-03-02 15:50:07Z quaoar $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Sources/Server.cpp b/Tests/Sources/Server.cpp new file mode 100644 index 0000000..5b3d79d --- /dev/null +++ b/Tests/Sources/Server.cpp @@ -0,0 +1,170 @@ +// SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-or-later +// +// CAN Interface API, Version 3 (Testing) +// +// Copyright (c) 2004-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// All rights reserved. +// +// This file is part of CAN API V3. +// +// CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License +// and under the GNU General Public License v2.0 (or any later version). +// You can choose between one of them if you use this file. +// +// (1) BSD 2-Clause "Simplified" License +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// CAN API V3 IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF CAN API V3, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// (2) GNU General Public License v2.0 or later +// +// CAN API V3 is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// CAN API V3 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with CAN API V3; if not, see . +// +#include "pch.h" +#include "Server.h" +#include "crc_j1850.h" + +#include +#include +#include +#include +#if !defined(_WIN32) && !defined(_WIN64) +#include +#include +#else +#include +#endif +#include + +#if (OPTION_CANTCP_ENABLED != 0) +CCanServer g_CanServer = CCanServer(); // global access to CAN server +#endif + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; // mutex for critical sections +static CCanDevice *canDevice = NULL; // to be used in the C callback function + +static int EventHandler(const void *data, size_t size, void *param) { + CANTCP_Message_t* ipc_msg = (CANTCP_Message_t*)data; + CANAPI_Message_t can_msg = CANAPI_Message_t(); + int retVal = CCanApi::FatalError; + (void)param; + + /* sanity check */ + if (!data) { + return CCanApi::NullPointer; + } + if (size != sizeof(CANTCP_Message_t)) { + return CCanApi::IllegalParameter; + } + if (crc_j1850_calc(data, sizeof(CANTCP_Message_t) - 1U, NULL) != ipc_msg->checksum) { + return (int)(-80); // TODO: define error code + } + if (ipc_msg->ctrlchar != CANTCP_ETX_CHAR) { + return (int)(-81); // TODO: define error code + } + /* convert the message from network to host byte order */ + CANTCP_MSG_NTOH(*ipc_msg); + /* transmit the message on the CAN bus */ + can_msg.id = ipc_msg->id; + can_msg.xtd = (ipc_msg->flags & CANTCP_XTD_MASK) ? 1 : 0; + can_msg.rtr = (ipc_msg->flags & CANTCP_RTR_MASK) ? 1 : 0; + can_msg.fdf = (ipc_msg->flags & CANTCP_FDF_MASK) ? 1 : 0; + can_msg.brs = (ipc_msg->flags & CANTCP_BRS_MASK) ? 1 : 0; + can_msg.esi = (ipc_msg->flags & CANTCP_ESI_MASK) ? 1 : 0; + can_msg.err = (ipc_msg->flags & CANTCP_ERR_MASK) ? 1 : 0; // set also flag 'sts' and flag 'err' even + can_msg.sts = (ipc_msg->flags & CANTCP_STS_MASK) ? 1 : 0; // that they can't be send on the CAN bus + can_msg.dlc = CCanApi::Len2Dlc(ipc_msg->length); + for (int i = 0; (i < CANFD_MAX_LEN) && (i < CANTCP_MAX_LEN); i++) { + can_msg.data[i] = ipc_msg->data[i]; + } + /* make it so! */ + assert(pthread_mutex_lock(&mutex) == 0); + if (canDevice) { + do { + retVal = canDevice->WriteMessage(can_msg); + if (retVal == CCanApi::TransmitterBusy) + PCBUSB_QXMT_DELAY(); + } while (retVal == CCanApi::TransmitterBusy); + } else { + retVal = CCanApi::NotSupported; + } + assert(pthread_mutex_unlock(&mutex) == 0); + /* who cares about? */ + return retVal; +} + +CCanServer::CCanServer() : CCanTcpServer() { + assert(pthread_mutex_init(&mutex, NULL) == 0); + canDevice = NULL; +} + +CCanServer::~CCanServer() { + if (IsRunning()) { + Stop(); + } + assert(pthread_mutex_destroy(&mutex) == 0); +} + +bool CCanServer::AttachDevice(CCanDevice *device) { + assert(pthread_mutex_lock(&mutex) == 0); + canDevice = device; + assert(pthread_mutex_unlock(&mutex) == 0); + return true; +} + +bool CCanServer::DetachDevice() { + assert(pthread_mutex_lock(&mutex) == 0); + canDevice = NULL; + assert(pthread_mutex_unlock(&mutex) == 0); + return true; +} + +CANAPI_Return_t CCanServer::StartServer(const char *service) { + if (!SetCallback(EventHandler)) return CCanApi::AlreadyInitialized; + return Start(service); +} + +CANAPI_Return_t CCanServer::StopServer() { + CANAPI_Return_t retVal = Stop(); + SetCallback(NULL); + DetachDevice(); + return retVal; +} + +void CCanServer::ShowServerPort(const char* prefix) { + if (IsRunning()) { + if (prefix) + std::cout << prefix << ' '; + std::cout << "RocketCAN server listening on port " << GetService(); + std::cout << " with data size " << GetFrameSize() << " 🚀" << std::endl; + } +} + +// $Id: Server.cpp 1493 2025-03-07 18:25:36Z sedna $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Sources/Server.h b/Tests/Sources/Server.h new file mode 100644 index 0000000..01206f6 --- /dev/null +++ b/Tests/Sources/Server.h @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-or-later +// +// CAN Interface API, Version 3 (Testing) +// +// Copyright (c) 2004-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// All rights reserved. +// +// This file is part of CAN API V3. +// +// CAN API V3 is dual-licensed under the BSD 2-Clause "Simplified" License +// and under the GNU General Public License v2.0 (or any later version). +// You can choose between one of them if you use this file. +// +// (1) BSD 2-Clause "Simplified" License +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// CAN API V3 IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF CAN API V3, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// (2) GNU General Public License v2.0 or later +// +// CAN API V3 is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// CAN API V3 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with CAN API V3; if not, see . +// +#ifndef SERVER_H_INCLUDED +#define SERVER_H_INCLUDED + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include "Device.h" + +#include "CanTcpServer.h" +#include "CanTcpClient.h" + +class CCanServer : public CCanTcpServer { +public: + CCanServer(); + ~CCanServer(); + + bool AttachDevice(CCanDevice *device); + bool DetachDevice(); + + CANAPI_Return_t StartServer(const char *service); + CANAPI_Return_t StopServer(); + + void ShowServerPort(const char* prefix); +}; +#if (OPTION_CANTCP_ENABLED != 0) +// The one and only server object +extern CCanServer g_CanServer; +#endif +#endif // SERVER_H_INCLUDED + +// $Id: Server.h 1486 2025-03-02 15:50:07Z quaoar $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Sources/Timer.cpp b/Tests/Sources/Timer.cpp index 5a32538..f63775d 100644 --- a/Tests/Sources/Timer.cpp +++ b/Tests/Sources/Timer.cpp @@ -262,4 +262,44 @@ double CTimer::DiffTime(struct timespec start, struct timespec stop) { ((double)start.tv_sec + ((double)start.tv_nsec / 1000000000.f))); } -// $Id: Timer.cpp 841 2025-01-17 18:54:40Z quaoar $ Copyright (c) UV Software, Berlin // +static inline uint64_t abs_int64(int64_t x) { + return (x < 0) ? (uint64_t)(-x) : (uint64_t)x; +} + +uint64_t CTimer::DiffTimeInUsec(struct timespec start, struct timespec stop) { + int64_t sec_diff = (int64_t)(stop.tv_sec - start.tv_sec); + int64_t nsec_diff = (int64_t)(stop.tv_nsec - start.tv_nsec); + /* normalize time differences */ + if (nsec_diff < 0) { + sec_diff -= (int64_t)1; + nsec_diff += (int64_t)1000000000; + } + /* convert to microseconds (rounded up) */ + return abs_int64((sec_diff * (int64_t)1000000) + ((nsec_diff + (int64_t)500) / (int64_t)1000)); +} + +uint64_t CTimer::DiffTimeInMsec(struct timespec start, struct timespec stop) { + int64_t sec_diff = (int64_t)(stop.tv_sec - start.tv_sec); + int64_t nsec_diff = (int64_t)(stop.tv_nsec - start.tv_nsec); + /* normalize time differences */ + if (nsec_diff < 0) { + sec_diff -= (int64_t)1; + nsec_diff += (int64_t)1000000000; + } + // convert to milliseconds (rounded up) + return abs_int64((sec_diff * (int64_t)1000) + ((nsec_diff + (int64_t)500000) / (int64_t)1000000)); +} + +uint64_t CTimer::DiffTimeInSec(struct timespec start, struct timespec stop) { + int64_t sec_diff = (int64_t)(stop.tv_sec - start.tv_sec); + int64_t nsec_diff = (int64_t)(stop.tv_nsec - start.tv_nsec); + /* normalize time differences */ + if (nsec_diff < 0) { + sec_diff -= (int64_t)1; + nsec_diff += (int64_t)1000000000; + } + // convert to seconds (rounded up) + return abs_int64(sec_diff + ((nsec_diff + (int64_t)500000000) / (int64_t)1000000000)); +} + +// $Id: Timer.cpp 847 2025-02-22 12:50:44Z sedna $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/Timer.h b/Tests/Sources/Timer.h index dc6c1d1..ef48514 100644 --- a/Tests/Sources/Timer.h +++ b/Tests/Sources/Timer.h @@ -56,6 +56,7 @@ #include #include +#include #if defined(_WIN32) || defined(_WIN64) #include #endif @@ -88,8 +89,11 @@ class CTimer { static struct timespec GetTime(); // time with nanosecond resolution static double DiffTime(struct timespec start, struct timespec stop); + static uint64_t DiffTimeInUsec(struct timespec start, struct timespec stop); + static uint64_t DiffTimeInMsec(struct timespec start, struct timespec stop); + static uint64_t DiffTimeInSec(struct timespec start, struct timespec stop); }; #endif // TIMER_H_INCLUDED -// $Id: Timer.h 841 2025-01-17 18:54:40Z quaoar $ Copyright (c) UV Software, Berlin // +// $Id: Timer.h 847 2025-02-22 12:50:44Z sedna $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/main.cpp b/Tests/Sources/main.cpp index b298312..82751d6 100644 --- a/Tests/Sources/main.cpp +++ b/Tests/Sources/main.cpp @@ -50,9 +50,10 @@ #include #include #include "pch.h" +#include "anykey.h" GTEST_API_ int main(int argc, char **argv) { - std::cout << "CAN API V3 C++ Testing ("; + std::cout << "CAN API V3 C++ Testing (GoogleTest " << GTEST_VERSION << ", "; #if !defined(_MSC_VER) std::cout << __VERSION__ << ")" << std::endl; #else @@ -78,8 +79,33 @@ GTEST_API_ int main(int argc, char **argv) { else if (g_Options.ShowHelp()) { return 0; } +#if (OPTION_CANTCP_ENABLED != 0) + // --- start CAN server --- + if (g_Options.IsCanServerEnabled()) { + g_CanServer.SetLoggingLevel(g_Options.GetCanServerLoggingLevel()); + if (g_CanServer.StartServer(g_Options.GetCanServerService()) < 0) { + std::cerr << "+++ error: failed to start CAN server" << std::endl; + return 1; + } + } +#endif + // --- interactive start --- + if (g_Options.StartInteractive()) { + std::cout << "Press any key to start testing..."; + std::cout << std::flush; + (void)getkey(); + std::cout << std::endl; + } // --- test execution starts here -- - return RUN_ALL_TESTS(); + int res = RUN_ALL_TESTS(); +#if (OPTION_CANTCP_ENABLED != 0) + // --- stop CAN server --- + if (g_Options.IsCanServerEnabled()) { + g_CanServer.StopServer(); + } +#endif + // --- say goodbye --- + return res; } -// $Id: main.cpp 1411 2025-01-17 18:59:07Z quaoar $ Copyright (c) UV Software, Berlin // +// $Id: main.cpp 1541 2025-09-23 16:34:04Z quaoar $ Copyright (c) UV Software, Berlin // diff --git a/Tests/Sources/pch.h b/Tests/Sources/pch.h index 6614a7d..01ea365 100644 --- a/Tests/Sources/pch.h +++ b/Tests/Sources/pch.h @@ -30,5 +30,7 @@ #include "Progress.h" #include "Timer.h" #include "Version.h" - +#if (OPTION_CANTCP_ENABLED != 0) +#include "Server.h" +#endif #endif // PRECOMPILED_HEADERS_INCLUDED diff --git a/Tests/Testcases/TC00_SmokeTest.cc b/Tests/Testcases/TC00_SmokeTest.cc index c42fce0..25c4514 100644 --- a/Tests/Testcases/TC00_SmokeTest.cc +++ b/Tests/Testcases/TC00_SmokeTest.cc @@ -268,6 +268,9 @@ TEST_F(SmokeTest, DefaultScenario) { dut2.ShowDeviceInformation("[ DUT2 ]"); dut1.ShowOperationMode("[ MODE ]"); dut1.ShowBitrateSettings("[ BAUD ]"); +#if (OPTION_CANTCP_ENABLED != 0) + g_CanServer.ShowServerPort("[ PORT ]"); +#endif // @- probe if DUT1 is present and not occupied retVal = dut1.ProbeChannel(state); ASSERT_EQ(CCanApi::NoError, retVal) << "[ ERROR! ] dut1.ProbeChannel() failed with error code " << retVal; @@ -359,4 +362,4 @@ TEST_F(SmokeTest, DefaultScenario) { // @end. } -// $Id: TC00_SmokeTest.cc 1411 2025-01-17 18:59:07Z quaoar $ Copyright (c) UV Software, Berlin. +// $Id: TC00_SmokeTest.cc 1486 2025-03-02 15:50:07Z quaoar $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TC03_StartController.cc b/Tests/Testcases/TC03_StartController.cc index 9125c97..a43b463 100644 --- a/Tests/Testcases/TC03_StartController.cc +++ b/Tests/Testcases/TC03_StartController.cc @@ -2,7 +2,7 @@ // // CAN Interface API, Version 3 (Testing) // -// Copyright (c) 2004-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2004-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.com) // All rights reserved. // // This file is part of CAN API V3. @@ -870,7 +870,7 @@ TEST_F(StartController, GTEST_TESTCASE(WithDifferentCanBitrateIndexAfterCanStopp EXPECT_EQ(CCanApi::NoError, retVal); EXPECT_TRUE(status.can_stopped); // @test: - // @-- change bit-timing index: + // @-- change bit-timing index: CLEAR_BTR(bitrate); switch (i) { // @ - sub(3): index 8 (10kbps) ==> 0 (1Mbps) @@ -1362,7 +1362,7 @@ TEST_F(StartController, GTEST_TESTCASE(WithDifferentCanBitrateSettingsAfterCanSt EXPECT_EQ(CCanApi::NoError, retVal); EXPECT_TRUE(status.can_stopped); // @test: - // @-- change bit-timing index: + // @-- change bit-timing index: CLEAR_BTR(bitrate); switch (i) { // @ - sub(3): 10kbps ==> 1Mbps @@ -1916,7 +1916,7 @@ TEST_F(StartController, GTEST_TESTCASE(WithDifferentCanFdBitrateSettingsAfterCan EXPECT_EQ(CCanApi::NoError, retVal); EXPECT_TRUE(status.can_stopped); // @test: - // @-- change bit-timing index: + // @-- change bit-timing index: CLEAR_BTR(bitrate); switch (i) { // @ - sub(4): nominal 1Mbps ==> nominal 125kbps (mode FDOE) @@ -2315,4 +2315,4 @@ TEST_F(StartController, GTEST_TESTCASE(WithCanFdBitrateSettingsInCan20Mode, GTES } #endif // (CAN_FD_SUPPORTED == FEATURE_SUPPORTED) -// $Id: TC03_StartController.cc 1411 2025-01-17 18:59:07Z quaoar $ Copyright (c) UV Software, Berlin. +// $Id: TC03_StartController.cc 1598 2026-08-26 09:53:26Z quaoar $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TCx2_BitrateConverter.cc b/Tests/Testcases/TCx2_BitrateConverter.cc index 05428d1..136269a 100644 --- a/Tests/Testcases/TCx2_BitrateConverter.cc +++ b/Tests/Testcases/TCx2_BitrateConverter.cc @@ -2,7 +2,7 @@ // // CAN Interface API, Version 3 (Testing) // -// Copyright (c) 2004-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2004-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) // All rights reserved. // // This file is part of CAN API V3. @@ -256,7 +256,7 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToSpeedWithInvalidIndexes, GTEST_ // @note: This test is optional! if (!g_Options.RunTestBitrateConverter()) GTEST_SKIP() << "This test is optional: '--run_all=YES'"; - // @test: + // @test: CCounter counter = CCounter(); // @- sub(1): index = -10 counter.Increment(); @@ -306,7 +306,7 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToSpeedWithValidCan20Values, GTES // @note: This test is optional! if (!g_Options.RunTestBitrateConverter()) GTEST_SKIP() << "This test is optional: '--run_all=YES'"; - // @test: + // @test: // @- loop over valid CAN 2.0 bit-rate settings CCounter counter = CCounter(); for (int i = 0; i < 10; i++) { @@ -362,7 +362,7 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToSpeedWithInvalidCanValues, GTES // @note: This test is optional! if (!g_Options.RunTestBitrateConverter()) GTEST_SKIP() << "This test is optional: '--run_all=YES'"; - // @test: + // @test: // @- loop over invalid CAN 2.0 bit-rate settings CCounter counter = CCounter(); for (int i = 0; i < 16; i++) { @@ -432,7 +432,7 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToSpeedWithValidCanFdValues, GTES // @note: This test is optional! if (!g_Options.RunTestBitrateConverter()) GTEST_SKIP() << "This test is optional: '--run_all=YES'"; - // @test: + // @test: // @- loop over valid CAN FD bit-rate settings CCounter counter = CCounter(); for (int i = 0; i < 8; i++) { @@ -441,21 +441,21 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToSpeedWithValidCanFdValues, GTES CLEAR_BPS(speed); switch (i) { // @sub(1): nominal 1Mbps (mode FDOE) - case 0: DEFAULT_CAN_FD_BR_1M(bitrate); break; + case 0: BITRATE_FD_1M(bitrate); break; // @sub(2): nominal 500kbps (mode FDOE) - case 1: DEFAULT_CAN_FD_BR_500K(bitrate); break; + case 1: BITRATE_FD_500K(bitrate); break; // @sub(3): nominal 250kbps (mode FDOE) - case 2: DEFAULT_CAN_FD_BR_250K(bitrate); break; + case 2: BITRATE_FD_250K(bitrate); break; // @sub(4): nominal 125kbps (mode FDOE) - case 3: DEFAULT_CAN_FD_BR_125K(bitrate); break; + case 3: BITRATE_FD_125K(bitrate); break; // @sub(5): nominal 1Mbps, data phase 8Mbps (mode FDOE+BRSE) - case 4: DEFAULT_CAN_FD_BR_1M8M(bitrate); break; + case 4: BITRATE_FD_1M8M(bitrate); break; // @sub(6): nominal 500kbps, data phase 4Mbps (mode FDOE+BRSE) - case 5: DEFAULT_CAN_FD_BR_500K4M(bitrate); break; + case 5: BITRATE_FD_500K4M(bitrate); break; // @sub(7): nominal 250kbps, data phase 2Mbps (mode FDOE+BRSE) - case 6: DEFAULT_CAN_FD_BR_250K2M(bitrate); break; + case 6: BITRATE_FD_250K2M(bitrate); break; // @sub(8): nominal 125kbps, data phase 1Mbps (mode FDOE+BRSE) - case 7: DEFAULT_CAN_FD_BR_125K1M(bitrate); break; + case 7: BITRATE_FD_125K1M(bitrate); break; default: return; // Get out of here! } // @-- convert bit-rate settings into transmission rate @@ -484,14 +484,14 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToSpeedWithInvalidCanFdValues, GT // @note: This test is optional! if (!g_Options.RunTestBitrateConverter()) GTEST_SKIP() << "This test is optional: '--run_all=YES'"; - // @test: + // @test: // @- loop over invalid CAN FD bit-rate settings CCounter counter = CCounter(); for (int i = 0; i < 30; i++) { counter.Increment(); CLEAR_BTR(bitrate); CLEAR_BPS(speed); - DEFAULT_CAN_FD_BR_250K2M(bitrate); + BITRATE_FD_250K2M(bitrate); switch (i) { // @sub(1): set all fields to 0 (note: 'frequency' == 0 is CiA Index 0, set to 1 instead) case 0: bitrate.btr.frequency = 1; @@ -590,7 +590,7 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToSpeedWithDivisonByZero, GTEST_E // @note: This test is optional! if (!g_Options.RunTestBitrateConverter()) GTEST_SKIP() << "This test is optional: '--run_all=YES'"; - // @test: + // @test: CCounter counter = CCounter(); // @- sub(1): CAN 2.0 250 kbps with nominal BRP set to zero counter.Increment(); @@ -612,7 +612,7 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToSpeedWithDivisonByZero, GTEST_E counter.Increment(); CLEAR_BTR(bitrate); CLEAR_BPS(speed); - DEFAULT_CAN_FD_BR_250K2M(bitrate); + BITRATE_FD_250K2M(bitrate); bitrate.btr.data.brp = 0; // @-- convert bit-rate settings into transmission rate retVal = CCanDevice::MapBitrate2Speed(bitrate, speed); @@ -703,7 +703,7 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(IndexToBitrateWithInvalidIndexes, GTEST_ // @note: This test is optional! if (!g_Options.RunTestBitrateConverter()) GTEST_SKIP() << "This test is optional: '--run_all=YES'"; - // @test: + // @test: CCounter counter = CCounter(); // @- sub(1): index = -10 counter.Increment(); @@ -983,7 +983,7 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToStringFromInvalidIndexes, GTEST // @note: This test is optional! if (!g_Options.RunTestBitrateConverter()) GTEST_SKIP() << "This test is optional: '--run_all=YES'"; - // @test: + // @test: char buffer[CANPROP_MAX_BUFFER_SIZE] = ""; CCounter counter = CCounter(); // @- sub(1): index = -10 @@ -1167,13 +1167,13 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToStringFromValidCanFdValuesBrsDi CLEAR_BTR(target); switch (i) { // @sub(1): nominal 1Mbps (mode FDOE) - case 0: DEFAULT_CAN_FD_BR_1M(source); break; + case 0: BITRATE_FD_1M(source); break; // @sub(2): nominal 500kbps (mode FDOE) - case 1: DEFAULT_CAN_FD_BR_500K(source); break; + case 1: BITRATE_FD_500K(source); break; // @sub(3): nominal 250kbps (mode FDOE) - case 2: DEFAULT_CAN_FD_BR_250K(source); break; + case 2: BITRATE_FD_250K(source); break; // @sub(4): nominal 125kbps (mode FDOE) - case 3: DEFAULT_CAN_FD_BR_125K(source); break; + case 3: BITRATE_FD_125K(source); break; default: return; // Get out of here! } // @- convert index to bit-timing table to string @@ -1213,7 +1213,7 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToStringFromInvalidCanFdValuesBrs counter.Increment(); CLEAR_BTR(source); CLEAR_BTR(target); - DEFAULT_CAN_FD_BR_250K(source); + BITRATE_FD_250K(source); switch (i) { // @sub(1): set all fields to 0 (note: 'frequency' == 0 is CiA Index 0, set to 1 instead) case 0: source.btr.frequency = 1; @@ -1304,13 +1304,13 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToStringFromValidCanFdValuesBrsEn CLEAR_BTR(target); switch (i) { // @sub(1): nominal 1Mbps, data phase 8Mbps (mode FDOE+BRSE) - case 0: DEFAULT_CAN_FD_BR_1M8M(source); break; + case 0: BITRATE_FD_1M8M(source); break; // @sub(2): nominal 500kbps, data phase 4Mbps (mode FDOE+BRSE) - case 1: DEFAULT_CAN_FD_BR_500K4M(source); break; + case 1: BITRATE_FD_500K4M(source); break; // @sub(3): nominal 250kbps, data phase 2Mbps (mode FDOE+BRSE) - case 2: DEFAULT_CAN_FD_BR_250K2M(source); break; + case 2: BITRATE_FD_250K2M(source); break; // @sub(4): nominal 125kbps, data phase 1Mbps (mode FDOE+BRSE) - case 3: DEFAULT_CAN_FD_BR_125K1M(source); break; + case 3: BITRATE_FD_125K1M(source); break; default: return; // Get out of here! } // @- convert index to bit-timing table to string @@ -1350,7 +1350,7 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToStringFromInvalidCanFdValuesBrs counter.Increment(); CLEAR_BTR(source); CLEAR_BTR(target); - DEFAULT_CAN_FD_BR_250K2M(source); + BITRATE_FD_250K2M(source); switch (i) { // @sub(1): set all fields to 0 (note: 'frequency' == 0 is CiA Index 0, set to 1 instead) case 0: source.btr.frequency = 1; @@ -1605,4 +1605,4 @@ TEST_F(BitrateConverter, GTEST_TESTCASE(BitrateToStringWithNullPointerForString, // // @note: passing a pointer for 'btr0btr1' is not possible with the C++ API! -// $Id: TCx2_BitrateConverter.cc 1411 2025-01-17 18:59:07Z quaoar $ Copyright (c) UV Software, Berlin. +// $Id: TCx2_BitrateConverter.cc 1600 2026-08-27 16:08:37Z quaoar $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Testcases/TCxX_Summary.cc b/Tests/Testcases/TCxX_Summary.cc index 59f31e6..237f652 100644 --- a/Tests/Testcases/TCxX_Summary.cc +++ b/Tests/Testcases/TCxX_Summary.cc @@ -58,6 +58,40 @@ class Summary : public testing::Test { // ... }; +// @gtest TCxX.0: Get test information +// +// @expected: CANERR_NOERROR +// +TEST_F(Summary, GTEST_TESTCASE(GetTestInformation, GTEST_ENABLED)) { + // @ + // @note: This test is optional! + if (!g_Options.RunTestBitrateConverter()) + GTEST_SKIP() << "This test is optional: '--run_all=YES'"; + // @test: + RecordProperty("GoogleTestVersion", GTEST_VERSION); + RecordProperty("TestSuiteRevision", REVISION_NO); +#if (OPTION_REGESSION_TEST != 0) + RecordProperty("RegressionText", "Enabled"); +#else + RecordProperty("RegressionTest", "Disabled"); +#endif +#if (OPTION_CANAPI_RETVALS != 0) + RecordProperty("CanApiRetVals", "Enabled"); +#else + RecordProperty("CanApiRetVals", "Disabled"); +#endif +#if (OPTION_CAN_2_0_ONLY != 0) + RecordProperty("Can2.0Only", "Enabled"); +#else + RecordProperty("Can2.0Only", "Disabled"); +#endif + RecordProperty("TestFrames", g_Options.GetNumberOfTestFrames()); + RecordProperty("SmoketestFrames", g_Options.GetNumberOfSmokeTestFrames()); + RecordProperty("ClassicalCAN", g_Options.RunCanClassicOnly() ? "Yes" : "No"); + RecordProperty("3rdDevice", g_Options.Is3rdDevicePresent() ? "Yes" : "No"); + RecordProperty("RtrDevice", g_Options.IsRtrDevicePresent() ? "Yes" : "No"); + // @end. +} // @gtest TCxX.1: Get library information // // @expected: CANERR_NOERROR @@ -145,31 +179,31 @@ TEST_F(Summary, GTEST_TESTCASE(GetLibraryInformation, GTEST_ENABLED)) { #else RecordProperty("OperationMode", "CAN CC (2.0)"); #endif - // @ regested bit-rate settings + // @ requested bit-rate settings bitrate = g_Options.GetBitrate(DUT1); if (CCanDevice::MapBitrate2Speed(bitrate, speed) == CCanApi::NoError) { #if (OPTION_CAN_2_0_ONLY == 0) if (opMode.fdoe) { - snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u)\n", + snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u)", speed.nominal.speed / 1000.f, speed.nominal.samplepoint * 100.f, bitrate.btr.nominal.sjw); string[CANPROP_MAX_BUFFER_SIZE] = '\0'; RecordProperty("BusSpeed.Nominal", string); - snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u)\n", + snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u)", speed.data.speed / 1000.f, speed.data.samplepoint * 100.f, bitrate.btr.data.sjw); string[CANPROP_MAX_BUFFER_SIZE] = '\0'; RecordProperty("BusSpeed.DataPhase", string); } else { - snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u, SAM=%u)\n", + snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u, SAM=%u)", speed.nominal.speed / 1000.f, speed.nominal.samplepoint * 100.f, bitrate.btr.nominal.sjw, bitrate.btr.nominal.sam); string[CANPROP_MAX_BUFFER_SIZE] = '\0'; RecordProperty("BusSpeed.Nominal", string); } #else - snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u, SAM=%u)\n", + snprintf(string, CANPROP_MAX_BUFFER_SIZE, "%.3f kbps (SP=%.2f%%, SJW=%u, SAM=%u)", speed.nominal.speed / 1000.f, speed.nominal.samplepoint * 100.f, bitrate.btr.nominal.sjw, bitrate.btr.nominal.sam); string[CANPROP_MAX_BUFFER_SIZE] = '\0'; @@ -429,4 +463,4 @@ TEST_F(Summary, GTEST_TESTCASE(GetDevice2Information, GTEST_ENABLED)) { // @end. } -// $Id: TCxX_Summary.cc 1411 2025-01-17 18:59:07Z quaoar $ Copyright (c) UV Software, Berlin. +// $Id: TCxX_Summary.cc 1541 2025-09-23 16:34:04Z quaoar $ Copyright (c) UV Software, Berlin. diff --git a/Tests/Version.h b/Tests/Version.h index 159323d..4f6b427 100644 --- a/Tests/Version.h +++ b/Tests/Version.h @@ -2,7 +2,7 @@ // // CAN Interface API, Version 3 (Testing) // -// Copyright (c) 2004-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2004-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) // All rights reserved. // // This file is part of CAN API V3. @@ -49,8 +49,10 @@ // #ifndef VERSION_H_INCLUDED #define VERSION_H_INCLUDED -// SVN revision number (update with each commit: XXXIV) -#define REVISION_NO "$Rev: 1412 $" +// SVN revision number (update with each commit: XXXVIII) +#define REVISION_NO "$Rev: 1600 $" +// GoogleTest does not offer its own version number +#define GTEST_VERSION "1.18.0" #endif // VERSION_H_INCLUDED -// $Id: Version.h 1412 2025-01-17 19:04:10Z quaoar $ Copyright (c) UV Software, Berlin // +// $Id: Version.h 1600 2026-08-27 16:08:37Z quaoar $ Copyright (c) UV Software, Berlin // diff --git a/Tests/pcb_testing.vcxproj b/Tests/pcb_testing.vcxproj index 6bc6e68..a77ed63 100644 --- a/Tests/pcb_testing.vcxproj +++ b/Tests/pcb_testing.vcxproj @@ -1,10 +1,6 @@ - - Debug - Win32 - Debug x64 @@ -18,12 +14,6 @@ 10.0 - - Application - true - v143 - Unicode - Application true @@ -35,30 +25,10 @@ - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;OPTION_CAN_2_0_ONLY=0;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_RETVALS=0;OPTION_CANCPP_DLLEXPORT=0;OPTION_REGESSION_TEST=0;%(PreprocessorDefinitions) - true - .;.\Sources;..\Includes;.\GoogleTest\include;%(AdditionalIncludeDirectories) - MultiThreadedDebug - Use - pch.h - - - Console - true - .\GoogleTest\Windows\x86-Debug\lib\gtest.lib;..\Binaries\x86\lib\Debug\uvPeakCAN.lib;..\Binaries\x86\lib\Debug\PCANBasic.lib;%(AdditionalDependencies) - - Level3 @@ -66,32 +36,33 @@ _DEBUG;_CONSOLE;OPTION_CAN_2_0_ONLY=0;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_RETVALS=0;OPTION_CANCPP_DLLEXPORT=0;OPTION_REGESSION_TEST=0;%(PreprocessorDefinitions) true .;.\Sources;..\Includes;.\GoogleTest\include;%(AdditionalIncludeDirectories) - MultiThreadedDebug + MultiThreadedDebugDLL Use pch.h + stdcpp17 Console true - .\GoogleTest\Windows\x64-Debug\lib\gtest.lib;..\Binaries\x64\lib\Debug\uvPeakCAN.lib;..\Binaries\x64\lib\Debug\PCANBasic.lib;%(AdditionalDependencies) + .\GoogleTest\Windows\lib\Debug\gtest.lib;..\Binaries\x64\lib\Debug\uvPeakCAN.lib;..\Binaries\x64\lib\Debug\PCANBasic.lib;%(AdditionalDependencies) + + NotUsing + - Create Create - NotUsing NotUsing - NotUsing NotUsing @@ -121,6 +92,7 @@ + @@ -128,8 +100,10 @@ + + diff --git a/Tests/pcb_testing.vcxproj.filters b/Tests/pcb_testing.vcxproj.filters index 2d12e8c..7ab0efd 100644 --- a/Tests/pcb_testing.vcxproj.filters +++ b/Tests/pcb_testing.vcxproj.filters @@ -99,6 +99,9 @@ Source Files\Testcases + + Source Files + @@ -152,5 +155,14 @@ Header Files + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/Tests/x86_build.bat b/Tests/x86_build.bat deleted file mode 100644 index 2805e3a..0000000 --- a/Tests/x86_build.bat +++ /dev/null @@ -1,35 +0,0 @@ -@echo off - -set VCVARS="True" -set NORUN="False" - -rem parse arguments: [NOVARS] [NORUN] -:LOOP -if "%1" == "NOVARS" set VCVARS="False" -if "%1" == "NORUN" set NORUN="True" -SHIFT -if not "%1" == "" goto LOOP - -rem set MSBuild environment variables -if %VCVARS% == "True" ( - pushd - call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat" x86 - popd -) -pushd - -rem build the test suites -call msbuild.exe .\pcb_testing.vcxproj /t:Clean;Build /p:"Configuration=Debug";"Platform=Win32" -if errorlevel 1 goto end - -rem execute the smoke-test -if %NORUN% == "False" ( - call .\Debug\pcb_testing.exe --gtest_filter=SmokeTest.* -) - -rem end of the job -:end -popd -if %VCVARS% == "True" ( - pause -) diff --git a/Tests/x86_prompt.bat b/Tests/x86_prompt.bat deleted file mode 100644 index 716db5c..0000000 --- a/Tests/x86_prompt.bat +++ /dev/null @@ -1,3 +0,0 @@ -@pushd -@call %comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat" x86 %* -@popd \ No newline at end of file diff --git a/Trial/Sources/main.cpp b/Trial/Sources/main.cpp index c875a04..7148150 100644 --- a/Trial/Sources/main.cpp +++ b/Trial/Sources/main.cpp @@ -48,7 +48,6 @@ #define BITRATE_10K(x) DEFAULT_CAN_BR_10K(x) #define BITRATE_5K(x) DEFAULT_CAN_BR_5K(x) #endif -#if (OPTION_PCAN_BIT_TIMING == 1) #define BITRATE_FD_1M(x) PEAKCAN_FD_BR_1M(x) #define BITRATE_FD_500K(x) PEAKCAN_FD_BR_500K(x) #define BITRATE_FD_250K(x) PEAKCAN_FD_BR_250K(x) @@ -57,16 +56,7 @@ #define BITRATE_FD_500K4M(x) PEAKCAN_FD_BR_500K4M(x) #define BITRATE_FD_250K2M(x) PEAKCAN_FD_BR_250K2M(x) #define BITRATE_FD_125K1M(x) PEAKCAN_FD_BR_125K1M(x) -#else -#define BITRATE_FD_1M(x) DEFAULT_CAN_FD_BR_1M(x) -#define BITRATE_FD_500K(x) DEFAULT_CAN_FD_BR_500K(x) -#define BITRATE_FD_250K(x) DEFAULT_CAN_FD_BR_250K(x) -#define BITRATE_FD_125K(x) DEFAULT_CAN_FD_BR_125K(x) -#define BITRATE_FD_1M8M(x) DEFAULT_CAN_FD_BR_1M8M(x) -#define BITRATE_FD_500K4M(x) DEFAULT_CAN_FD_BR_500K4M(x) -#define BITRATE_FD_250K2M(x) DEFAULT_CAN_FD_BR_250K2M(x) -#define BITRATE_FD_125K1M(x) DEFAULT_CAN_FD_BR_125K1M(x) -#endif + #define OPTION_NO (0) #define OPTION_YES (1) diff --git a/Trial/pcb_test.vcxproj b/Trial/pcb_test.vcxproj index 82b84be..c1d1fd6 100644 --- a/Trial/pcb_test.vcxproj +++ b/Trial/pcb_test.vcxproj @@ -1,10 +1,6 @@ - - Debug - Win32 - Debug x64 @@ -18,12 +14,6 @@ 10.0 - - Application - true - v143 - Unicode - Application true @@ -35,27 +25,10 @@ - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CAN_2_0_ONLY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_DLLIMPORT=0;OPTION_CANAPI_COMPANIONS=1;OPTION_CANAPI_RETVALS=0 - true - ..\Sources;..\Sources;..\Sources\CANAPI;..\Sources\PCANBasic;..\Sources\Wrapper;%(AdditionalIncludeDirectories) - - - Console - true - ..\Sources\PCANBasic\x86\PCANBasic.lib;%(AdditionalDependencies) - - Level3 diff --git a/Utilities/can_moni/Driver.h b/Utilities/can_moni/Driver.h index 08d128b..a16a45f 100644 --- a/Utilities/can_moni/Driver.h +++ b/Utilities/can_moni/Driver.h @@ -2,7 +2,7 @@ // // CAN Monitor for PEAK-System PCAN Interfaces (CAN API V3) // -// Copyright (c) 2007,2012-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2007,2012-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ #else #define MONITOR_INTERFACE "PEAK-System PCAN USB Interfaces" #endif -#define MONITOR_COPYRIGHT "2007,2012-2025 by Uwe Vogt, UV Software, Berlin" +#define MONITOR_COPYRIGHT "2007,2012-2026 by Uwe Vogt, UV Software, Berlin" #if defined(_WIN32) || defined(_WIN64) #define MONITOR_PLATFORM "Windows" #elif defined(__linux__) @@ -67,7 +67,6 @@ #define BITRATE_5K(x) DEFAULT_CAN_BR_5K(x) #endif #if (CAN_FD_SUPPORTED != 0) -#if (OPTION_PCAN_BIT_TIMING == 1) #define BITRATE_FD_1M(x) PEAKCAN_FD_BR_1M(x) #define BITRATE_FD_500K(x) PEAKCAN_FD_BR_500K(x) #define BITRATE_FD_250K(x) PEAKCAN_FD_BR_250K(x) @@ -76,16 +75,6 @@ #define BITRATE_FD_500K4M(x) PEAKCAN_FD_BR_500K4M(x) #define BITRATE_FD_250K2M(x) PEAKCAN_FD_BR_250K2M(x) #define BITRATE_FD_125K1M(x) PEAKCAN_FD_BR_125K1M(x) -#else -#define BITRATE_FD_1M(x) DEFAULT_CAN_FD_BR_1M(x) -#define BITRATE_FD_500K(x) DEFAULT_CAN_FD_BR_500K(x) -#define BITRATE_FD_250K(x) DEFAULT_CAN_FD_BR_250K(x) -#define BITRATE_FD_125K(x) DEFAULT_CAN_FD_BR_125K(x) -#define BITRATE_FD_1M8M(x) DEFAULT_CAN_FD_BR_1M8M(x) -#define BITRATE_FD_500K4M(x) DEFAULT_CAN_FD_BR_500K4M(x) -#define BITRATE_FD_250K2M(x) DEFAULT_CAN_FD_BR_250K2M(x) -#define BITRATE_FD_125K1M(x) DEFAULT_CAN_FD_BR_125K1M(x) -#endif #endif typedef CPeakCAN CCanDriver; diff --git a/Utilities/can_moni/README.md b/Utilities/can_moni/README.md index 4969169..1911cc3 100644 --- a/Utilities/can_moni/README.md +++ b/Utilities/can_moni/README.md @@ -1,5 +1,5 @@ -__CAN Monitor for PEAK-System PCAN Interfaces, Version 0.6__ \ -Copyright © 2007,2012-2025 by Uwe Vogt, UV Software, Berlin +__CAN Monitor for PEAK-System PCAN Interfaces, Version 0.6.1__ \ +Copyright © 2007,2012-2026 by Uwe Vogt, UV Software, Berlin ``` Usage: can_moni [ - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - Application true @@ -57,12 +36,6 @@ - - - - - - @@ -70,39 +43,6 @@ - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANCPP_DLLIMPORT=0;OPTION_CANAPI_DLLIMPORT=0;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CAN_2_0_ONLY=0 - true - .;.\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\Wrapper;..\..\Sources\PCANBasic;%(AdditionalIncludeDirectories) - MultiThreadedDebug - - - Console - true - ..\..\Binaries\x86\lib\Debug\uvPeakCAN.lib;..\..\Binaries\x86\lib\Debug\PCANBasic.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANCPP_DLLIMPORT=0;OPTION_CANAPI_DLLIMPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CAN_2_0_ONLY=0 - true - .;.\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\Wrapper;..\..\Sources\PCANBasic;%(AdditionalIncludeDirectories) - - - Console - true - true - true - ..\..\Binaries\x86\uvPeakCAN.lib;%(AdditionalDependencies) - - Level3 @@ -110,7 +50,7 @@ _DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANCPP_DLLIMPORT=0;OPTION_CANAPI_DLLIMPORT=0;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CAN_2_0_ONLY=0 true .;.\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\Wrapper;..\..\Sources\PCANBasic;%(AdditionalIncludeDirectories) - MultiThreadedDebug + MultiThreadedDebugDLL Console diff --git a/Utilities/can_send/Driver.h b/Utilities/can_send/Driver.h index 5a7a17d..1b87095 100644 --- a/Utilities/can_send/Driver.h +++ b/Utilities/can_send/Driver.h @@ -2,7 +2,7 @@ // // CAN Sender for PEAK-System PCAN Interfaces (CAN API V3) // -// Copyright (c) 2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2025-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ #else #define SENDER_INTERFACE "PEAK-System PCAN USB Interfaces" #endif -#define SENDER_COPYRIGHT "2025 by Uwe Vogt, UV Software, Berlin" +#define SENDER_COPYRIGHT "2025-2026 by Uwe Vogt, UV Software, Berlin" #if defined(_WIN32) || defined(_WIN64) #define SENDER_PLATFORM "Windows" #elif defined(__linux__) @@ -67,7 +67,6 @@ #define BITRATE_5K(x) DEFAULT_CAN_BR_5K(x) #endif #if (CAN_FD_SUPPORTED != 0) -#if (OPTION_PCAN_BIT_TIMING == 1) #define BITRATE_FD_1M(x) PEAKCAN_FD_BR_1M(x) #define BITRATE_FD_500K(x) PEAKCAN_FD_BR_500K(x) #define BITRATE_FD_250K(x) PEAKCAN_FD_BR_250K(x) @@ -76,16 +75,6 @@ #define BITRATE_FD_500K4M(x) PEAKCAN_FD_BR_500K4M(x) #define BITRATE_FD_250K2M(x) PEAKCAN_FD_BR_250K2M(x) #define BITRATE_FD_125K1M(x) PEAKCAN_FD_BR_125K1M(x) -#else -#define BITRATE_FD_1M(x) DEFAULT_CAN_FD_BR_1M(x) -#define BITRATE_FD_500K(x) DEFAULT_CAN_FD_BR_500K(x) -#define BITRATE_FD_250K(x) DEFAULT_CAN_FD_BR_250K(x) -#define BITRATE_FD_125K(x) DEFAULT_CAN_FD_BR_125K(x) -#define BITRATE_FD_1M8M(x) DEFAULT_CAN_FD_BR_1M8M(x) -#define BITRATE_FD_500K4M(x) DEFAULT_CAN_FD_BR_500K4M(x) -#define BITRATE_FD_250K2M(x) DEFAULT_CAN_FD_BR_250K2M(x) -#define BITRATE_FD_125K1M(x) DEFAULT_CAN_FD_BR_125K1M(x) -#endif #endif typedef CPeakCAN CCanDriver; diff --git a/Utilities/can_send/README.md b/Utilities/can_send/README.md index bd54b8c..288eec4 100644 --- a/Utilities/can_send/README.md +++ b/Utilities/can_send/README.md @@ -1,5 +1,5 @@ -__CAN Sender for PEAK-System PCAN Interfaces, Version 0.4__ \ -Copyright © 2025 by Uwe Vogt, UV Software, Berlin +__CAN Sender for PEAK-System PCAN Interfaces, Version 0.6.1__ \ +Copyright © 2025-2026 by Uwe Vogt, UV Software, Berlin ``` Usage: can_send [ - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - Application true @@ -57,12 +36,6 @@ - - - - - - @@ -70,39 +43,6 @@ - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANCPP_DLLIMPORT=0;OPTION_CANAPI_DLLIMPORT=0;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CAN_2_0_ONLY=0 - true - .;.\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\Wrapper;..\..\Sources\PCANBasic;%(AdditionalIncludeDirectories) - MultiThreadedDebug - - - Console - true - ..\..\Binaries\x86\lib\Debug\uvPeakCAN.lib;..\..\Binaries\x86\lib\Debug\PCANBasic.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANCPP_DLLIMPORT=0;OPTION_CANAPI_DLLIMPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CAN_2_0_ONLY=0 - true - .;.\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\Wrapper;..\..\Sources\PCANBasic;%(AdditionalIncludeDirectories) - - - Console - true - true - true - ..\..\Binaries\x86\uvPeakCAN.lib;%(AdditionalDependencies) - - Level3 @@ -110,7 +50,7 @@ _DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANCPP_DLLIMPORT=0;OPTION_CANAPI_DLLIMPORT=0;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CAN_2_0_ONLY=0 true .;.\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\Wrapper;..\..\Sources\PCANBasic;%(AdditionalIncludeDirectories) - MultiThreadedDebug + MultiThreadedDebugDLL Console diff --git a/Utilities/can_test/Driver.h b/Utilities/can_test/Driver.h index 592ac22..71f1e25 100644 --- a/Utilities/can_test/Driver.h +++ b/Utilities/can_test/Driver.h @@ -3,7 +3,7 @@ // CAN Tester for for PEAK-System PCAN Interfaces (CAN API V3) // // Copyright (c) 2005-2010 Uwe Vogt, UV Software, Friedrichshafen -// Copyright (c) 2012-2025 Uwe Vogt, UV Software, Berlin (info@uv-software.com) +// Copyright (c) 2012-2026 Uwe Vogt, UV Software, Berlin (info@uv-software.de) // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ #else #define TESTER_INTERFACE "PEAK-System PCAN USB Interfaces" #endif -#define TESTER_COPYRIGHT "2005-2010,2012-2025 by Uwe Vogt, UV Software, Berlin" +#define TESTER_COPYRIGHT "2005-2010,2012-2026 by Uwe Vogt, UV Software, Berlin" #if defined(_WIN32) || defined(_WIN64) #define TESTER_PLATFORM "Windows" #elif defined(__linux__) @@ -68,7 +68,6 @@ #define BITRATE_5K(x) DEFAULT_CAN_BR_5K(x) #endif #if (CAN_FD_SUPPORTED != 0) -#if (OPTION_PCAN_BIT_TIMING == 1) #define BITRATE_FD_1M(x) PEAKCAN_FD_BR_1M(x) #define BITRATE_FD_500K(x) PEAKCAN_FD_BR_500K(x) #define BITRATE_FD_250K(x) PEAKCAN_FD_BR_250K(x) @@ -77,16 +76,6 @@ #define BITRATE_FD_500K4M(x) PEAKCAN_FD_BR_500K4M(x) #define BITRATE_FD_250K2M(x) PEAKCAN_FD_BR_250K2M(x) #define BITRATE_FD_125K1M(x) PEAKCAN_FD_BR_125K1M(x) -#else -#define BITRATE_FD_1M(x) DEFAULT_CAN_FD_BR_1M(x) -#define BITRATE_FD_500K(x) DEFAULT_CAN_FD_BR_500K(x) -#define BITRATE_FD_250K(x) DEFAULT_CAN_FD_BR_250K(x) -#define BITRATE_FD_125K(x) DEFAULT_CAN_FD_BR_125K(x) -#define BITRATE_FD_1M8M(x) DEFAULT_CAN_FD_BR_1M8M(x) -#define BITRATE_FD_500K4M(x) DEFAULT_CAN_FD_BR_500K4M(x) -#define BITRATE_FD_250K2M(x) DEFAULT_CAN_FD_BR_250K2M(x) -#define BITRATE_FD_125K1M(x) DEFAULT_CAN_FD_BR_125K1M(x) -#endif #endif typedef CPeakCAN CCanDriver; diff --git a/Utilities/can_test/README.md b/Utilities/can_test/README.md index 3ef2565..4858585 100644 --- a/Utilities/can_test/README.md +++ b/Utilities/can_test/README.md @@ -1,5 +1,5 @@ -__CAN Tester for PEAK-System PCAN Interfaces, Version 0.6__ \ -Copyright © 2005-2010,2012-2025 by Uwe Vogt, UV Software, Berlin +__CAN Tester for PEAK-System PCAN Interfaces, Version 0.6.1__ \ +Copyright © 2005-2010,2012-2026 by Uwe Vogt, UV Software, Berlin ``` Usage: can_test [ - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - Application true @@ -57,12 +36,6 @@ - - - - - - @@ -70,39 +43,6 @@ - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANCPP_DLLIMPORT=0;OPTION_CANAPI_DLLIMPORT=0;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CAN_2_0_ONLY=0 - true - .;.\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\Wrapper;..\..\Sources\PCANBasic;%(AdditionalIncludeDirectories) - MultiThreadedDebug - - - Console - true - ..\..\Binaries\x86\lib\Debug\uvPeakCAN.lib;..\..\Binaries\x86\lib\Debug\PCANBasic.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANCPP_DLLIMPORT=0;OPTION_CANAPI_DLLIMPORT=1;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CAN_2_0_ONLY=0 - true - .;.\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\Wrapper;..\..\Sources\PCANBasic;%(AdditionalIncludeDirectories) - - - Console - true - true - true - ..\..\Binaries\x86\uvPeakCAN.lib;%(AdditionalDependencies) - - Level3 @@ -110,7 +50,7 @@ _DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;OPTION_CANCPP_DLLIMPORT=0;OPTION_CANAPI_DLLIMPORT=0;OPTION_CANAPI_LIBRARY=0;OPTION_CANAPI_DRIVER=1;OPTION_CANAPI_COMPANIONS=1;OPTION_CAN_2_0_ONLY=0 true .;.\Sources;..\..\Sources;..\..\Sources\CANAPI;..\..\Sources\Wrapper;..\..\Sources\PCANBasic;%(AdditionalIncludeDirectories) - MultiThreadedDebug + MultiThreadedDebugDLL Console diff --git a/Utilities/can_util.sln b/Utilities/can_util.sln index 643fda0..1a6ebdc 100644 --- a/Utilities/can_util.sln +++ b/Utilities/can_util.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.13.35818.85 d17.13 +VisualStudioVersion = 17.13.35818.85 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "can_moni", "can_moni\can_moni.vcxproj", "{993FEAEA-604C-4116-AC57-3EB2A7DDF9E6}" EndProject @@ -12,35 +12,21 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Release|x64 = Release|x64 - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {993FEAEA-604C-4116-AC57-3EB2A7DDF9E6}.Debug|x64.ActiveCfg = Debug|x64 {993FEAEA-604C-4116-AC57-3EB2A7DDF9E6}.Debug|x64.Build.0 = Debug|x64 - {993FEAEA-604C-4116-AC57-3EB2A7DDF9E6}.Debug|x86.ActiveCfg = Debug|Win32 - {993FEAEA-604C-4116-AC57-3EB2A7DDF9E6}.Debug|x86.Build.0 = Debug|Win32 {993FEAEA-604C-4116-AC57-3EB2A7DDF9E6}.Release|x64.ActiveCfg = Release|x64 {993FEAEA-604C-4116-AC57-3EB2A7DDF9E6}.Release|x64.Build.0 = Release|x64 - {993FEAEA-604C-4116-AC57-3EB2A7DDF9E6}.Release|x86.ActiveCfg = Release|Win32 - {993FEAEA-604C-4116-AC57-3EB2A7DDF9E6}.Release|x86.Build.0 = Release|Win32 {6165B0F0-9948-4FED-80D6-90E8133E1C0F}.Debug|x64.ActiveCfg = Debug|x64 {6165B0F0-9948-4FED-80D6-90E8133E1C0F}.Debug|x64.Build.0 = Debug|x64 - {6165B0F0-9948-4FED-80D6-90E8133E1C0F}.Debug|x86.ActiveCfg = Debug|Win32 - {6165B0F0-9948-4FED-80D6-90E8133E1C0F}.Debug|x86.Build.0 = Debug|Win32 {6165B0F0-9948-4FED-80D6-90E8133E1C0F}.Release|x64.ActiveCfg = Release|x64 {6165B0F0-9948-4FED-80D6-90E8133E1C0F}.Release|x64.Build.0 = Release|x64 - {6165B0F0-9948-4FED-80D6-90E8133E1C0F}.Release|x86.ActiveCfg = Release|Win32 - {6165B0F0-9948-4FED-80D6-90E8133E1C0F}.Release|x86.Build.0 = Release|Win32 {E5266B37-62FA-45A1-AB3F-95F772072A9E}.Debug|x64.ActiveCfg = Debug|x64 {E5266B37-62FA-45A1-AB3F-95F772072A9E}.Debug|x64.Build.0 = Debug|x64 - {E5266B37-62FA-45A1-AB3F-95F772072A9E}.Debug|x86.ActiveCfg = Debug|Win32 - {E5266B37-62FA-45A1-AB3F-95F772072A9E}.Debug|x86.Build.0 = Debug|Win32 {E5266B37-62FA-45A1-AB3F-95F772072A9E}.Release|x64.ActiveCfg = Release|x64 {E5266B37-62FA-45A1-AB3F-95F772072A9E}.Release|x64.Build.0 = Release|x64 - {E5266B37-62FA-45A1-AB3F-95F772072A9E}.Release|x86.ActiveCfg = Release|Win32 - {E5266B37-62FA-45A1-AB3F-95F772072A9E}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/x86_build.bat b/x86_build.bat deleted file mode 100644 index 4cfe24c..0000000 --- a/x86_build.bat +++ /dev/null @@ -1,129 +0,0 @@ -@echo off - -set VCVARS="True" -set TRIAL="True" -set LIBDB="True" -set UTILS="True" - -rem parse arguments: [NOVARS] [NOTRIAL] [NODEBUG] [NOUTILS] -:LOOP -if "%1" == "NOVARS" set VCVARS="False" -if "%1" == "NOTRIAL" set TRIAL="False" -if "%1" == "NODEBUG" set LIBDB="False" -if "%1" == "NOUTILS" set UTILS="False" -SHIFT -if not "%1" == "" goto LOOP - -rem set MSBuild environment variables -if %VCVARS% == "True" ( - pushd - call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat" x86 - popd -) -pushd - -rem generate a pseudo build number -call build_no.bat - -rem build the trial program -if %TRIAL% == "True" ( - call msbuild.exe .\Trial\pcb_test.vcxproj /t:Clean;Build /p:"Configuration=Debug";"Platform=Win32" - if errorlevel 1 goto end -) -rem build the CAN API V3 C library (dynamic and static) -call msbuild.exe .\Libraries\CANAPI\uvcanpcb.vcxproj /t:Clean;Build /p:"Configuration=Release_dll";"Platform=Win32" -if errorlevel 1 goto end - -call msbuild.exe .\Libraries\CANAPI\uvcanpcb.vcxproj /t:Clean;Build /p:"Configuration=Release_lib";"Platform=Win32" -if errorlevel 1 goto end - -if %LIBDB% == "True" ( - call msbuild.exe .\Libraries\CANAPI\uvcanpcb.vcxproj /t:Clean;Build /p:"Configuration=Debug_lib";"Platform=Win32" - if errorlevel 1 goto end -) -rem build the CAN API V3 C++ library (dynamic and static) -call msbuild.exe .\Libraries\PeakCAN\PeakCAN.vcxproj /t:Clean;Build /p:"Configuration=Release_dll";"Platform=Win32" -if errorlevel 1 goto end - -call msbuild.exe .\Libraries\PeakCAN\PeakCAN.vcxproj /t:Clean;Build /p:"Configuration=Release_lib";"Platform=Win32" -if errorlevel 1 goto end - -if %LIBDB% == "True" ( - call msbuild.exe .\Libraries\PeakCAN\PeakCAN.vcxproj /t:Clean;Build /p:"Configuration=Debug_lib";"Platform=Win32" - if errorlevel 1 goto end -) -rem copy the arifacts into the Binaries folder -set BIN=.\Binaries -if not exist %BIN% mkdir %BIN% -set BIN=%BIN%\x86 -if not exist %BIN% mkdir %BIN% -echo Copying dynamic libraries... -copy /Y .\Libraries\CANAPI\Release_dll\u3canpcb.dll %BIN% -copy /Y .\Libraries\CANAPI\Release_dll\u3canpcb.exp %BIN% -copy /Y .\Libraries\CANAPI\Release_dll\u3canpcb.lib %BIN% -copy /Y .\Libraries\CANAPI\Release_dll\u3canpcb.pdb %BIN% -copy /Y .\Libraries\PeakCAN\Release_dll\uvPeakCAN.dll %BIN% -copy /Y .\Libraries\PeakCAN\Release_dll\uvPeakCAN.exp %BIN% -copy /Y .\Libraries\PeakCAN\Release_dll\uvPeakCAN.lib %BIN% -copy /Y .\Libraries\PeakCAN\Release_dll\uvPeakCAN.pdb %BIN% -set BIN=%BIN%\lib -if not exist %BIN% mkdir %BIN% -echo Copying static libraries... -copy /Y .\Libraries\CANAPI\Release_lib\u3canpcb.lib %BIN% -copy /Y .\Libraries\CANAPI\Release_lib\u3canpcb.pdb %BIN% -copy /Y .\Libraries\PeakCAN\Release_lib\uvPeakCAN.lib %BIN% -copy /Y .\Libraries\PeakCAN\Release_lib\uvPeakCAN.pdb %BIN% -copy /Y .\Sources\PCANBasic\x86\PCANBasic.lib %BIN% -echo "Static libraries (x86)" > %BIN%\readme.txt -set BIN=%BIN%\Debug -if %LIBDB% == "True" ( - echo Copying static debug libraries... - if not exist %BIN% mkdir %BIN% - copy /Y .\Libraries\CANAPI\Debug_lib\u3canpcb.lib %BIN% - copy /Y .\Libraries\CANAPI\Debug_lib\u3canpcb.pdb %BIN% - copy /Y .\Libraries\CANAPI\Debug_lib\u3canpcb.idb %BIN% - copy /Y .\Libraries\PeakCAN\Debug_lib\uvPeakCAN.lib %BIN% - copy /Y .\Libraries\PeakCAN\Debug_lib\uvPeakCAN.pdb %BIN% - copy /Y .\Libraries\PeakCAN\Debug_lib\uvPeakCAN.idb %BIN% - copy /Y .\Sources\PCANBasic\x86\PCANBasic.lib %BIN% - echo "Static debug libraries (x86)" > %BIN%\readme.txt -) -rem build the utilities 'can_moni', 'can_send' and 'can_test' -if %UTILS% == "True" ( - call msbuild.exe .\Utilities\can_moni\can_moni.vcxproj /t:Clean;Build /p:"Configuration=Release";"Platform=Win32" - if errorlevel 1 goto end - - call msbuild.exe .\Utilities\can_send\can_send.vcxproj /t:Clean;Build /p:"Configuration=Release";"Platform=Win32" - if errorlevel 1 goto end - - call msbuild.exe .\Utilities\can_test\can_test.vcxproj /t:Clean;Build /p:"Configuration=Release";"Platform=Win32" - if errorlevel 1 goto end -) -set BIN=.\Binaries -if not exist %BIN% mkdir %BIN% -set BIN=%BIN%\x86 -if not exist %BIN% mkdir %BIN% -if %UTILS% == "True" ( - echo Copying utilities... - copy /Y .\Utilities\can_moni\Release\can_moni.exe %BIN% - copy /Y .\Utilities\can_send\Release\can_send.exe %BIN% - copy /Y .\Utilities\can_test\Release\can_test.exe %BIN% -) -rem copy the header files into the Includes folder -echo Copying header files... -set INC=.\Includes -if not exist %INC% mkdir %INC% -copy /Y .\Sources\PeakCAN*.h %INC% -copy /Y .\Sources\CANAPI\CANAPI.h %INC% -copy /Y .\Sources\CANAPI\CANAPI_Types.h %INC% -copy /Y .\Sources\CANAPI\CANAPI_Defines.h %INC% -copy /Y .\Sources\CANAPI\CANBTR_Defaults.h %INC% -copy /Y .\Sources\CANAPI\can_api.h %INC% -copy /Y .\Sources\CANAPI\can_btr.h %INC% - -rem end of the job -:end -popd -if %VCVARS% == "True" ( - pause -) diff --git a/x86_install.bat b/x86_install.bat deleted file mode 100644 index b8574c3..0000000 --- a/x86_install.bat +++ /dev/null @@ -1,10 +0,0 @@ -rem Requires administrator rights! -@echo off -set PWD="%~dp0" -pushd -cd /D %PWD% -copy /Y .\Binaries\x86\u3canpcb.dll C:\Windows\SysWOW64 -copy /Y .\Binaries\x86\uvPeakCAN.dll C:\Windows\SysWOW64 -popd -dir C:\Windows\SysWOW64\u*can*.dll -pause diff --git a/x86_prompt.bat b/x86_prompt.bat deleted file mode 100644 index 716db5c..0000000 --- a/x86_prompt.bat +++ /dev/null @@ -1,3 +0,0 @@ -@pushd -@call %comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat" x86 %* -@popd \ No newline at end of file diff --git a/xxl_build.bat b/xxl_build.bat index 5e5b2dc..ffc431b 100644 --- a/xxl_build.bat +++ b/xxl_build.bat @@ -9,15 +9,11 @@ pushd rem build libraries, utilities and the trial program call .\x64_build.bat NOVARS if not errorlevel 0 goto end -call .\x86_build.bat NOVARS -if not errorlevel 0 goto end rem build test suites cd /D .\Tests call .\x64_build.bat NOVARS NORUN if not errorlevel 0 goto end -call .\x86_build.bat NOVARS NORUN -if not errorlevel 0 goto end rem end of the job :end