Skip to content

Commit

Permalink
Add debug vesion unit tests steps in document (#165)
Browse files Browse the repository at this point in the history
* Add debug version unit tests steps
  * Unit tests could use AWS SDK dlls on Windows instead of
    static linking to AWS SDK libraries
  • Loading branch information
RoyZhang2022 authored Nov 17, 2023
1 parent 03e34cb commit e239ed9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
13 changes: 8 additions & 5 deletions docs/building-the-aws-driver/BuildingAwsSdkCpp.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Building the AWS SDK for C++
The driver supports AWS IAM and AWS Secrets Manager authentication by using [AWS SDK for C++](https://docs.aws.amazon.com/sdk-for-cpp/). The driver requires `aws-cpp-sdk-core`, `aws-cpp-sdk-rds`, and `aws-cpp-sdk-secretsmanager`. You can either build the SDK yourself directly from the source using the script under `scripts` folder or [download the libraries using a package manager](https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/sdk-from-pm.html). The script will install the SDK under `aws_sdk/install` folder. The driver will look for SDK dependencies through `aws_sdk/install` folder and `CMAKE_PREFIX_PATH` environment variable.
> **_NOTE:_** On Winodws, depending on the use case, you may build the SDK as a static library or dynamic library. On Linux and macOS, you should always build the SDK as a dynamic library.
> **_NOTE:_** On Windows, depending on the use case, you may build the SDK as a static library or dynamic library. On Linux and macOS, you should always build the SDK as a dynamic library.
## Windows
If you want to build and run the driver unit tests, you need to build the SDK as static library, as the unit test binary will link every dependency statically.
### For release version unit tests or driver
```
.\scripts\build_aws_sdk_win.ps1 x64 Debug OFF "Visual Studio 16 2019"
.\scripts\build_aws_sdk_win.ps1 x64 Release ON "Visual Studio 16 2019"
```
If you want to build the driver DLL, you need to build the SDK as dynamic library, as the driver DLL will link the SDK dynamically.
### For debug version unit tests
```
.\scripts\build_aws_sdk_win.ps1 x64 Release ON "Visual Studio 16 2019"
.\scripts\build_aws_sdk_win.ps1 x64 Debug ON "Visual Studio 16 2019"
```
Note:
- Use ```Visual Studio 17 2022`` for Visual Studio 2022.

## Linux/macOS
```
./scripts/build_aws_sdk_unix.sh Release
Expand Down
17 changes: 17 additions & 0 deletions docs/testing-the-aws-driver/TestingTheAwsDriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,33 @@
## Unit Tests
1. Build driver binaries with `ENABLE_UNIT_TESTS` command set to `TRUE`:
- **Windows**

Add AWS SDK dynamic libraries path to environment variable `path` so the dlls could be found when unit tests are running.

- For release version unit tests, run the following command from repository root
```
cmake -S . -B build -G "Visual Studio 16 2019" -DMYSQL_DIR="C:\Program Files\MySQL\MySQL Server 8.0" -DMYSQLCLIENT_STATIC_LINKING=TRUE -DENABLE_UNIT_TESTS=TRUE
cmake --build build --config Release
```
- For debug version unit tests
- Download MySQL debug binaries from [MySQL::Download MySQL Community Server](https://dev.mysql.com/downloads/mysql/).
- Extract the `mysqlclient.lib` from debug binaries. Make sure to backup your release version of mysqlclient.lib in `MYSQL_DIR\lib`, e.g. `C:\Program Files\MySQL\MySQL Server 8.0\lib`. Replace release version `mysqlclient.lib` with debug version of `mysqlclient.lib`.
- Run the following command from repository root
```
cmake -S . -B build -G "Visual Studio 16 2019" -DMYSQL_DIR="C:\Program Files\MySQL\MySQL Server 8.0" -DMYSQLCLIENT_STATIC_LINKING=TRUE -DENABLE_UNIT_TESTS=TRUE -DCMAKE_BUILD_TYPE=Debug
cmake --build build --config Debug
```
- **MacOS**
- Run the following command from repository root
```
cmake -S . -B build -G "Unix Makefiles" -DMYSQLCLIENT_STATIC_LINKING=true -DODBC_INCLUDES=/usr/local/Cellar/libiodbc/3.52.15/include -DENABLE_UNIT_TESTS=TRUE
cmake --build build --config Release
```
- **Linux**
- Run the following command from repository root
```
cmake -S . -B build -G "Unix Makefiles" -DMYSQLCLIENT_STATIC_LINKING=true -DWITH_UNIXODBC=1 -DENABLE_UNIT_TESTS=TRUE
cmake --build build --config Release
Expand Down

0 comments on commit e239ed9

Please sign in to comment.