Tests: add live integration test (optional via PRIVATEBIN_IT), fix WinHTTP host/port + TLS opts, robust JSON parser (meta.time_to_live), CTest wiring; Add LLVM/clang-cl coverage option and docs; add build_thinkpad.bat; README updates

This commit is contained in:
mbusc
2025-08-28 15:22:00 +02:00
parent 7a125a4c9c
commit 0f58d40f52
10 changed files with 467 additions and 39 deletions

View File

@ -19,9 +19,9 @@ This library provides a simple C++ interface for interacting with PrivateBin ser
### Prerequisites
- CMake 3.10+
- C++17-fähiger Compiler (MSVC 2022 bzw. GCC/Clang)
- C++17-capable compiler (MSVC 2022 or GCC/Clang)
- Git
- vcpkg (wird bei Makefile-Nutzung automatisch gebootstrapped)
- vcpkg (automatically bootstrapped by the Makefile)
### Dependencies
@ -38,7 +38,7 @@ This library provides a simple C++ interface for interacting with PrivateBin ser
make
```
2) Beispiel bauen und ausführen:
2) Build and run the example:
```
make example
@ -70,6 +70,29 @@ cmake -S example -B example/build -DCMAKE_BUILD_TYPE=Release
cmake --build example/build --config Release
```
### Windows (PowerShell) Build via build_thinkpad.bat
For systems with Visual Studio 2022 Build Tools (C++ workload) and vcpkg in the user profile, there is a robust build script:
```
cd C:\Users\mbusc\source\repos\lib-privatebin
./build_thinkpad.bat
```
Notes:
- Requires Visual Studio 2022 Build Tools with C++ tools and the Windows 11 SDK. If `VsDevCmd.bat` is found, the script automatically initializes the MSVC environment.
- vcpkg is bootstrapped if needed; missing dependencies (`cryptopp`, `nlohmann-json`) are installed.
- If vcpkg requires a baseline, the script sets it automatically.
Edition/Path notes:
- If you use another VS edition (e.g., Professional/Enterprise), adjust the paths in `build_thinkpad.bat`:
- `C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Tools\VsDevCmd.bat`
- `C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat`
- Alternatively, you can use `vswhere.exe` to discover the installation path:
```powershell
& 'C:\Program Files\Microsoft Visual Studio\Installer\vswhere.exe' -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
```
## Usage
### API Functions
@ -142,4 +165,63 @@ int main() {
## License
This project is licensed under the MIT License - see the LICENSE file for details.
This project is licensed under the MIT License - see the LICENSE file for details.
## Troubleshooting
- vcpkg requires a baseline / "this vcpkg instance requires a manifest with a specified baseline"
- Run in the repo root to add an initial builtin baseline to `vcpkg.json`:
```powershell
$env:VCPKG_ROOT = "$env:USERPROFILE\vcpkg"
& "$env:VCPKG_ROOT\vcpkg.exe" x-update-baseline --add-initial-baseline
```
- Then configure/build again.
- Visual Studio instance not found / "could not find specified instance of Visual Studio"
- Ensure VS 2022 Build Tools or Community with C++ tools and Windows 11 SDK are installed.
- Use the Developer Command Prompt (VsDevCmd):
```powershell
cmd /c "call `"C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat`" -arch=x64 && build.bat"
```
- Or delete the build folder to clear stale CMake cache and reconfigure:
```powershell
Remove-Item -Recurse -Force build
```
- `vswhere.exe` not found
- Add the VS Installer directory to PATH for the current session:
```powershell
$env:PATH = 'C:\\Program Files\\Microsoft Visual Studio\\Installer;' + $env:PATH
```
- Or install/download `vswhere` from Microsoft and place it under the Installer folder.
- `cryptoppConfig.cmake` / `cryptopp-config.cmake` not found during CMake configure
- Make sure CMake uses vcpkg's toolchain file and that the ports are installed for the active triplet:
```powershell
$env:VCPKG_ROOT = "$env:USERPROFILE\vcpkg"
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
& "$env:VCPKG_ROOT\vcpkg.exe" install cryptopp nlohmann-json --triplet x64-windows
```
- PowerShell line continuation issues / parser errors
- Prefer single-line commands in PowerShell (avoid backticks if unsure). The README uses single-line examples for reliability.
## LLVM/clang-cl Coverage (Windows)
Requirements:
- clang/clang-cl toolchain installed
- LLVM tools on PATH (`llvm-profdata`, `llvm-cov`)
Configure with coverage:
```powershell
cmd /c "call ""C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat"" -arch=x64 && cmake -S . -B build-llvm -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang-cl -DENABLE_LLVM_COVERAGE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=""%USERPROFILE%\vcpkg\scripts\buildsystems\vcpkg.cmake"" && cmake --build build-llvm --config Release"
```
Run coverage target (executes tests, merges profiles, generates HTML report):
```powershell
cmd /c "call ""C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat"" -arch=x64 && cmake --build build-llvm --target coverage_llvm --config Release && start build-llvm\coverage\html\index.html"
```
Notes:
- If Ninja is not available, you can use the VS generator, but Ninja is recommended for clang.
- You can override `LLVM_PROFDATA` and `LLVM_COV` cache variables to absolute tool paths if needed.