Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmp_tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominik Loidolt
cmp_tool
Commits
3c309cdf
Commit
3c309cdf
authored
1 year ago
by
Dominik Loidolt
Browse files
Options
Downloads
Patches
Plain Diff
Fix mock of malloc function in test_cmp_max_used_bits_list.c
parent
dac800fc
No related branches found
No related tags found
1 merge request
!30
Enhanced Error Handling in Chunk Compression Functions
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cmp_max_used_bits/test_cmp_max_used_bits_list.c
+10
-5
10 additions, 5 deletions
test/cmp_max_used_bits/test_cmp_max_used_bits_list.c
with
10 additions
and
5 deletions
test/cmp_max_used_bits/test_cmp_max_used_bits_list.c
+
10
−
5
View file @
3c309cdf
...
@@ -17,22 +17,28 @@
...
@@ -17,22 +17,28 @@
*/
*/
#if !defined(__sparc__) && !defined(_WIN32) && !defined(_WIN64)
# define MAKE_MALLOC_FAIL_TEST
# define _GNU_SOURCE
# include <dlfcn.h>
# include <stdlib.h>
#endif
#include
<string.h>
#include
<string.h>
#include
<unity.h>
#include
<unity.h>
#include
<cmp_max_used_bits_list.h>
#include
<cmp_max_used_bits_list.h>
#if
n
def
__sparc__
#ifdef
MAKE_MALLOC_FAIL_TEST
/* if set the mock malloc will fail (return NULL) */
/* if set the mock malloc will fail (return NULL) */
static
int
malloc_fail
;
static
int
malloc_fail
;
/*
/*
* mock of the malloc function; can controlled with the global malloc_fail variable
* mock of the malloc function; can controlled with the global malloc_fail variable
* see:https://jayconrod.com/posts/23/tutorial--function-interposition-in-linux
* see:
https://jayconrod.com/posts/23/tutorial--function-interposition-in-linux
*/
*/
#include
<dlfcn.h>
void
*
malloc
(
size_t
size
)
void
*
malloc
(
size_t
size
)
{
{
...
@@ -47,7 +53,6 @@ void* malloc(size_t size)
...
@@ -47,7 +53,6 @@ void* malloc(size_t size)
TEST_ASSERT_NOT_NULL
(
real_malloc
);
TEST_ASSERT_NOT_NULL
(
real_malloc
);
}
}
fprintf
(
stderr
,
"malloc(%zu)
\n
"
,
size
);
return
real_malloc
(
size
);
return
real_malloc
(
size
);
}
}
#endif
#endif
...
@@ -181,7 +186,7 @@ void test_cmp_max_used_bits_list(void)
...
@@ -181,7 +186,7 @@ void test_cmp_max_used_bits_list(void)
cmp_max_used_bits_list_empty
();
cmp_max_used_bits_list_empty
();
/* error case */
/* error case */
#if
n
def
__sparc__
#ifdef
MAKE_MALLOC_FAIL_TEST
malloc_fail
=
1
;
malloc_fail
=
1
;
return_val
=
cmp_max_used_bits_list_add
(
&
i_36
);
return_val
=
cmp_max_used_bits_list_add
(
&
i_36
);
TEST_ASSERT_EQUAL_INT
(
return_val
,
-
1
);
TEST_ASSERT_EQUAL_INT
(
return_val
,
-
1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment