From 93fb191a8baf7f73a21142e7873d9e9d23094eef Mon Sep 17 00:00:00 2001 From: Hampus Avekvist Date: Mon, 28 Jul 2025 12:16:22 +0200 Subject: [PATCH] chore: Rename Testcontainers for C to Testcontainers Native This renames every instance of "Testcontainers for C", "Testcontainers C", and "testcontainers-c". --- .devcontainer/README.md | 2 +- .gitignore | 10 +++++----- CMakeLists.txt | 6 +++--- README.md | 8 ++++---- ROADMAP.md | 12 +++++------ demo/README.md | 2 +- demo/generic-container/CMakeLists.txt | 8 ++++---- demo/generic-container/README.md | 4 ++-- .../generic_container_demo.c | 5 ++--- demo/google-test/CMakeLists.txt | 6 +++--- demo/google-test/README.md | 8 ++++---- demo/google-test/test.cpp | 18 ++++++++--------- demo/wiremock/CMakeLists.txt | 14 ++++++------- demo/wiremock/README.md | 4 ++-- demo/wiremock/wiremock_module_demo.c | 5 ++--- docs/SECURITY.md | 2 +- docs/SUPPORT.md | 4 ++-- docs/architecture/README.md | 8 ++++---- docs/c/README.md | 20 +++++++++---------- docs/cpp/README.md | 14 ++++++------- docs/getting-started.md | 6 +++--- docs/swift/README.md | 20 +++++++++---------- modules/README.md | 12 +++++------ modules/wiremock/CMakeLists.txt | 16 +++++++-------- modules/wiremock/README.md | 2 +- modules/wiremock/impl.c | 6 +++--- ...ock.h => testcontainers-native-wiremock.h} | 2 +- .../CMakeLists.txt | 18 ++++++++--------- .../cmake.pc.in | 0 .../go.mod | 2 +- .../go.sum | 0 .../testcontainers-native.go | 0 32 files changed, 121 insertions(+), 123 deletions(-) rename modules/wiremock/{testcontainers-c-wiremock.h => testcontainers-native-wiremock.h} (97%) rename {testcontainers-c => testcontainers-native}/CMakeLists.txt (68%) rename {testcontainers-c => testcontainers-native}/cmake.pc.in (100%) rename {testcontainers-c => testcontainers-native}/go.mod (97%) rename {testcontainers-c => testcontainers-native}/go.sum (100%) rename testcontainers-c/testcontainers-c.go => testcontainers-native/testcontainers-native.go (100%) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index bb6a34d..f94888b 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -1,4 +1,4 @@ -# Testcontainers for C/C++. DevContainer +# Testcontainers Native. DevContainer This is an experimental Dev Container for the project site that does not yet include the build tools. diff --git a/.gitignore b/.gitignore index b292995..f776d4a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,11 +14,11 @@ build/ /lib # Generated files -testcontainers-c/testcontainers-c.h -testcontainers-c/testcontainers-c.so -testcontainers-c/testcontainers.so -testcontainers-c/testcontainers.dll -testcontainers-c/testcontainers.h +testcontainers-native/testcontainers-native.h +testcontainers-native/testcontainers-native.so +testcontainers-native/testcontainers.so +testcontainers-native/testcontainers.dll +testcontainers-native/testcontainers.h *.so *.out *.exe diff --git a/CMakeLists.txt b/CMakeLists.txt index b6183a0..1ed721d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,11 @@ cmake_minimum_required (VERSION 3.16.3) -project (TESTCONTAINERS-C) +project (TESTCONTAINERS-NATIVE) include(CTest) -include_directories(${CMAKE_CURRENT_BINARY_DIR}/testcontainers-c) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/testcontainers-native) -add_subdirectory(testcontainers-c) +add_subdirectory(testcontainers-native) add_subdirectory(modules) if(NOT DEFINED SKIP_DEMOS) add_subdirectory(demo) diff --git a/README.md b/README.md index 9f8a53e..e3cd725 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Slack: testcontainers-native on slack.testcontainers.org](https://img.shields.io/badge/Slack-%23testcontainers%E2%80%94native-brightgreen?style=flat&logo=slack)](https://slack.testcontainers.org/) [![Stability: Experimental](https://masterminds.github.io/stability/experimental.svg)](https://masterminds.github.io/stability/experimental.html) -[![GitHub release (latest by date)](https://img.shields.io/github/v/release/oleg-nenashev/testcontainers-c)](https://github.com/oleg-nenashev/testcontainers-c/releases) +[![GitHub release (latest by date)](https://img.shields.io/github/v/release/testcontainers/testcontainers-native)](https://github.com/testcontainers/testcontainers-native/releases) !!! warning This is a prototype. @@ -24,7 +24,7 @@ Also join the `#testcontainers-native` channel on the [Testcontainers Slack](htt ## Key Features -- _Testcontainers for C/C++_ - a shared library and C-style headers that can be used in native projects +- _Testcontainers Native_ - a shared library and C-style headers that can be used in native projects - Support for [C](./docs/c/README.md), [C++](./docs/cpp/README.md), [Swift](./docs/swift/README.md) and other native projects. - Minimum viable Testcontainers API functionality: starting and terminating containers, passing files, exposing ports, @@ -66,12 +66,12 @@ See [the examples and demos](./demo/README.md) for more examples. ### Using in other languages TL;DR: You get the C header file, a shared library object or a DLL file from the -[Testcontainers for C](./docs/c/README.md) module. +[Testcontainers for Native](./docs/c/README.md) module. Then, you can bind this native library in your project type. It allows supporting many other languages that support using native tooling via dynamically or statically linked libraries: -![Languages that can leverage Testcontainers for C](docs/images/supported-languages.png) +![Languages that can leverage Testcontainers Native](docs/images/supported-languages.png) Disclaimer: The schema above shows the most popular languages for Embedded systems, diff --git a/ROADMAP.md b/ROADMAP.md index b8d0270..d8c6524 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -3,23 +3,23 @@ [![Slack: testcontainers-native on slack.testcontainers.org](https://img.shields.io/badge/Slack-%23testcontainers%E2%80%94native-brightgreen?style=flat&logo=slack)](http://slack.testcontainers.org/) A full public roadmap is coming soon. -See the [GitHub Issues](https://github.com/testcontainers/testcontainers-c/issues) and, +See the [GitHub Issues](https://github.com/testcontainers/testcontainers-native/issues) and, in particular, the pinned issues to learn about the key initiatives on the table. ## Key Objectives -What we want to do before 1.0: +What we want to do before 1.0: -- [ ] Ensure sufficient feature parity with Testcontainers for Go ([#6](https://github.com/testcontainers/testcontainers-c/issues/6)) -- [ ] Add a C++ binding library and class-based headers ([#12](https://github.com/testcontainers/testcontainers-c/issues/12)) +- [ ] Ensure sufficient feature parity with Testcontainers for Go ([#6](https://github.com/testcontainers/testcontainers-native/issues/6)) +- [ ] Add a C++ binding library and class-based headers ([#12](https://github.com/testcontainers/testcontainers-native/issues/12)) - [ ] Prototype and document support for other languages that leverage native libraries, in particular Swift - [x] Make Testcontainers Native an official project listed on the [Testcontainers site](https://testcontainers.com/) - [ ] Publish the project to common C/C++ package managers - ([vcpkg](https://github.com/testcontainers/testcontainers-c/issues/2), - [Conan](https://github.com/testcontainers/testcontainers-c/issues/3)) + ([vcpkg](https://github.com/testcontainers/testcontainers-native/issues/2), + [Conan](https://github.com/testcontainers/testcontainers-native/issues/3)) ## Discuss the Roadmap diff --git a/demo/README.md b/demo/README.md index 0b44cab..6592809 100644 --- a/demo/README.md +++ b/demo/README.md @@ -3,5 +3,5 @@ ## Usage in C/C++ - [Using the generic Testcontainer C API](./generic-container/README.md) -- [Using Testcontainers C in Google Test (C++)](./google-test/README.md) +- [Using Testcontainers Native in Google Test (C++)](./google-test/README.md) - [Using the WireMock module](./wiremock/README.md) diff --git a/demo/generic-container/CMakeLists.txt b/demo/generic-container/CMakeLists.txt index 7559e5f..bb0d8c4 100644 --- a/demo/generic-container/CMakeLists.txt +++ b/demo/generic-container/CMakeLists.txt @@ -1,15 +1,15 @@ -project(testcontainers-c-generic-container-demo +project(testcontainers-native-generic-container-demo VERSION 0.0.1 DESCRIPTION "Demonstrates usage of the generic container API in a simple main app") set(TARGET_OUT demo_generic_container.out) -include_directories(${testcontainers-c_SOURCE_DIR}) +include_directories(${testcontainers-native_SOURCE_DIR}) # WORKING_DIRECTORY breaks shared lib loading file(COPY test_data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # Vanilla Demo for WireMock add_executable(${TARGET_OUT} generic_container_demo.c) -add_dependencies(${TARGET_OUT} testcontainers-c-shim) -target_link_libraries(${TARGET_OUT} PRIVATE testcontainers-c) +add_dependencies(${TARGET_OUT} testcontainers-native-shim) +target_link_libraries(${TARGET_OUT} PRIVATE testcontainers-native) add_test(NAME generic_container_demo COMMAND ${TARGET_OUT}) diff --git a/demo/generic-container/README.md b/demo/generic-container/README.md index 7f8a59a..015f01d 100644 --- a/demo/generic-container/README.md +++ b/demo/generic-container/README.md @@ -1,6 +1,6 @@ -# Demo - Generic Container on Testcontainers C +# Demo - Generic Container on Testcontainers Native -Demonstrates usage of the generic container API provided by the Testcontainers C library. +Demonstrates usage of the generic container API provided by the Testcontainers Native library. In this demo, we do not use any module SDKs or test frameworks, just a simple `main()` function. ## Running demo diff --git a/demo/generic-container/generic_container_demo.c b/demo/generic-container/generic_container_demo.c index ff600f4..3b88bc0 100644 --- a/demo/generic-container/generic_container_demo.c +++ b/demo/generic-container/generic_container_demo.c @@ -1,10 +1,10 @@ #include -#include "testcontainers-c.h" +#include "testcontainers-native.h" #define DEFAULT_IMAGE "wiremock/wiremock:3.0.1-1" int main() { - printf("Using WireMock with the Testcontainers C binding:\n"); + printf("Using WireMock with the Testcontainers Native binding:\n"); printf("Creating new container: %s\n", DEFAULT_IMAGE); int requestId = tc_new_container_request(DEFAULT_IMAGE); @@ -31,4 +31,3 @@ int main() { printf("Server Response: HTTP-%d\n%s\n\n", response.r0, response.r1); return 0; } - diff --git a/demo/google-test/CMakeLists.txt b/demo/google-test/CMakeLists.txt index ede0901..e4f9ee9 100644 --- a/demo/google-test/CMakeLists.txt +++ b/demo/google-test/CMakeLists.txt @@ -2,7 +2,7 @@ # This is based on https://google.github.io/googletest/quickstart-cmake.html project(google-test-demo VERSION 0.0.1 - DESCRIPTION "Demonstrates usage of Testcontainers C in Google Test") + DESCRIPTION "Demonstrates usage of Testcontainers Native in Google Test") set(TARGET_OUT ${PROJECT_NAME}.out) @@ -21,8 +21,8 @@ enable_testing() file(COPY test_data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) add_executable(${TARGET_OUT} test.cpp) -add_dependencies(${TARGET_OUT} testcontainers-c-shim) -target_link_libraries(${TARGET_OUT} PRIVATE testcontainers-c) +add_dependencies(${TARGET_OUT} testcontainers-native-shim) +target_link_libraries(${TARGET_OUT} PRIVATE testcontainers-native) target_link_libraries(${TARGET_OUT} PRIVATE GTest::gtest_main) include(GoogleTest) diff --git a/demo/google-test/README.md b/demo/google-test/README.md index 55b9706..75c8a5c 100644 --- a/demo/google-test/README.md +++ b/demo/google-test/README.md @@ -1,6 +1,6 @@ -# Using Testcontainers C in Google Test +# Using Testcontainers Native in Google Test -Demonstrates usage of Testcontainers C in [Google Test](https://github.com/google/googletest). +Demonstrates usage of Testcontainers Native in [Google Test](https://github.com/google/googletest). See [test.cpp](./test.cpp) for the code. ## Run the demo @@ -15,8 +15,8 @@ ctest --output-on-failure ## Sample output ```shell -onenashev:~/testcontainers-c/demo/google-test$ ctest --output-on-failure -Test project /home/onenashev/testcontainers-c/demo/google-test +onenashev:~/testcontainers-native/demo/google-test$ ctest --output-on-failure +Test project /home/onenashev/testcontainers-native/demo/google-test Start 1: WireMockTestContainer.HelloWorld 1/5 Test #1: WireMockTestContainer.HelloWorld ...................... Passed 3.31 sec Start 2: WireMockTestContainer.HelloWorldFromResource diff --git a/demo/google-test/test.cpp b/demo/google-test/test.cpp index ae87581..da0de6a 100644 --- a/demo/google-test/test.cpp +++ b/demo/google-test/test.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "testcontainers-c.h" +#include "testcontainers-native.h" class WireMockTestContainer : public ::testing::Test { @@ -11,7 +11,7 @@ const char* WIREMOCK_ADMIN_MAPPING_ENDPOINT = "/__admin/mappings"; protected: void SetUp() override { std::cout << "Creating new container: " << WIREMOCK_IMAGE << '\n'; - + int requestId = tc_new_container_request(WIREMOCK_IMAGE); tc_with_exposed_tcp_port(requestId, 8080); tc_with_wait_for_http(requestId, 8080, WIREMOCK_ADMIN_MAPPING_ENDPOINT); @@ -19,10 +19,10 @@ const char* WIREMOCK_ADMIN_MAPPING_ENDPOINT = "/__admin/mappings"; tc_with_file(requestId, "test_data/hello_with_resource.json", "/home/wiremock/mappings/hello2.json"); tc_with_file(requestId, "test_data/hello_with_missing_resource.json", "/home/wiremock/mappings/hello3.json"); tc_with_file(requestId, "test_data/response.xml", "/home/wiremock/__files/response.xml"); - + struct tc_run_container_return ret = tc_run_container(requestId); containerId = ret.r0; - + EXPECT_TRUE(ret.r1) << "Failed to run the container: " << ret.r2; }; @@ -37,27 +37,27 @@ const char* WIREMOCK_ADMIN_MAPPING_ENDPOINT = "/__admin/mappings"; TEST_F(WireMockTestContainer, HelloWorld) { std::cout << "Sending HTTP request to the container\n"; struct tc_send_http_get_return response = tc_send_http_get(containerId, 8080, "/hello"); - + ASSERT_NE(response.r0, -1) << "Failed to send HTTP request: " << response.r2; ASSERT_EQ(response.r0, 200) << "Received wrong response code: " << response.r1 << response.r2; - + std::cout << "Server Response: HTTP-" << response.r0 << '\n' << response.r1 << '\n'; } TEST_F(WireMockTestContainer, HelloWorldFromResource) { std::cout << "Sending HTTP request to the container\n"; struct tc_send_http_get_return response = tc_send_http_get(containerId, 8080, "/hello-from-resource"); - + ASSERT_NE(response.r0, -1) << "Failed to send HTTP request: " << response.r2; ASSERT_EQ(response.r0, 200) << "Received wrong response code: " << response.r1 << response.r2; - + std::cout << "Server Response: HTTP-" << response.r0 << '\n' << response.r1 << '\n'; } TEST_F(WireMockTestContainer, HelloWorldFromMissingResource) { std::cout << "Sending HTTP request to the container\n"; struct tc_send_http_get_return response = tc_send_http_get(containerId, 8080, "/hello-from-missing-resource"); - + ASSERT_EQ(response.r0, 500) << "The request should have failed"; } diff --git a/demo/wiremock/CMakeLists.txt b/demo/wiremock/CMakeLists.txt index aa232ba..3304738 100644 --- a/demo/wiremock/CMakeLists.txt +++ b/demo/wiremock/CMakeLists.txt @@ -1,17 +1,17 @@ -project(testcontainers-c-wiremock-demo +project(testcontainers-native-wiremock-demo VERSION 0.0.1 - DESCRIPTION "Demonstrates usage of the WireMock module for Testcontainers C in a simple main app") + DESCRIPTION "Demonstrates usage of the WireMock module for Testcontainers Native in a simple main app") set(TARGET_OUT demo_wiremock_module.out) -include_directories(${testcontainers-c_SOURCE_DIR}) +include_directories(${testcontainers-native_SOURCE_DIR}) # WORKING_DIRECTORY breaks shared lib loading file(COPY test_data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # WireMock Module demo add_executable(${TARGET_OUT} wiremock_module_demo.c) -add_dependencies(${TARGET_OUT} testcontainers-c-shim) -target_include_directories(${TARGET_OUT} PRIVATE ${testcontainers-c-wiremock_SOURCE_DIR}) -target_link_libraries(${TARGET_OUT} PRIVATE testcontainers-c) -target_link_libraries(${TARGET_OUT} PRIVATE testcontainers-c-wiremock) +add_dependencies(${TARGET_OUT} testcontainers-native-shim) +target_include_directories(${TARGET_OUT} PRIVATE ${testcontainers-native-wiremock_SOURCE_DIR}) +target_link_libraries(${TARGET_OUT} PRIVATE testcontainers-native) +target_link_libraries(${TARGET_OUT} PRIVATE testcontainers-native-wiremock) add_test(NAME wiremock_module_demo COMMAND ${TARGET_OUT}) diff --git a/demo/wiremock/README.md b/demo/wiremock/README.md index c68698b..35240aa 100644 --- a/demo/wiremock/README.md +++ b/demo/wiremock/README.md @@ -1,6 +1,6 @@ -# Demo - WireMock on Testcontainers C +# Demo - WireMock on Testcontainers Native -Demonstrates usage of the [WireMock Module for Testcontainers C](../../modules/wiremock/) in a simple main function. +Demonstrates usage of the [WireMock Module for Testcontainers Native](../../modules/wiremock/) in a simple main function. No test framework is used here. ## Running demo diff --git a/demo/wiremock/wiremock_module_demo.c b/demo/wiremock/wiremock_module_demo.c index 9e70598..b11499c 100644 --- a/demo/wiremock/wiremock_module_demo.c +++ b/demo/wiremock/wiremock_module_demo.c @@ -1,9 +1,9 @@ #include #include -#include "testcontainers-c-wiremock.h" +#include "testcontainers-native-wiremock.h" int main() { - printf("Using WireMock with the Testcontainers C binding:\n"); + printf("Using WireMock with the Testcontainers Native binding:\n"); printf("Creating new container: %s\n", DEFAULT_WIREMOCK_IMAGE); int requestId = tc_wm_new_default_container(); @@ -45,4 +45,3 @@ int main() { printf("Server Response: HTTP-%d\n%s\n\n", response.r0, response.r1); return 0; } - diff --git a/docs/SECURITY.md b/docs/SECURITY.md index 001d098..792858a 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -3,7 +3,7 @@ ## Reporting Security Issues You can submit any security issue or suspected vulnerability -on [GitHub Security](https://github.com/testcontainers/testcontainers-c/security/advisories). +on [GitHub Security](https://github.com/testcontainers/testcontainers-native/security/advisories). Please do **NOT** use public GitHub Issues for reporting vulnerabilities. ## Bug Bounty diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md index 1cfbfac..6f0b26f 100644 --- a/docs/SUPPORT.md +++ b/docs/SUPPORT.md @@ -13,14 +13,14 @@ At the moment, this is single channel for all project matters. ## Raising Issues and Feature Requests -Use [GitHub Issues](https://github.com/testcontainers/testcontainers-c/issues). +Use [GitHub Issues](https://github.com/testcontainers/testcontainers-native/issues). Note that it may take some time to get a response, thanks for your patience. Contributions are always welcome, see the [Contributor Guide](../CONTRIBUTING.md). ## Reporting Security Issues You can submit any security issue or suspected vulnerability -on [GitHub Security](https://github.com/testcontainers/testcontainers-c/security/advisories). +on [GitHub Security](https://github.com/testcontainers/testcontainers-native/security/advisories). Please do NOT use public GitHub Issues for reporting vulnerabilities. Read More - [Security Policy](./SECURITY.md). diff --git a/docs/architecture/README.md b/docs/architecture/README.md index 73fa218..2d93fa1 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -8,9 +8,9 @@ ![Testcontainers Native Build Process](./images/build-process.png) -### Stage 1. Testcontainers for C shared library +### Stage 1. Testcontainers Native shared library -The core `testcontainers-c` shared library is built with [Cgo](https://pkg.go.dev/cmd/cgo). +The core `testcontainers-native` shared library is built with [Cgo](https://pkg.go.dev/cmd/cgo). For that the `-buildmode=c-shared` is used in the Golang builder, and it also receives a customized header so that the types can be mapped between C and Golang. For that, we also have to flatten the structure and to switch the reference-based build process to fixed Objects stored in the Golang namespace, and C API @@ -18,7 +18,7 @@ using unique object IDs. ### Stage 2. Language Bindings -Then, we build custom binding libraries, by using Testcontainers for C +Then, we build custom binding libraries, by using Testcontainers Native as a static library that is bundled into the language specific libs. This stage depends on the language and common practices there. @@ -27,5 +27,5 @@ This stage depends on the language and common practices there. Well, you build it. From the previous stages, you get a header file, binding libraries, -a shared library object or a DLL file from the [Testcontainers for C](./docs/c/README.md) module. +a shared library object or a DLL file from the [Testcontainers Native](./docs/c/README.md) module. Then, you know the drill. diff --git a/docs/c/README.md b/docs/c/README.md index ef5ccf2..5df8dbc 100644 --- a/docs/c/README.md +++ b/docs/c/README.md @@ -1,6 +1,6 @@ -# Using Testcontainers for C +# Using Testcontainers Native -You can use the `testcontainers-c` library with common C +You can use the `testcontainers-native` library with common C unit testing frameworks and, soon, with package managers. !!! note @@ -31,9 +31,9 @@ You can also use [CPM](https://github.com/cpm-cmake/CPM.cmake) in CMake: ```cmake include(cmake/CPM.cmake) CPMAddPackage( - NAME testcontainers-c + NAME testcontainers-native VERSION 0.0.2 - GITHUB_REPOSITORY "testcontainers/testcontainers-c" + GITHUB_REPOSITORY "testcontainers/testcontainers-native" OPTIONS "SKIP_DEMOS TRUE") ``` @@ -55,10 +55,10 @@ Testcontainers for Go has automatic resource de-provisioning. ```c #include #include -#include "testcontainers-c-wiremock.h" +#include "testcontainers-native-wiremock.h" int main() { - printf("Using WireMock with the Testcontainers C binding:\n"); + printf("Using WireMock with the Testcontainers Native binding:\n"); printf("Creating new container: %s\n", DEFAULT_WIREMOCK_IMAGE); int requestId = tc_wm_new_default_container(); @@ -113,7 +113,7 @@ Then, this code will be replaced by a real test of your application. } ``` -In CMake, once the `testcontainers-c` is installed (see above), +In CMake, once the `testcontainers-native` is installed (see above), you can use it in test executables built by CMake: ```cmake @@ -121,8 +121,8 @@ enable_testing() file(COPY test_data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) add_executable(${TARGET_OUT} mytest.cpp) -add_dependencies(${TARGET_OUT} testcontainers-c-shim) -target_link_libraries(${TARGET_OUT} PRIVATE testcontainers-c) +add_dependencies(${TARGET_OUT} testcontainers-native-shim) +target_link_libraries(${TARGET_OUT} PRIVATE testcontainers-native) add_test(NAME wiremock_module_demo COMMAND ${TARGET_OUT}) ``` @@ -135,5 +135,5 @@ ctest --output-on-failure ## Demos -- [Using the generic Testcontainers C API](../../demo/generic-container/README.md) +- [Using the generic Testcontainers Native API](../../demo/generic-container/README.md) - [Using the WireMock module](../../demo/wiremock/README.md) diff --git a/docs/cpp/README.md b/docs/cpp/README.md index c0913ed..bcb6858 100644 --- a/docs/cpp/README.md +++ b/docs/cpp/README.md @@ -2,7 +2,7 @@ At the moment, there is no dedicated C++ binding library/header, but it is on [our roadmap](../../ROADMAP.md). -Tou can use the `testcontainers-c` library directly +Tou can use the `testcontainers-native` library directly in all C++ testing frameworks. ## Google Test @@ -15,7 +15,7 @@ with proper setup and tear-down methods. #include #include #include -#include "testcontainers-c.h" +#include "testcontainers-native.h" class WireMockTestContainer : public ::testing::Test { @@ -29,10 +29,10 @@ protected: tc_with_exposed_tcp_port(requestId, 8080); tc_with_wait_for_http(requestId, 8080, WIREMOCK_ADMIN_MAPPING_ENDPOINT); tc_with_file(requestId, "test_data/hello.json", "/home/wiremock/mappings/hello.json"); - + struct tc_run_container_return ret = tc_run_container(requestId); containerId = ret.r0; - + EXPECT_TRUE(ret.r1) << "Failed to run the container: " << ret.r2; }; @@ -51,14 +51,14 @@ Then, you can define new tests by referring to the container via `containerId`. TEST_F(WireMockTestContainer, HelloWorld) { std::cout << "Sending HTTP request to the container\n"; struct tc_send_http_get_return response = tc_send_http_get(containerId, 8080, "/hello"); - + ASSERT_NE(response.r0, -1) << "Failed to send HTTP request: " << response.r2; ASSERT_EQ(response.r0, 200) << "Received wrong response code: " << response.r1 << response.r2; - + std::cout << "Server Response: HTTP-" << response.r0 << '\n' << response.r1 << '\n'; } ``` ## Demos -- [Using Testcontainers C in Google Test (C++)](../../demo/google-test/) +- [Using Testcontainers Native in Google Test (C++)](../../demo/google-test/) diff --git a/docs/getting-started.md b/docs/getting-started.md index ded08ff..07f5983 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,4 +1,4 @@ -# Getting Started with Testcontainers for C/C++ +# Getting Started with Testcontainers Native In this section, we will build a demo C application that uses Testcontainers in a simple C application @@ -51,12 +51,12 @@ main.c - Show me the Code ```c #include #include -#include "testcontainers-c.h" +#include "testcontainers-native.h" #define DEFAULT_IMAGE "wiremock/wiremock:3.0.1-1" int main() { - printf("Using WireMock with the Testcontainers C binding:\n"); + printf("Using WireMock with the Testcontainers Native binding:\n"); printf("Creating new container: %s\n", DEFAULT_IMAGE); int requestId = tc_new_container_request(DEFAULT_IMAGE); diff --git a/docs/swift/README.md b/docs/swift/README.md index 800bf3d..2b35bf9 100644 --- a/docs/swift/README.md +++ b/docs/swift/README.md @@ -1,8 +1,8 @@ # Using Testcontainers in Swift -The Testcontainers for C/C++ library is compatible with native languages, and that includes Swift. To use the library in Swift, a few extra steps must be followed in order for it to be useable. +The Testcontainers Native library is compatible with native languages, and that includes Swift. To use the library in Swift, a few extra steps must be followed in order for it to be useable. -## Using the generic Testcontainer C API +## Using the generic Testcontainer Native API From the root of the repository: @@ -11,11 +11,11 @@ cmake . cmake --build . ``` -The testcontainers-c header and library must be deployed to /usr manually: +The testcontainers-native header and library must be deployed to /usr manually: ```bash -sudo cp testcontainers-c/testcontainers-c.h /usr/include -sudo cp testcontainers-c/testcontainers-c.so /usr/lib/libtestcontainers-c.so +sudo cp testcontainers-c/testcontainers-native.h /usr/include +sudo cp testcontainers-c/testcontainers-native.so /usr/lib/libtestcontainers-native.so ``` This is required so that Swift can actually find the header and library. On some systems, it may be required to deploy the *.so file to `/usr/lib64` instead (such as openSUSE). Try this if Swift is unable to find the library at `/usr/lib`. @@ -30,7 +30,7 @@ swift package init --type=executable Inside of this project, create a new directory under `Sources/` called `CTestContainers`. Create a `CTestContainers.h` file with the following content: ```c -#include +#include ``` Then, create a file called `module.modulemap` in the same directory with this: @@ -38,7 +38,7 @@ Then, create a file called `module.modulemap` in the same directory with this: ```c module CTestContainers [system] { header "CTestContainers.h" - link "testcontainers-c" + link "testcontainers-native" export * } ``` @@ -89,7 +89,7 @@ extension String { } let defaultImage = "wiremock/wiremock:3.0.1-1" -print("Using WireMock with the Testcontainers C binding (from Swift):") +print("Using WireMock with the Testcontainers Native binding (from Swift):") print("Creating new container: \(defaultImage)") let requestId = tc_new_container_request(defaultImage) @@ -133,13 +133,13 @@ Also, note that that `free` should be called to avoid memory leaks on the C stri To use the `wiremock` module in Swift, all that needs to be done is to deploy the header and library in the same way as described above, and then add the following to `CTestContainers.h`: ```c -#include +#include ``` And the following to `module.modulemap`: ```c -link "testcontainers-c-wiremock" +link "testcontainers-native-wiremock" ``` Then it is possible to use all the wiremock module helper functions from inside of Swift. diff --git a/modules/README.md b/modules/README.md index b9885c9..fcecc9e 100644 --- a/modules/README.md +++ b/modules/README.md @@ -6,7 +6,7 @@ easier. The expectation is that the modules are implemented in a separate dynamic library and linked to the consumer project. -The modules use Native API, and +The modules use a C API, and can be a fully native implementation or a Golang bridge one, similar to the core project. @@ -30,7 +30,7 @@ The following modules are available for this project: Initializing WireMock with the module: ```c -#include "testcontainers-c-wiremock.h" +#include "testcontainers-native-wiremock.h" int main() { printf("Creating new container: %s\n", DEFAULT_WIREMOCK_IMAGE); @@ -50,12 +50,12 @@ Show me the Code ```c -#include "testcontainers-c.h" +#include "testcontainers-native.h" #define DEFAULT_IMAGE "wiremock/wiremock:3.1.0-1" int main() { - printf("Using WireMock with the Testcontainers C binding:\n"); + printf("Using WireMock with the Testcontainers Native binding:\n"); printf("Creating new container: %s\n", DEFAULT_IMAGE); int requestId = tc_new_container_request(DEFAULT_IMAGE); @@ -76,7 +76,7 @@ and you can also create modules as standalone repositories. ### Where to Publish Modules? -Some modules are stored in [this repository](https://github.com/testcontainers/testcontainers-c) for demo and prototyping purposes. +Some modules are stored in [this repository](https://github.com/testcontainers/testcontainers-native) for demo and prototyping purposes. You are welcome to add your modules there too. -If you develop new modules, once `vcpkg` or `Conan` packaging is implemented for Testcontainers C, +If you develop new modules, once `vcpkg` or `Conan` packaging is implemented for Testcontainers Native, you might want to develop your module in a standalone repository instead. diff --git a/modules/wiremock/CMakeLists.txt b/modules/wiremock/CMakeLists.txt index 640928a..04a05db 100644 --- a/modules/wiremock/CMakeLists.txt +++ b/modules/wiremock/CMakeLists.txt @@ -1,21 +1,21 @@ cmake_minimum_required(VERSION 3.9) -project(testcontainers-c-wiremock VERSION 0.0.1 - DESCRIPTION "WireMock module for Testcontainers C") +project(testcontainers-native-wiremock VERSION 0.0.1 + DESCRIPTION "WireMock module for Testcontainers Native") include(GNUInstallDirs) add_library(${PROJECT_NAME} SHARED - testcontainers-c-wiremock.h + testcontainers-native-wiremock.h impl.c ) -add_dependencies(${PROJECT_NAME} testcontainers-c) +add_dependencies(${PROJECT_NAME} testcontainers-native) -include_directories(${testcontainers-c_SOURCE_DIR}) +include_directories(${testcontainers-native_SOURCE_DIR}) -set_target_properties(${PROJECT_NAME} PROPERTIES - VERSION ${PROJECT_VERSION} - PUBLIC_HEADER testcontainers-c-wiremock.h) +set_target_properties(${PROJECT_NAME} PROPERTIES + VERSION ${PROJECT_VERSION} + PUBLIC_HEADER testcontainers-native-wiremock.h) configure_file(cmake.pc.in ${PROJECT_NAME}.pc @ONLY) install(TARGETS ${PROJECT_NAME} diff --git a/modules/wiremock/README.md b/modules/wiremock/README.md index eca3d9d..904bd73 100644 --- a/modules/wiremock/README.md +++ b/modules/wiremock/README.md @@ -1,4 +1,4 @@ -# WireMock Module for Testcontainers C +# WireMock Module for Testcontainers Native This module allows provisioning the WireMock server as a standalone container within your tests, based on [WireMock Docker](https://github.com/wiremock/wiremock-docker). diff --git a/modules/wiremock/impl.c b/modules/wiremock/impl.c index ad0bf34..7ddd078 100644 --- a/modules/wiremock/impl.c +++ b/modules/wiremock/impl.c @@ -1,4 +1,4 @@ -#include "testcontainers-c-wiremock.h" +#include "testcontainers-native-wiremock.h" #include #include @@ -17,7 +17,7 @@ void tc_wm_with_mapping(GoInt requestID, char* filePath, char* destination) { char dest_file[128] = ""; strcat(dest_file, WIREMOCK_MAPPINGS_DIR); strcat(dest_file, destination); - + // Append extension if missing if(strlen(destination) > 5 && !strcmp(destination + strlen(destination) - 5, ".json")) { strcat(dest_file, ".json"); @@ -27,7 +27,7 @@ void tc_wm_with_mapping(GoInt requestID, char* filePath, char* destination) { } printf("DEBUG: %s to %s.\n", filePath, dest_file); - tc_with_file(requestID, filePath, dest_file); + tc_with_file(requestID, filePath, dest_file); }; struct WireMock_Mapping tc_wm_get_mappings(GoInt containerId) { diff --git a/modules/wiremock/testcontainers-c-wiremock.h b/modules/wiremock/testcontainers-native-wiremock.h similarity index 97% rename from modules/wiremock/testcontainers-c-wiremock.h rename to modules/wiremock/testcontainers-native-wiremock.h index 4ed78b9..45d72ea 100644 --- a/modules/wiremock/testcontainers-c-wiremock.h +++ b/modules/wiremock/testcontainers-native-wiremock.h @@ -1,4 +1,4 @@ -#include "testcontainers-c.h" +#include "testcontainers-native.h" #ifndef TESTCONTAINERS_WIREMOCK_H #define TESTCONTAINERS_WIREMOCK_H diff --git a/testcontainers-c/CMakeLists.txt b/testcontainers-native/CMakeLists.txt similarity index 68% rename from testcontainers-c/CMakeLists.txt rename to testcontainers-native/CMakeLists.txt index 9583bd6..af87af0 100644 --- a/testcontainers-c/CMakeLists.txt +++ b/testcontainers-native/CMakeLists.txt @@ -1,14 +1,14 @@ cmake_minimum_required(VERSION 3.0) -project(testcontainers-c VERSION 0.0.1 - DESCRIPTION "Testcontainers C library") +project(testcontainers-native VERSION 0.0.1 + DESCRIPTION "Testcontainers Native library") include(GNUInstallDirs) -set(SRCS testcontainers-c.go) +set(SRCS testcontainers-native.go) -set(TARGET testcontainers-c-shim) -set(TARGET_LIB testcontainers-c.so) -set(TARGET_HEADER testcontainers-c.h) +set(TARGET testcontainers-native-shim) +set(TARGET_LIB testcontainers-native.so) +set(TARGET_HEADER testcontainers-native.h) add_custom_command(OUTPUT ${TARGET_LIB} ${TARGET_HEADER} DEPENDS ${SRCS} @@ -16,16 +16,16 @@ add_custom_command(OUTPUT ${TARGET_LIB} ${TARGET_HEADER} COMMAND env GOPATH=${GOPATH} go build -buildmode=c-shared -o "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_LIB}" ${CMAKE_GO_FLAGS} ${SRCS} - COMMENT "Building Testcontainers C shared library") + COMMENT "Building Testcontainers Native shared library") add_custom_target(${TARGET} DEPENDS ${TARGET_LIB} ${TARGET_HEADER}) add_library(${PROJECT_NAME} SHARED IMPORTED GLOBAL) add_dependencies(${PROJECT_NAME} ${TARGET}) -set_target_properties(${PROJECT_NAME} PROPERTIES +set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE C VERSION ${PROJECT_VERSION} - PUBLIC_HEADER testcontainers-c.h + PUBLIC_HEADER testcontainers-native.h IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_LIB} INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/testcontainers-c/cmake.pc.in b/testcontainers-native/cmake.pc.in similarity index 100% rename from testcontainers-c/cmake.pc.in rename to testcontainers-native/cmake.pc.in diff --git a/testcontainers-c/go.mod b/testcontainers-native/go.mod similarity index 97% rename from testcontainers-c/go.mod rename to testcontainers-native/go.mod index 201e396..778b9ac 100644 --- a/testcontainers-c/go.mod +++ b/testcontainers-native/go.mod @@ -1,4 +1,4 @@ -module github.com/testcontainers/testcontainers-c +module github.com/testcontainers/testcontainers-native go 1.19 diff --git a/testcontainers-c/go.sum b/testcontainers-native/go.sum similarity index 100% rename from testcontainers-c/go.sum rename to testcontainers-native/go.sum diff --git a/testcontainers-c/testcontainers-c.go b/testcontainers-native/testcontainers-native.go similarity index 100% rename from testcontainers-c/testcontainers-c.go rename to testcontainers-native/testcontainers-native.go