Skip to content

Commit b8a06b5

Browse files
authoredOct 26, 2024
Remove version number from h5repack test plugin (HDFGroup#5011)
1 parent 8b2f40f commit b8a06b5

5 files changed

+90
-95
lines changed
 

‎tools/test/h5repack/CMakeTests.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ ADD_H5_DMP_NO_OPT_TEST (tst_onion_objs "TEST" 0 tst_onion_objs.h5 --src-vfd-name
19281928
### P L U G I N T E S T S
19291929
##############################################################################
19301930
if (BUILD_SHARED_LIBS)
1931-
ADD_H5_UD_TEST (plugin_version_test 0 h5repack_layout.h5 -v -f UD=260,0,4,9,${H5_VERS_MAJOR},${H5_VERS_MINOR},${H5_VERS_RELEASE})
1931+
ADD_H5_UD_TEST (plugin_version_test 0 h5repack_layout.h5 -v -f UD=260,0,0)
19321932
ADD_H5_UD_TEST (plugin_test 0 h5repack_layout.h5 -v -f UD=257,0,1,9)
19331933
ADD_H5_UD_TEST (plugin_none 0 h5repack_layout.UD.h5 -v -f NONE)
19341934
# check for no parameters

‎tools/test/h5repack/dynlib_vrpk.c

+67-64
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,34 @@
99
* If you do not have access to either file, you may request a copy from *
1010
* help@hdfgroup.org. *
1111
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12+
1213
/*
13-
* Purpose: Tests the plugin module (H5PL)
14+
* Purpose: Test group filter plugin for the filter_pluging.c test.
1415
*/
1516

1617
#include <stdlib.h>
1718
#include <stdio.h>
18-
#include "H5PLextern.h"
19+
#include <string.h>
1920

20-
#define H5Z_FILTER_DYNLIB4 260
21+
#include "H5PLextern.h"
2122

22-
#define PUSH_ERR(func, minor, str) \
23-
H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str)
23+
#define FILTER4_ID 260
24+
#define SUFFIX_LEN 8
25+
#define GROUP_SUFFIX ".h5group"
2426

25-
static size_t H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values,
26-
size_t nbytes, size_t *buf_size, void **buf);
27+
static size_t append_to_group_name(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values,
28+
size_t nbytes, size_t *buf_size, void **buf);
2729

