Skip to content

Commit eb1f1c5

Browse files
authored
4181 tag c++ tests (#4472)
* Setting up python script * Tests running globally with filter * updated some comments * tests tagged * Tests and build working * Changes for windows * Docker file and run script for tests * Clean up of comments * Some comments fixes. * Text fixes and one bug fix
1 parent 9d1011c commit eb1f1c5

File tree

114 files changed

+1259
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1259
-391
lines changed

Diff for: cpp/.dockerignore

-7
This file was deleted.

Diff for: cpp/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build/
22
cmake-build*/
3-
.vs/
3+
.vs/
4+
build_tests

Diff for: cpp/Dockerfile

+52-33
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,59 @@
1-
# This DockerFile was copied from the AWS SDK for C++.
2-
# https://github.com/aws/aws-sdk-cpp/blob/master/CI/docker-file/Ubuntu/20.04/Dockerfile
3-
# Additional run steps were added.
4-
5-
# Using official ubuntu docker image
6-
FROM ubuntu:20.04
7-
8-
# Install git, zip, python-pip, cmake, g++, zlib, libssl, libcurl, java, maven via apt
9-
# Specify DEBIAN_FRONTEND and TZ to prevent tzdata hanging
10-
RUN apt-get update && \
11-
apt-get upgrade -y && \
12-
DEBIAN_FRONTEND="noninteractive" TZ="America/Los_Angeles" apt-get install -y git zip wget python3 python3-pip cmake g++ zlib1g-dev libssl-dev libcurl4-openssl-dev openjdk-8-jdk doxygen ninja-build
13-
14-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
15-
16-
# Install maven
17-
RUN apt-get install -y maven
18-
19-
# Install awscli
20-
#RUN pip install awscli --upgrade
21-
22-
RUN mkdir /src
23-
COPY . /src/
24-
25-
ENV SERVICES="autoscaling;ec2;iam;dynamodb;glue;lambda;monitoring;s3;sts"
26-
27-
RUN mkdir /src/aws && \
28-
cd /src/aws && \
29-
git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp && \
30-
cd aws-sdk-cpp && \
31-
mkdir build && \
1+
# Build this docker file from the sdk example code root directory in order to access the resources folder.
2+
#
3+
# To build the docker image, run the following command from the shell.
4+
# 'docker build -f cpp/Dockerfile -t <a_docker_file_name> .'
5+
#
6+
# The following command will run the docker image, copying your AWS credentials.
7+
# 'docker run -it --volume ~/.aws/credentials:/root/.aws/credentials <a_docker_file_name>'
8+
9+
FROM amazonlinux:2022
10+
11+
USER root
12+
13+
# Set up the dependencies.
14+
RUN \
15+
yum update -y && \
16+
yum install -y gcc gcc-c++ make cmake libcurl-devel openssl-devel libuuid-devel pulseaudio-libs-devel git && \
17+
yum clean all
18+
19+
# Build only the services needed for example code.
20+
ENV SERVICES="acm;autoscaling;cloudtrail;codebuild;codecommit;cognito-idp;dynamodb;ec2;elasticache;elasticbeanstalk"
21+
ENV SERVICES=${SERVICES}";elasticfilesystem;email;events;glacier;glue;guardduty;iam;kinesis;lambda;logs;monitoring"
22+
ENV SERVICES=${SERVICES}";monitoring;neptune;rds-data;redshift;s3;s3-crt;s3-encryption;secretsmanager;sesv2;sns;sqs"
23+
ENV SERVICES=${SERVICES}";storagegateway;sts;transfer;transcribe;transcribestreaming"
24+
25+
RUN echo ${SERVICES}
26+
27+
# Build aws-sdk-cpp, building only the modules listed in SERVICES using the BUILD_ONLY argument.
28+
RUN \
29+
cd /usr/local && \
30+
git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git && \
31+
cd aws-sdk-cpp && \
32+
mkdir -p build && \
33+
cd build && \
34+
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY=${SERVICES} -DENABLE_TESTING=ON .. && \
35+
make --jobs=3 install && \
36+
cd /usr/local
37+
38+
# Install googletest.
39+
RUN \
40+
git clone https://github.com/google/googletest.git -b v1.13.0 && \
41+
cd googletest && \
42+
mkdir build && \
3243
cd build && \
33-
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY=${SERVICES} -DENABLE_TESTING=OFF && \
44+
cmake .. -DBUILD_GMOCK=OFF && \
3445
make && \
3546
make install
3647

37-
WORKDIR /src
48+
# Copy the C++ example code.
49+
RUN mkdir -p /src/cpp
50+
COPY cpp /src/cpp/
51+
52+
# The sample files are needed for some of the automated tests.
53+
RUN mkdir -p /src/resources/sample_files
54+
COPY resources/sample_files /src/resources/sample_files
55+
56+
WORKDIR /src/cpp/
3857

3958
CMD ["bash"]
4059

Diff for: cpp/Dockerfile.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/build/
2+
**/cmake-build*/
3+
**/.idea/
4+
**/build_tests/

Diff for: cpp/build_all_examples.sh

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
2-
# Run the automated tests for cpp.
2+
# Build the AWS example code for C++ .
33

44

5-
TEST_CMAKE_FILES=$(ls example_code/*/CMakeLists.txt)
6-
TEST_CMAKE_FILES=($TEST_CMAKE_FILES)
7-
echo "TEST_CMAKE_FILES ${TEST_CMAKE_FILES}"
5+
CMAKE_FILES=$(ls example_code/*/CMakeLists.txt)
6+
CMAKE_FILES=($CMAKE_FILES)
7+
echo "CMAKE_FILES ${CMAKE_FILES}"
88

9-
len=${#TEST_CMAKE_FILES[@]}
9+
len=${#CMAKE_FILES[@]}
1010
echo "len ${len}"
1111
if [[ ${len} == 0 ]]; then
1212
echo "No CMake files found!"
@@ -20,7 +20,7 @@ echo "BUILD_DIR ${BUILD_DIR}"
2020
mkdir -pv ${BUILD_DIR}
2121

2222
HAD_ERROR=false
23-
for MAKE_FILE in "${TEST_CMAKE_FILES[@]}"
23+
for MAKE_FILE in "${CMAKE_FILES[@]}"
2424
do
2525
SOURCE_DIR="${MAKE_FILE%CMakeLists.txt}"
2626
MODULE_BUILD_DIR="${BUILD_DIR}/${SOURCE_DIR}"
@@ -34,16 +34,20 @@ do
3434
HAD_ERROR=true
3535
continue
3636
fi
37-
make
37+
cmake --build .
3838
if [ $? != 0 ]; then
3939
echo "ERROR with make ${$?}"
4040
HAD_ERROR=true
4141
continue
4242
fi
4343
done
4444

45-
if [ HAD_ERROR ]; then
45+
echo
46+
47+
if [ $HAD_ERROR = true ]; then
48+
echo "The build had errors."
4649
exit 1
4750
else
51+
echo "The build was successful with no errors."
4852
exit 0
49-
fi
53+
fi

Diff for: cpp/example_code/autoscaling/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set(SERVICE_COMPONENTS autoscaling ec2 monitoring)
1010
# Set this project's name.
1111
project("${SERVICE_NAME}-examples")
1212

13-
#Set the location of where Windows can find the installed libraries of the SDK.
13+
# Set the location of where Windows can find the installed libraries of the SDK.
1414
if(MSVC)
1515
string(REPLACE ";" "/aws-cpp-sdk-all;" SYSTEM_MODULE_PATH "${CMAKE_SYSTEM_PREFIX_PATH}/aws-cpp-sdk-all")
1616
list(APPEND CMAKE_PREFIX_PATH ${SYSTEM_MODULE_PATH})

0 commit comments

Comments
 (0)