Skip to content

Commit

Permalink
Minor bug solved in logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Dec 3, 2019
1 parent d24f49c commit aea5252
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/log/source/log_aspect.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ int log_aspect_attach(log_aspect aspect, log_policy policy)
size = LOG_ASPECT_POLICIES_MAX_SIZE;
}

data = realloc(aspect->policies, size);
data = realloc(aspect->policies, sizeof(log_policy) * size);

if (data == NULL)
{
Expand Down
1 change: 1 addition & 0 deletions source/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ add_subdirectory(cs_loader_test)
add_subdirectory(node_loader_test)
add_subdirectory(file_loader_test)
add_subdirectory(loader_path_test)
add_subdirectory(metacall_logs_test)
add_subdirectory(metacall_load_memory_test)
add_subdirectory(metacall_load_configuration_test)
add_subdirectory(metacall_load_configuration_relative_test)
Expand Down
148 changes: 148 additions & 0 deletions source/tests/metacall_logs_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#
# Executable name and options
#

# Target name
set(target metacall-logs-test)
message(STATUS "Test ${target}")

#
# Compiler warnings
#

include(Warnings)

#
# Compiler security
#

include(SecurityFlags)

#
# Sources
#

set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target}")
set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")

set(sources
${source_path}/main.cpp
${source_path}/metacall_logs_test.cpp
)

# Group source files
set(header_group "Header Files (API)")
set(source_group "Source Files")
source_group_by_path(${include_path} "\\\\.h$|\\\\.hpp$"
${header_group} ${headers})
source_group_by_path(${source_path} "\\\\.cpp$|\\\\.c$|\\\\.h$|\\\\.hpp$"
${source_group} ${sources})

#
# Create executable
#

# Build executable
add_executable(${target}
${sources}
)

# Create namespaced alias
add_executable(${META_PROJECT_NAME}::${target} ALIAS ${target})

#
# Project options
#

set_target_properties(${target}
PROPERTIES
${DEFAULT_PROJECT_OPTIONS}
FOLDER "${IDE_FOLDER}"
)

#
# Include directories
#

target_include_directories(${target}
PRIVATE
${DEFAULT_INCLUDE_DIRECTORIES}
${PROJECT_BINARY_DIR}/source/include
)

#
# Libraries
#

target_link_libraries(${target}
PRIVATE
${DEFAULT_LIBRARIES}

GTest

${META_PROJECT_NAME}::version
${META_PROJECT_NAME}::preprocessor
${META_PROJECT_NAME}::environment
${META_PROJECT_NAME}::format
${META_PROJECT_NAME}::log
${META_PROJECT_NAME}::memory
${META_PROJECT_NAME}::portability
${META_PROJECT_NAME}::adt
${META_PROJECT_NAME}::reflect
${META_PROJECT_NAME}::dynlink
${META_PROJECT_NAME}::detour
${META_PROJECT_NAME}::serial
${META_PROJECT_NAME}::configuration
${META_PROJECT_NAME}::loader
${META_PROJECT_NAME}::metacall
)

#
# Compile definitions
#

target_compile_definitions(${target}
PRIVATE
${DEFAULT_COMPILE_DEFINITIONS}
)

#
# Compile options
#

target_compile_options(${target}
PRIVATE
${DEFAULT_COMPILE_OPTIONS}
)

#
# Linker options
#

target_link_libraries(${target}
PRIVATE
${DEFAULT_LINKER_OPTIONS}
)

#
# Define test
#

add_test(NAME ${target}
COMMAND $<TARGET_FILE:${target}>
)

#
# Define test properties
#

set_property(TEST ${target}
PROPERTY LABELS ${target}
)

include(TestEnvironmentVariables)

test_environment_variables(${target}
""
${TESTS_ENVIRONMENT_VARIABLES}
)
28 changes: 28 additions & 0 deletions source/tests/metacall_logs_test/source/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* MetaCall Library by Parra Studios
* A library for providing a foreign function interface calls.
*
* Copyright (C) 2016 - 2019 Vicente Eduardo Ferrer Garcia <[email protected]>
*
* 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.
*
*/

#include <gmock/gmock.h>

int main(int argc, char * argv[])
{
::testing::InitGoogleMock(&argc, argv);

return RUN_ALL_TESTS();
}
44 changes: 44 additions & 0 deletions source/tests/metacall_logs_test/source/metacall_logs_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* MetaCall Library by Parra Studios
* A library for providing a foreign function interface calls.
*
* Copyright (C) 2016 - 2019 Vicente Eduardo Ferrer Garcia <[email protected]>
*
* 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.
*
*/

#include <gmock/gmock.h>

#include <metacall/metacall.h>

class metacall_logs_test : public testing::Test
{
public:
};

TEST_F(metacall_logs_test, DefaultConstructor)
{
metacall_log_stdio_type log_stdio = { stdout };

metacall_print_info();

for (int i = 0; i < 50; ++i)
{
ASSERT_EQ((int) 0, (int) metacall_log(METACALL_LOG_STDIO, (void *)&log_stdio));
}

ASSERT_EQ((int) 0, (int) metacall_initialize());

EXPECT_EQ((int) 0, (int) metacall_destroy());
}

0 comments on commit aea5252

Please sign in to comment.