28-
/* This message derives from H5Z */
29-
const H5Z_class2_t H5Z_DYNLIB4[1] = {{
30-
H5Z_CLASS_T_VERS, /* H5Z_class_t version */
31-
H5Z_FILTER_DYNLIB4, /* Filter id number */
32-
1, 1, /* Encoding and decoding enabled */
33-
"dynlib4", /* Filter name for debugging */
34-
NULL, /* The "can apply" callback */
35-
NULL, /* The "set local" callback */
36-
H5Z_filter_dynlib4, /* The actual filter function */
30+
/* Filter class struct */
31+
const H5Z_class2_t FILTER_INFO[1] = {{
32+
H5Z_CLASS_T_VERS, /* H5Z_class_t version */
33+
FILTER4_ID, /* Filter ID number */
34+
1, /* Encoding enabled */
35+
1, /* Decoding enabled */
36+
"test filter plugin 4", /* Filter name for debugging */
37+
NULL, /* The "can apply" callback */
38+
NULL, /* The "set local" callback */
39+
append_to_group_name, /* The actual filter function */
3740
}};
3841

3942
H5PL_type_t
@@ -44,66 +47,66 @@ H5PLget_plugin_type(void)
4447
const void *
4548
H5PLget_plugin_info(void)
4649
{
47-
return H5Z_DYNLIB4;
50+
return FILTER_INFO;
4851
}
4952

5053
/*-------------------------------------------------------------------------
51-
* Function: H5Z_filter_dynlib4
54+
* Function: append_to_group_name
5255
*
53-
* Purpose: A dynlib4 filter method that adds on and subtract from
54-
* the original value with another value. It will be built
55-
* as a shared library. plugin.c test will load and use
56-
* this filter library. Designed to call a HDF function.
56+
* Purpose: On write:
57+
* Appends the suffix ".h5group" to the group name
58+
* On read:
59+
* Removes the ".h5group" suffix from the group name
5760
*
58-
* Return: Success: Data chunk size
59-
*
60-
* Failure: 0
61+
* Return: Success: Data size in bytes
62+
* Failure: 0
6163
*
6264
*-------------------------------------------------------------------------
6365
*/
6466
static size_t
65-
H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes,
66-
size_t *buf_size, void **buf)
67+
append_to_group_name(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes,
68+
size_t *buf_size, void **buf)
6769
{
68-
int *int_ptr = (int *)*buf; /* Pointer to the data values */
69-
size_t buf_left = *buf_size; /* Amount of data buffer left to process */
70-
int add_on = 0;
71-
unsigned ver_info[3];
72-
73-
/* Check for the library version */
74-
if (H5get_libversion(&ver_info[0], &ver_info[1], &ver_info[2]) < 0) {
75-
PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion");
76-
return (0);
77-
}
70+
size_t new_name_size = 0; /* Return value */
71+
7872
/* Check for the correct number of parameters */
79-
if (cd_nelmts == 0)
80-
return (0);
73+
if (cd_nelmts > 0)
74+
return 0;
75+
76+
/* Assignment to eliminate unused parameter warning. */
77+
(void)cd_values;
78+
79+
if (flags & H5Z_FLAG_REVERSE) {
80+
/* READ - Remove the suffix from the group name */
81+
new_name_size = *buf_size = nbytes - SUFFIX_LEN;
82+
}
83+
else {
84+
/* WRITE - Append the suffix to the group name */
85+
void *outbuf = NULL; /* Pointer to new buffer */
86+
unsigned char *dst = NULL; /* Temporary pointer to destination buffer */
87+
88+
/* Get memory for the new, larger string buffer using the
89+
* library's memory allocator.
90+
*/
91+
if (NULL == (dst = (unsigned char *)(outbuf = H5allocate_memory(nbytes + SUFFIX_LEN, 0))))
92+
return 0;
93+
94+
/* Copy raw data */
95+
memcpy((void *)dst, (const void *)(*buf), nbytes);
96+
97+
/* Append suffix to raw data for storage */
98+
dst += nbytes;
99+
memcpy((void *)dst, (const void *)GROUP_SUFFIX, SUFFIX_LEN);
81100

82-
/* Check that permanent parameters are set correctly */
83-
if (cd_values[0] > 9)
84-
return (0);
101+
/* Free the passed-in buffer using the library's allocator */
102+
H5free_memory(*buf);
85103

86-
if (ver_info[0] != cd_values[1] || ver_info[1] != cd_values[2]) {
87-
PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion does not match");
88-
return (0);
104+
/* Set return values */
105+
*buf_size = nbytes + SUFFIX_LEN;
106+
*buf = outbuf;
107+
outbuf = NULL;
108+
new_name_size = *buf_size;
89109
}
90110

91-
add_on = (int)cd_values[0];
92-
93-
if (flags & H5Z_FLAG_REVERSE) { /*read*/
94-
/* Subtract the "add on" value to all the data values */
95-
while (buf_left > 0) {
96-
*int_ptr++ -= add_on;
97-
buf_left -= sizeof(int);
98-
} /* end while */
99-
} /* end if */
100-
else { /*write*/
101-
/* Add the "add on" value to all the data values */
102-
while (buf_left > 0) {
103-
*int_ptr++ += add_on;
104-
buf_left -= sizeof(int);
105-
} /* end while */
106-
} /* end else */
107-
108-
return nbytes;
109-
} /* end H5Z_filter_dynlib4() */
111+
return new_name_size;
112+
} /* append_to_group_name() */

‎tools/test/h5repack/expected/h5repack_layout.h5-plugin_version_test.ddl

+14-21
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ GROUP "/" {
55
DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) }
66
STORAGE_LAYOUT {
77
CHUNKED ( 40, 20 )
8-
SIZE 3200 (1.000:1 COMPRESSION)
8+
SIZE 3208 (0.998:1 COMPRESSION)
99
}
1010
FILTERS {
1111
USER_DEFINED_FILTER {
1212
FILTER_ID 260
13-
COMMENT dynlib4
14-
PARAMS { 9 1 17 0 }
13+
COMMENT test filter plugin 4
1514
}
1615
}
1716
FILLVALUE {
@@ -27,13 +26,12 @@ GROUP "/" {
2726
DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) }
2827
STORAGE_LAYOUT {
2928
CHUNKED ( 40, 20 )
30-
SIZE 3200 (1.000:1 COMPRESSION)
29+
SIZE 3208 (0.998:1 COMPRESSION)
3130
}
3231
FILTERS {
3332
USER_DEFINED_FILTER {
3433
FILTER_ID 260
35-
COMMENT dynlib4
36-
PARAMS { 9 1 17 0 }
34+
COMMENT test filter plugin 4
3735
}
3836
}
3937
FILLVALUE {
@@ -49,13 +47,12 @@ GROUP "/" {
4947
DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) }
5048
STORAGE_LAYOUT {
5149
CHUNKED ( 40, 20 )
52-
SIZE 3200 (1.000:1 COMPRESSION)
50+
SIZE 3208 (0.998:1 COMPRESSION)
5351
}
5452
FILTERS {
5553
USER_DEFINED_FILTER {
5654
FILTER_ID 260
57-
COMMENT dynlib4
58-
PARAMS { 9 1 17 0 }
55+
COMMENT test filter plugin 4
5956
}
6057
}
6158
FILLVALUE {
@@ -71,13 +68,12 @@ GROUP "/" {
7168
DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) }
7269
STORAGE_LAYOUT {
7370
CHUNKED ( 40, 20 )
74-
SIZE 3200 (1.000:1 COMPRESSION)
71+
SIZE 3208 (0.998:1 COMPRESSION)
7572
}
7673
FILTERS {
7774
USER_DEFINED_FILTER {
7875
FILTER_ID 260
79-
COMMENT dynlib4
80-
PARAMS { 9 1 17 0 }
76+
COMMENT test filter plugin 4
8177
}
8278
}
8379
FILLVALUE {
@@ -93,13 +89,12 @@ GROUP "/" {
9389
DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) }
9490
STORAGE_LAYOUT {
9591
CHUNKED ( 20, 10 )
96-
SIZE 3200 (1.000:1 COMPRESSION)
92+
SIZE 3232 (0.990:1 COMPRESSION)
9793
}
9894
FILTERS {
9995
USER_DEFINED_FILTER {
10096
FILTER_ID 260
101-
COMMENT dynlib4
102-
PARAMS { 9 1 17 0 }
97+
COMMENT test filter plugin 4
10398
}
10499
}
105100
FILLVALUE {
@@ -115,13 +110,12 @@ GROUP "/" {
115110
DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) }
116111
STORAGE_LAYOUT {
117112
CHUNKED ( 40, 20 )
118-
SIZE 3200 (1.000:1 COMPRESSION)
113+
SIZE 3208 (0.998:1 COMPRESSION)
119114
}
120115
FILTERS {
121116
USER_DEFINED_FILTER {
122117
FILTER_ID 260
123-
COMMENT dynlib4
124-
PARAMS { 9 1 17 0 }
118+
COMMENT test filter plugin 4
125119
}
126120
}
127121
FILLVALUE {
@@ -137,13 +131,12 @@ GROUP "/" {
137131
DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) }
138132
STORAGE_LAYOUT {
139133
CHUNKED ( 40, 20 )
140-
SIZE 3200 (1.000:1 COMPRESSION)
134+
SIZE 3208 (0.998:1 COMPRESSION)
141135
}
142136
FILTERS {
143137
USER_DEFINED_FILTER {
144138
FILTER_ID 260
145-
COMMENT dynlib4
146-
PARAMS { 9 1 17 0 }
139+
COMMENT test filter plugin 4
147140
}
148141
}
149142
FILLVALUE {

‎tools/test/h5repack/expected/plugin_version_test.h5repack_layout.h5.tst

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Making new file ...
66
Type Filter (Compression) Name
77
-----------------------------------------
88
group /
9-
dset UD (1.000:1) /dset1
10-
dset UD (1.000:1) /dset2
11-
dset UD (1.000:1) /dset3
12-
dset UD (1.000:1) /dset4
13-
dset UD (1.000:1) /dset_chunk
14-
dset UD (1.000:1) /dset_compact
15-
dset UD (1.000:1) /dset_contiguous
9+
dset UD (0.998:1) /dset1
10+
dset UD (0.998:1) /dset2
11+
dset UD (0.998:1) /dset3
12+
dset UD (0.998:1) /dset4
13+
dset UD (0.990:1) /dset_chunk
14+
dset UD (0.998:1) /dset_compact
15+
dset UD (0.998:1) /dset_contiguous

‎tools/test/h5repack/h5repack_plugin.sh.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,9 @@ TOOLTEST_DUMP()
245245
##############################################################################
246246
# prepare for test
247247
COPY_TESTFILES_TO_TESTDIR
248-
version_str=`echo @H5_VERSION@ | awk -F"-" '{print $1}' | sed 's/\./,/g'`
249248

250249
# Run the test
251-
arg="h5repack_layout.h5 -v -f UD=260,0,4,9,$version_str"
250+
arg="h5repack_layout.h5 -v -f UD=260,0,0"
252251
TOOLTEST_DUMP plugin_version_test $arg
253252

254253
arg="h5repack_layout.h5 -v -f UD=257,0,1,9"

0 commit comments

Comments
 (0)
Please sign in to comment.