Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple C++ test #650

Merged
merged 2 commits into from
Jun 4, 2020
Merged
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
9 changes: 9 additions & 0 deletions tests/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include tests/soter/soter.mk
include tests/tools/tools.mk
include tests/themis/themis.mk
include tests/themispp/themispp.mk
include tests/themispp_simple/themispp_simple.mk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I remember that RustThemis has some special relationship with included Makefiles, but this should be okay because tests/test.mk is not included when building by Cargo:

themis/Makefile

Lines 363 to 370 in a558d85

ifndef CARGO
include src/wrappers/themis/jsthemis/jsthemis.mk
include src/wrappers/themis/themispp/themispp.mk
include src/wrappers/themis/wasm/wasmthemis.mk
include jni/themis_jni.mk
include tests/test.mk
include tools/afl/fuzzy.mk
endif


soter_test: $(SOTER_TEST_BIN)
themis_test: $(THEMIS_TEST_BIN)
Expand Down Expand Up @@ -172,3 +173,11 @@ ifdef NPM_VERSION
endif

test_all: test prepare_tests_all test_cpp test_php test_python test_ruby test_js test_go test_rust

# requires all dependencies to be installed in system paths
test_cpp_simple: $(TEST_BIN_PATH)/themispp_simple_test
@echo "------------------------------------------------------------"
@echo "Running themissp simple test."
@echo "------------------------------------------------------------"
$(TEST_BIN_PATH)/themispp_simple_test
@echo "------------------------------------------------------------"
10 changes: 10 additions & 0 deletions tests/themispp_simple/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <themispp/secure_keygen.hpp>

int main()
{
std::vector<uint8_t> key = themispp::gen_sym_key();
if (key.empty()) {
return 1;
}
return 0;
}
28 changes: 28 additions & 0 deletions tests/themispp_simple/themispp_simple.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright (c) 2020 Cossack Labs Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

THEMISPP_SIMPLE_TEST_SOURCES = $(wildcard $(TEST_SRC_PATH)/themispp_simple/*.cpp)

# Link dynamically against Themis library in the standard system paths.
# We also need to link against Soter explicitly because of private imports.
$(TEST_BIN_PATH)/themispp_simple_test: CMD = $(CXX) -o $@ $(THEMISPP_SIMPLE_TEST_SOURCES) -lthemis -lsoter
$(TEST_BIN_PATH)/themispp_simple_test:
@mkdir -p $(@D)
@echo -n "build "
@$(BUILD_CMD)

clean_themispp_simple_test:
@rm -f $(TEST_BIN_PATH)/themispp_simple_test