-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'code-coverage-for-master' into 'master'
Code coverage for master See merge request eriknellessen/encrypting-cloud-storages!6
- Loading branch information
Showing
9 changed files
with
122 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# - Try to find CMocka | ||
# Once done this will define | ||
# | ||
# CMOCKA_ROOT_DIR - Set this variable to the root installation of CMocka | ||
# | ||
# Read-Only variables: | ||
# CMOCKA_FOUND - system has CMocka | ||
# CMOCKA_INCLUDE_DIR - the CMocka include directory | ||
# CMOCKA_LIBRARIES - Link these to use CMocka | ||
# CMOCKA_DEFINITIONS - Compiler switches required for using CMocka | ||
# | ||
#============================================================================= | ||
# Copyright (c) 2011-2012 Andreas Schneider <[email protected]> | ||
# | ||
# Distributed under the OSI-approved BSD License (the "License"); | ||
# see accompanying file Copyright.txt for details. | ||
# | ||
# This software is distributed WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the License for more information. | ||
#============================================================================= | ||
# | ||
|
||
find_path(CMOCKA_INCLUDE_DIR | ||
NAMES | ||
cmocka.h | ||
PATHS | ||
${CMOCKA_ROOT_DIR}/include | ||
) | ||
|
||
find_library(CMOCKA_LIBRARY | ||
NAMES | ||
cmocka | ||
PATHS | ||
${CMOCKA_ROOT_DIR}/include | ||
) | ||
|
||
if(CMOCKA_LIBRARY) | ||
set(CMOCKA_LIBRARIES | ||
${CMOCKA_LIBRARIES} | ||
${CMOCKA_LIBRARY} | ||
) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(CMocka DEFAULT_MSG CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR) | ||
|
||
# show the CMOCKA_INCLUDE_DIR and CMOCKA_LIBRARIES variables only in the advanced view | ||
mark_as_advanced(CMOCKA_INCLUDE_DIR CMOCKA_LIBRARIES) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.0.2) | ||
|
||
add_executable(data_operations_test data_operations_test.c) | ||
target_link_libraries(data_operations_test criterion) | ||
target_link_libraries(data_operations_test cmocka) | ||
|
||
add_test(NAME data_operations_test WORKING_DIRECTORY fuseecs/test COMMAND ./data_operations_test) | ||
|
||
add_executable(gpg_operations_test ../gpg_operations.c gpg_operations_test.c) | ||
set_target_properties(gpg_operations_test | ||
PROPERTIES | ||
LINK_FLAGS "-g -Wl,--wrap=access" | ||
) | ||
target_link_libraries(gpg_operations_test cmocka ${GPGME_VANILLA_LIBRARIES} showSigner) | ||
|
||
add_test(NAME gpg_operations_test WORKING_DIRECTORY fuseecs/test COMMAND ./gpg_operations_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
#include <string.h> | ||
#include <criterion/criterion.h> | ||
#include <criterion/new/assert.h> | ||
#include <stdarg.h> | ||
#include <stddef.h> | ||
#include <setjmp.h> | ||
#include <cmocka.h> | ||
#include "../data_operations.h" | ||
|
||
Test(data_operations_test_suite, local_string_concatenation_test) { | ||
static void test_local_string_concatenation(void **state) { | ||
LOCAL_STR_CAT("foo", "bar", concatenated_string) | ||
cr_assert(eq(str, concatenated_string, "foobar"), "Did not concatenate strings as expected!"); | ||
assert_string_equal(concatenated_string, "foobar"); | ||
} | ||
|
||
int main(void) { | ||
const struct CMUnitTest tests[] = { | ||
cmocka_unit_test(test_local_string_concatenation), | ||
}; | ||
return cmocka_run_group_tests(tests, NULL, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdarg.h> | ||
#include <stddef.h> | ||
#include <setjmp.h> | ||
#include <cmocka.h> | ||
#include "../gpg_operations.h" | ||
|
||
int __real_access(const char *pathname, int how); | ||
int __wrap_access(const char *pathname, int how) { | ||
if (strlen(pathname) > 5 && !strcmp(pathname + strlen(pathname) - 5, ".gcda")) { | ||
return __real_access(pathname, how); | ||
} | ||
|
||
return mock_type(int); | ||
} | ||
|
||
static void test_directory_contains_authentic_file(void **state) { | ||
will_return(__wrap_access, 1); | ||
|
||
char *encrypted_directory = "/foo/"; | ||
char *file_name = "bar.txt"; | ||
int return_value = directory_contains_authentic_file(encrypted_directory, file_name); | ||
assert_int_equal(return_value, 0); | ||
} | ||
|
||
int main(void) { | ||
const struct CMUnitTest tests[] = { | ||
cmocka_unit_test(test_directory_contains_authentic_file), | ||
}; | ||
return cmocka_run_group_tests(tests, NULL, NULL); | ||
} |