Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
32f8ddf7
Commit
32f8ddf7
authored
Mar 22, 2019
by
Heikki Linnakangas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make printf format strings in test_integerset portable.
Use UINT64_FORMAT for printing uint64s.
parent
608c5f43
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
26 deletions
+28
-26
src/test/modules/test_integerset/test_integerset.c
src/test/modules/test_integerset/test_integerset.c
+28
-26
No files found.
src/test/modules/test_integerset/test_integerset.c
View file @
32f8ddf7
...
@@ -207,8 +207,8 @@ test_pattern(const test_spec *spec)
...
@@ -207,8 +207,8 @@ test_pattern(const test_spec *spec)
endtime
=
GetCurrentTimestamp
();
endtime
=
GetCurrentTimestamp
();
if
(
intset_test_stats
)
if
(
intset_test_stats
)
fprintf
(
stderr
,
"added
%lu values in %lu
ms
\n
"
,
fprintf
(
stderr
,
"added
"
UINT64_FORMAT
" values in %d
ms
\n
"
,
spec
->
num_values
,
(
endtime
-
starttime
)
/
1000
);
spec
->
num_values
,
(
int
)
(
endtime
-
starttime
)
/
1000
);
/*
/*
* Print stats on the amount of memory used.
* Print stats on the amount of memory used.
...
@@ -228,7 +228,7 @@ test_pattern(const test_spec *spec)
...
@@ -228,7 +228,7 @@ test_pattern(const test_spec *spec)
* MemoryContextStats().
* MemoryContextStats().
*/
*/
mem_usage
=
intset_memory_usage
(
intset
);
mem_usage
=
intset_memory_usage
(
intset
);
fprintf
(
stderr
,
"intset_memory_usage() reported
%lu
(%0.2f bytes / integer)
\n
"
,
fprintf
(
stderr
,
"intset_memory_usage() reported
"
UINT64_FORMAT
"
(%0.2f bytes / integer)
\n
"
,
mem_usage
,
(
double
)
mem_usage
/
spec
->
num_values
);
mem_usage
,
(
double
)
mem_usage
/
spec
->
num_values
);
MemoryContextStats
(
intset_ctx
);
MemoryContextStats
(
intset_ctx
);
...
@@ -237,7 +237,7 @@ test_pattern(const test_spec *spec)
...
@@ -237,7 +237,7 @@ test_pattern(const test_spec *spec)
/* Check that intset_get_num_entries works */
/* Check that intset_get_num_entries works */
n
=
intset_num_entries
(
intset
);
n
=
intset_num_entries
(
intset
);
if
(
n
!=
spec
->
num_values
)
if
(
n
!=
spec
->
num_values
)
elog
(
ERROR
,
"intset_num_entries returned
%lu, expected %lu"
,
n
,
spec
->
num_values
);
elog
(
ERROR
,
"intset_num_entries returned
"
UINT64_FORMAT
", expected "
UINT64_FORMAT
,
n
,
spec
->
num_values
);
/*
/*
* Test random-access probes with intset_is_member()
* Test random-access probes with intset_is_member()
...
@@ -279,11 +279,12 @@ test_pattern(const test_spec *spec)
...
@@ -279,11 +279,12 @@ test_pattern(const test_spec *spec)
b
=
intset_is_member
(
intset
,
x
);
b
=
intset_is_member
(
intset
,
x
);
if
(
b
!=
expected
)
if
(
b
!=
expected
)
elog
(
ERROR
,
"mismatch at
%lu
: %d vs %d"
,
x
,
b
,
expected
);
elog
(
ERROR
,
"mismatch at
"
UINT64_FORMAT
"
: %d vs %d"
,
x
,
b
,
expected
);
}
}
endtime
=
GetCurrentTimestamp
();
endtime
=
GetCurrentTimestamp
();
if
(
intset_test_stats
)
if
(
intset_test_stats
)
fprintf
(
stderr
,
"probed %lu values in %lu ms
\n
"
,
n
,
(
endtime
-
starttime
)
/
1000
);
fprintf
(
stderr
,
"probed "
UINT64_FORMAT
" values in %d ms
\n
"
,
n
,
(
int
)
(
endtime
-
starttime
)
/
1000
);
/*
/*
* Test iterator
* Test iterator
...
@@ -304,19 +305,20 @@ test_pattern(const test_spec *spec)
...
@@ -304,19 +305,20 @@ test_pattern(const test_spec *spec)
break
;
break
;
if
(
x
!=
expected
)
if
(
x
!=
expected
)
elog
(
ERROR
,
"iterate returned wrong value; got
%lu, expected %lu"
,
x
,
expected
);
elog
(
ERROR
,
"iterate returned wrong value; got
"
UINT64_FORMAT
", expected "
UINT64_FORMAT
,
x
,
expected
);
n
++
;
n
++
;
}
}
last_int
+=
spec
->
spacing
;
last_int
+=
spec
->
spacing
;
}
}
endtime
=
GetCurrentTimestamp
();
endtime
=
GetCurrentTimestamp
();
if
(
intset_test_stats
)
if
(
intset_test_stats
)
fprintf
(
stderr
,
"iterated %lu values in %lu ms
\n
"
,
n
,
(
endtime
-
starttime
)
/
1000
);
fprintf
(
stderr
,
"iterated "
UINT64_FORMAT
" values in %d ms
\n
"
,
n
,
(
int
)
(
endtime
-
starttime
)
/
1000
);
if
(
n
<
spec
->
num_values
)
if
(
n
<
spec
->
num_values
)
elog
(
ERROR
,
"iterator stopped short after
%lu entries, expected %lu"
,
n
,
spec
->
num_values
);
elog
(
ERROR
,
"iterator stopped short after
"
UINT64_FORMAT
" entries, expected "
UINT64_FORMAT
,
n
,
spec
->
num_values
);
if
(
n
>
spec
->
num_values
)
if
(
n
>
spec
->
num_values
)
elog
(
ERROR
,
"iterator returned
%lu entries, %lu
was expected"
,
n
,
spec
->
num_values
);
elog
(
ERROR
,
"iterator returned
"
UINT64_FORMAT
" entries, "
UINT64_FORMAT
"
was expected"
,
n
,
spec
->
num_values
);
MemoryContextDelete
(
intset_ctx
);
MemoryContextDelete
(
intset_ctx
);
}
}
...
@@ -332,7 +334,7 @@ test_single_value(uint64 value)
...
@@ -332,7 +334,7 @@ test_single_value(uint64 value)
uint64
num_entries
;
uint64
num_entries
;
bool
found
;
bool
found
;
elog
(
NOTICE
,
"testing intset with single value
%lu"
,
value
);
elog
(
NOTICE
,
"testing intset with single value
"
UINT64_FORMAT
,
value
);
/* Create the set. */
/* Create the set. */
intset
=
intset_create
();
intset
=
intset_create
();
...
@@ -341,7 +343,7 @@ test_single_value(uint64 value)
...
@@ -341,7 +343,7 @@ test_single_value(uint64 value)
/* Test intset_get_num_entries() */
/* Test intset_get_num_entries() */
num_entries
=
intset_num_entries
(
intset
);
num_entries
=
intset_num_entries
(
intset
);
if
(
num_entries
!=
1
)
if
(
num_entries
!=
1
)
elog
(
ERROR
,
"intset_num_entries returned
%lu, expected %lu"
,
num_entries
,
1L
);
elog
(
ERROR
,
"intset_num_entries returned
"
UINT64_FORMAT
", expected 1"
,
num_entries
);
/*
/*
* Test intset_is_member() at various special values, like 0 and and
* Test intset_is_member() at various special values, like 0 and and
...
@@ -362,11 +364,11 @@ test_single_value(uint64 value)
...
@@ -362,11 +364,11 @@ test_single_value(uint64 value)
intset_begin_iterate
(
intset
);
intset_begin_iterate
(
intset
);
found
=
intset_iterate_next
(
intset
,
&
x
);
found
=
intset_iterate_next
(
intset
,
&
x
);
if
(
!
found
||
x
!=
value
)
if
(
!
found
||
x
!=
value
)
elog
(
ERROR
,
"intset_iterate_next failed for
%lu"
,
x
);
elog
(
ERROR
,
"intset_iterate_next failed for
"
UINT64_FORMAT
,
x
);
found
=
intset_iterate_next
(
intset
,
&
x
);
found
=
intset_iterate_next
(
intset
,
&
x
);
if
(
found
)
if
(
found
)
elog
(
ERROR
,
"intset_iterate_next failed
%lu"
,
x
);
elog
(
ERROR
,
"intset_iterate_next failed
"
UINT64_FORMAT
,
x
);
}
}
/*
/*
...
@@ -391,7 +393,7 @@ test_single_value_and_filler(uint64 value, uint64 filler_min, uint64 filler_max)
...
@@ -391,7 +393,7 @@ test_single_value_and_filler(uint64 value, uint64 filler_min, uint64 filler_max)
uint64
num_entries
=
0
;
uint64
num_entries
=
0
;
uint64
mem_usage
;
uint64
mem_usage
;
elog
(
NOTICE
,
"testing intset with value
%lu, and all between %lu and %lu"
,
elog
(
NOTICE
,
"testing intset with value
"
UINT64_FORMAT
", and all between "
UINT64_FORMAT
" and "
UINT64_FORMAT
,
value
,
filler_min
,
filler_max
);
value
,
filler_min
,
filler_max
);
intset
=
intset_create
();
intset
=
intset_create
();
...
@@ -418,7 +420,7 @@ test_single_value_and_filler(uint64 value, uint64 filler_min, uint64 filler_max)
...
@@ -418,7 +420,7 @@ test_single_value_and_filler(uint64 value, uint64 filler_min, uint64 filler_max)
/* Test intset_get_num_entries() */
/* Test intset_get_num_entries() */
num_entries
=
intset_num_entries
(
intset
);
num_entries
=
intset_num_entries
(
intset
);
if
(
num_entries
!=
n
)
if
(
num_entries
!=
n
)
elog
(
ERROR
,
"intset_num_entries returned
%lu, expected %lu"
,
num_entries
,
n
);
elog
(
ERROR
,
"intset_num_entries returned
"
UINT64_FORMAT
", expected "
UINT64_FORMAT
,
num_entries
,
n
);
/*
/*
* Test intset_is_member() at various spots, at and around the values that
* Test intset_is_member() at various spots, at and around the values that
...
@@ -456,15 +458,15 @@ test_single_value_and_filler(uint64 value, uint64 filler_min, uint64 filler_max)
...
@@ -456,15 +458,15 @@ test_single_value_and_filler(uint64 value, uint64 filler_min, uint64 filler_max)
{
{
found
=
intset_iterate_next
(
intset
,
&
x
);
found
=
intset_iterate_next
(
intset
,
&
x
);
if
(
!
found
||
x
!=
iter_expected
[
i
])
if
(
!
found
||
x
!=
iter_expected
[
i
])
elog
(
ERROR
,
"intset_iterate_next failed for
%lu"
,
x
);
elog
(
ERROR
,
"intset_iterate_next failed for
"
UINT64_FORMAT
,
x
);
}
}
found
=
intset_iterate_next
(
intset
,
&
x
);
found
=
intset_iterate_next
(
intset
,
&
x
);
if
(
found
)
if
(
found
)
elog
(
ERROR
,
"intset_iterate_next failed
%lu"
,
x
);
elog
(
ERROR
,
"intset_iterate_next failed
"
UINT64_FORMAT
,
x
);
mem_usage
=
intset_memory_usage
(
intset
);
mem_usage
=
intset_memory_usage
(
intset
);
if
(
mem_usage
<
5000
||
mem_usage
>
500000000
)
if
(
mem_usage
<
5000
||
mem_usage
>
500000000
)
elog
(
ERROR
,
"intset_memory_usage() reported suspic
ous value: %lu"
,
mem_usage
);
elog
(
ERROR
,
"intset_memory_usage() reported suspic
ious value: "
UINT64_FORMAT
,
mem_usage
);
}
}
/*
/*
...
@@ -485,7 +487,7 @@ check_with_filler(IntegerSet *intset, uint64 x,
...
@@ -485,7 +487,7 @@ check_with_filler(IntegerSet *intset, uint64 x,
actual
=
intset_is_member
(
intset
,
x
);
actual
=
intset_is_member
(
intset
,
x
);
if
(
actual
!=
expected
)
if
(
actual
!=
expected
)
elog
(
ERROR
,
"intset_is_member failed for
%lu"
,
x
);
elog
(
ERROR
,
"intset_is_member failed for
"
UINT64_FORMAT
,
x
);
}
}
/*
/*
...
@@ -512,7 +514,7 @@ test_empty(void)
...
@@ -512,7 +514,7 @@ test_empty(void)
/* Test iterator */
/* Test iterator */
intset_begin_iterate
(
intset
);
intset_begin_iterate
(
intset
);
if
(
intset_iterate_next
(
intset
,
&
x
))
if
(
intset_iterate_next
(
intset
,
&
x
))
elog
(
ERROR
,
"intset_iterate_next on empty set returned a value (
%lu
)"
,
x
);
elog
(
ERROR
,
"intset_iterate_next on empty set returned a value (
"
UINT64_FORMAT
"
)"
,
x
);
}
}
/*
/*
...
@@ -594,16 +596,16 @@ test_huge_distances(void)
...
@@ -594,16 +596,16 @@ test_huge_distances(void)
{
{
result
=
intset_is_member
(
intset
,
x
-
1
);
result
=
intset_is_member
(
intset
,
x
-
1
);
if
(
result
!=
false
)
if
(
result
!=
false
)
elog
(
ERROR
,
"intset_is_member failed for
%lu"
,
x
-
1
);
elog
(
ERROR
,
"intset_is_member failed for
"
UINT64_FORMAT
,
x
-
1
);
}
}
result
=
intset_is_member
(
intset
,
x
);
result
=
intset_is_member
(
intset
,
x
);
if
(
result
!=
true
)
if
(
result
!=
true
)
elog
(
ERROR
,
"intset_is_member failed for
%lu"
,
x
);
elog
(
ERROR
,
"intset_is_member failed for
"
UINT64_FORMAT
,
x
);
result
=
intset_is_member
(
intset
,
x
+
1
);
result
=
intset_is_member
(
intset
,
x
+
1
);
if
(
result
!=
false
)
if
(
result
!=
false
)
elog
(
ERROR
,
"intset_is_member failed for
%lu"
,
x
+
1
);
elog
(
ERROR
,
"intset_is_member failed for
"
UINT64_FORMAT
,
x
+
1
);
}
}
/*
/*
...
@@ -614,9 +616,9 @@ test_huge_distances(void)
...
@@ -614,9 +616,9 @@ test_huge_distances(void)
{
{
found
=
intset_iterate_next
(
intset
,
&
x
);
found
=
intset_iterate_next
(
intset
,
&
x
);
if
(
!
found
||
x
!=
values
[
i
])
if
(
!
found
||
x
!=
values
[
i
])
elog
(
ERROR
,
"intset_iterate_next failed for
%lu"
,
x
);
elog
(
ERROR
,
"intset_iterate_next failed for
"
UINT64_FORMAT
,
x
);
}
}
found
=
intset_iterate_next
(
intset
,
&
x
);
found
=
intset_iterate_next
(
intset
,
&
x
);
if
(
found
)
if
(
found
)
elog
(
ERROR
,
"intset_iterate_next failed
%lu"
,
x
);
elog
(
ERROR
,
"intset_iterate_next failed
"
UINT64_FORMAT
,
x
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment