Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions demo/generic-container/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
4 changes: 2 additions & 2 deletions demo/generic-container/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions demo/generic-container/generic_container_demo.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <stdio.h>
#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);
Expand All @@ -31,4 +31,3 @@ int main() {
printf("Server Response: HTTP-%d\n%s\n\n", response.r0, response.r1);
return 0;
}

6 changes: 3 additions & 3 deletions demo/google-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions demo/google-test/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions demo/google-test/test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <iostream>
#include <string>
#include <gtest/gtest.h>
#include "testcontainers-c.h"
#include "testcontainers-native.h"

class WireMockTestContainer : public ::testing::Test {

Expand All @@ -11,18 +11,18 @@ 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);
tc_with_file(requestId, "test_data/hello.json", "/home/wiremock/mappings/hello.json");
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;
};

Expand All @@ -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";
}

Expand Down
14 changes: 7 additions & 7 deletions demo/wiremock/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
4 changes: 2 additions & 2 deletions demo/wiremock/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions demo/wiremock/wiremock_module_demo.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <stdio.h>
#include <string.h>
#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();
Expand Down Expand Up @@ -45,4 +45,3 @@ int main() {
printf("Server Response: HTTP-%d\n%s\n\n", response.r0, response.r1);
return 0;
}

2 changes: 1 addition & 1 deletion docs/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
8 changes: 4 additions & 4 deletions docs/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

![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
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.

Expand All @@ -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.
Loading