Skip to content

Commit aea5252

Browse files
committed
Minor bug solved in logs.
1 parent d24f49c commit aea5252

File tree

5 files changed

+222
-1
lines changed

5 files changed

+222
-1
lines changed

source/log/source/log_aspect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int log_aspect_attach(log_aspect aspect, log_policy policy)
167167
size = LOG_ASPECT_POLICIES_MAX_SIZE;
168168
}
169169

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

172172
if (data == NULL)
173173
{

source/tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ add_subdirectory(cs_loader_test)
107107
add_subdirectory(node_loader_test)
108108
add_subdirectory(file_loader_test)
109109
add_subdirectory(loader_path_test)
110+
add_subdirectory(metacall_logs_test)
110111
add_subdirectory(metacall_load_memory_test)
111112
add_subdirectory(metacall_load_configuration_test)
112113
add_subdirectory(metacall_load_configuration_relative_test)
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#
2+
# Executable name and options
3+
#
4+
5+
# Target name
6+
set(target metacall-logs-test)
7+
message(STATUS "Test ${target}")
8+
9+
#
10+
# Compiler warnings
11+
#
12+
13+
include(Warnings)
14+
15+
#
16+
# Compiler security
17+
#
18+
19+
include(SecurityFlags)
20+
21+
#
22+
# Sources
23+
#
24+
25+
set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target}")
26+
set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")
27+
28+
set(sources
29+
${source_path}/main.cpp
30+
${source_path}/metacall_logs_test.cpp
31+
)
32+
33+
# Group source files
34+
set(header_group "Header Files (API)")
35+
set(source_group "Source Files")
36+
source_group_by_path(${include_path} "\\\\.h$|\\\\.hpp$"
37+
${header_group} ${headers})
38+
source_group_by_path(${source_path} "\\\\.cpp$|\\\\.c$|\\\\.h$|\\\\.hpp$"
39+
${source_group} ${sources})
40+
41+
#
42+
# Create executable
43+
#
44+
45+
# Build executable
46+
add_executable(${target}
47+
${sources}
48+
)
49+
50+
# Create namespaced alias
51+
add_executable(${META_PROJECT_NAME}::${target} ALIAS ${target})
52+
53+
#
54+
# Project options
55+
#
56+
57+
set_target_properties(${target}
58+
PROPERTIES
59+
${DEFAULT_PROJECT_OPTIONS}
60+
FOLDER "${IDE_FOLDER}"
61+
)
62+
63+
#
64+
# Include directories
65+
#
66+
67+
target_include_directories(${target}
68+
PRIVATE
69+
${DEFAULT_INCLUDE_DIRECTORIES}
70+
${PROJECT_BINARY_DIR}/source/include
71+
)
72+
73+
#
74+
# Libraries
75+
#
76+
77+
target_link_libraries(${target}
78+
PRIVATE
79+
${DEFAULT_LIBRARIES}
80+
81+
GTest
82+
83+
${META_PROJECT_NAME}::version
84+
${META_PROJECT_NAME}::preprocessor
85+
${META_PROJECT_NAME}::environment
86+
${META_PROJECT_NAME}::format
87+
${META_PROJECT_NAME}::log
88+
${META_PROJECT_NAME}::memory
89+
${META_PROJECT_NAME}::portability
90+
${META_PROJECT_NAME}::adt
91+
${META_PROJECT_NAME}::reflect
92+
${META_PROJECT_NAME}::dynlink
93+
${META_PROJECT_NAME}::detour
94+
${META_PROJECT_NAME}::serial
95+
${META_PROJECT_NAME}::configuration
96+
${META_PROJECT_NAME}::loader
97+
${META_PROJECT_NAME}::metacall
98+
)
99+
100+
#
101+
# Compile definitions
102+
#
103+
104+
target_compile_definitions(${target}
105+
PRIVATE
106+
${DEFAULT_COMPILE_DEFINITIONS}
107+
)
108+
109+
#
110+
# Compile options
111+
#
112+
113+
target_compile_options(${target}
114+
PRIVATE
115+
${DEFAULT_COMPILE_OPTIONS}
116+
)
117+
118+
#
119+
# Linker options
120+
#
121+
122+
target_link_libraries(${target}
123+
PRIVATE
124+
${DEFAULT_LINKER_OPTIONS}
125+
)
126+
127+
#
128+
# Define test
129+
#
130+
131+
add_test(NAME ${target}
132+
COMMAND $<TARGET_FILE:${target}>
133+
)
134+
135+
#
136+
# Define test properties
137+
#
138+
139+
set_property(TEST ${target}
140+
PROPERTY LABELS ${target}
141+
)
142+
143+
include(TestEnvironmentVariables)
144+
145+
test_environment_variables(${target}
146+
""
147+
${TESTS_ENVIRONMENT_VARIABLES}
148+
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* MetaCall Library by Parra Studios
3+
* A library for providing a foreign function interface calls.
4+
*
5+
* Copyright (C) 2016 - 2019 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
#include <gmock/gmock.h>
22+
23+
int main(int argc, char * argv[])
24+
{
25+
::testing::InitGoogleMock(&argc, argv);
26+
27+
return RUN_ALL_TESTS();
28+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* MetaCall Library by Parra Studios
3+
* A library for providing a foreign function interface calls.
4+
*
5+
* Copyright (C) 2016 - 2019 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
#include <gmock/gmock.h>
22+
23+
#include <metacall/metacall.h>
24+
25+
class metacall_logs_test : public testing::Test
26+
{
27+
public:
28+
};
29+
30+
TEST_F(metacall_logs_test, DefaultConstructor)
31+
{
32+
metacall_log_stdio_type log_stdio = { stdout };
33+
34+
metacall_print_info();
35+
36+
for (int i = 0; i < 50; ++i)
37+
{
38+
ASSERT_EQ((int) 0, (int) metacall_log(METACALL_LOG_STDIO, (void *)&log_stdio));
39+
}
40+
41+
ASSERT_EQ((int) 0, (int) metacall_initialize());
42+
43+
EXPECT_EQ((int) 0, (int) metacall_destroy());
44+
}

0 commit comments

Comments
 (0)