Skip to content

Commit c3e19d6

Browse files
committed
add suse-example
1 parent 338acb3 commit c3e19d6

File tree

5 files changed

+108
-0
lines changed

5 files changed

+108
-0
lines changed

.github/workflows/test-build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: test-build.yml
2+
on:
3+
push: {}
4+
jobs:
5+
simple-build:
6+
runs-on: ubuntu-24.04-arm
7+
steps:
8+
- name: checkout
9+
uses: actions/checkout@v2
10+
with:
11+
path: aws-sdk-cpp
12+
submodules: recursive
13+
- name: build
14+
run: |
15+
cd aws-sdk-cpp/tools/CI/suse-example
16+
./replicate.sh
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
project(sdk_usage_workspace)
3+
set(CMAKE_CXX_STANDARD 20)
4+
5+
find_package(AWSSDK REQUIRED COMPONENTS core)
6+
find_package(OpenSSL REQUIRED)
7+
8+
add_executable(${PROJECT_NAME} main.cpp)
9+
target_link_libraries(${PROJECT_NAME} PRIVATE ${AWSSDK_LINK_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)

tools/CI/suse-example/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
project(sdk_usage_workspace)
3+
set(CMAKE_CXX_STANDARD 20)
4+
5+
find_package(AWSSDK REQUIRED COMPONENTS core)
6+
find_package(OpenSSL REQUIRED)
7+
8+
add_executable(${PROJECT_NAME} main.cpp)
9+
target_link_libraries(${PROJECT_NAME} PRIVATE ${AWSSDK_LINK_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)

tools/CI/suse-example/main.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <aws/core/Aws.h>
4+
#include <aws/core/utils/HashingUtils.h>
5+
#include <aws/core/utils/memory/stl/AWSString.h>
6+
#include <openssl/opensslv.h>
7+
8+
int main(int argc, char* argv[]) {
9+
// Initialize AWS SDK
10+
Aws::SDKOptions options;
11+
Aws::InitAPI(options);
12+
13+
// Print platform and OpenSSL info
14+
std::cout << "=== Platform Information ===" << std::endl;
15+
#ifdef __aarch64__
16+
std::cout << "Architecture: ARM64 (aarch64)" << std::endl;
17+
#elif defined(__x86_64__)
18+
std::cout << "Architecture: x86_64" << std::endl;
19+
#else
20+
std::cout << "Architecture: Unknown" << std::endl;
21+
#endif
22+
23+
std::cout << "OpenSSL version: " << OPENSSL_VERSION_TEXT << std::endl;
24+
std::cout << std::endl;
25+
26+
// Test payload (similar to DeleteObjects XML)
27+
std::string test_payload =
28+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
29+
"<Delete>"
30+
"<Object><Key>test-object-1</Key></Object>"
31+
"<Object><Key>test-object-2</Key></Object>"
32+
"</Delete>";
33+
34+
std::cout << "=== MD5 Calculation Test ===" << std::endl;
35+
std::cout << "Test payload: " << test_payload << std::endl;
36+
std::cout << "Payload size: " << test_payload.length() << " bytes" << std::endl;
37+
std::cout << std::endl;
38+
39+
// Calculate MD5 using AWS SDK
40+
std::cout << "Calling Aws::Utils::HashingUtils::CalculateMD5()..." << std::endl;
41+
auto md5_bytebuffer = Aws::Utils::HashingUtils::CalculateMD5(test_payload);
42+
43+
std::cout << "MD5 ByteBuffer length: " << md5_bytebuffer.GetLength()
44+
<< " (expected: 16)" << std::endl;
45+
46+
if (md5_bytebuffer.GetLength() == 0) {
47+
std::cout << "ERROR: CalculateMD5() returned EMPTY ByteBuffer!" << std::endl;
48+
} else if (md5_bytebuffer.GetLength() == 16) {
49+
std::cout << "✓ SUCCESS: MD5 calculation returned correct length" << std::endl;
50+
51+
// Calculate Base64 encoding
52+
auto base64_md5 = Aws::Utils::HashingUtils::Base64Encode(md5_bytebuffer);
53+
std::cout << "Base64 MD5: " << base64_md5.c_str() << std::endl;
54+
std::cout << "Base64 length: " << base64_md5.length() << " (expected: 24)" << std::endl;
55+
} else {
56+
std::cout << "ERROR: Unexpected MD5 ByteBuffer length!" << std::endl;
57+
}
58+
59+
std::cout << std::endl;
60+
61+
// Cleanup AWS SDK
62+
Aws::ShutdownAPI(options);
63+
64+
return (md5_bytebuffer.GetLength() == 16) ? 0 : 1;
65+
}

tools/CI/suse-example/replicate.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/zsh
2+
3+
set -u
4+
5+
# build image
6+
docker build -t test-image .
7+
8+
# run example
9+
docker run --name test-image test-image /sdk-example/build/sdk_usage_workspace

0 commit comments

Comments
 (0)