aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/image-hdf5.c285
-rw-r--r--tests/CMakeLists.txt32
-rw-r--r--tests/ev_enum1.c26
-rw-r--r--tests/ev_enum2.c78
-rw-r--r--tests/ev_enum2.geom14
-rw-r--r--tests/ev_enum2.h5bin0 -> 9064 bytes
-rw-r--r--tests/evparse1.c3
-rw-r--r--tests/evparse2.c3
-rw-r--r--tests/evparse3.c2
-rw-r--r--tests/evparse4.c2
-rw-r--r--tests/evparse5.c2
-rw-r--r--tests/evparse6.c2
-rw-r--r--tests/evparse7.c3
-rw-r--r--tests/gen-ev-test.py8
14 files changed, 356 insertions, 104 deletions
diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c
index 82968575..ccd0bb92 100644
--- a/libcrystfel/src/image-hdf5.c
+++ b/libcrystfel/src/image-hdf5.c
@@ -46,8 +46,10 @@
/* Get the path parts of the event ID
* e.g. ev_orig = abc/def/ghi//5/2/7
- * -> [abc, def, ghi], with *pn_plvals=3 */
-static char **read_path_parts(const char *ev_orig, int *pn_plvals)
+ * -> [abc, def, ghi], with *pn_plvals=3.
+ *
+ * Not part of public API. Not "static" for testing. */
+char **read_path_parts(const char *ev_orig, int *pn_plvals)
{
char **plvals;
char *ev;
@@ -108,8 +110,10 @@ static char **read_path_parts(const char *ev_orig, int *pn_plvals)
/* Get the dimension parts of the event ID
* e.g. ev_orig = abc/def/ghi//5/2/7
- * -> [5, 2, 7], with *pn_dvals=3 */
-static int *read_dim_parts(const char *ev_orig, int *pn_dvals)
+ * -> [5, 2, 7], with *pn_dvals=3
+ *
+ * Not part of public API. Not "static" for testing. */
+int *read_dim_parts(const char *ev_orig, int *pn_dvals)
{
char *ev;
@@ -175,8 +179,10 @@ static int *read_dim_parts(const char *ev_orig, int *pn_dvals)
/* ev = abc/def/ghi//5/2/7
* pattern = /data/%/somewhere/%/%/data
* output = /data/abc/somewhere/def/ghi/data
+ *
+ * Not part of public API. Not "static" for testing.
*/
-static char *substitute_path(const char *ev, const char *pattern)
+char *substitute_path(const char *ev, const char *pattern)
{
char **plvals;
int n_plvals;
@@ -203,7 +209,8 @@ static char *substitute_path(const char *ev, const char *pattern)
if ( n_plvals != n_pl_exp ) {
ERROR("Wrong number of path placeholders: "
- "'%s' into '%s'\n", ev, pattern);
+ "'%s' (%i) into '%s' (%i)\n",
+ ev, n_plvals, pattern, n_pl_exp);
return NULL;
}
@@ -1166,17 +1173,30 @@ struct ev_list
};
-static void add_to_list(struct ev_list *list, char *ev_str)
+static int add_to_list(struct ev_list *list, char *ev_str)
{
if ( list->n_events == list->max_events ) {
char **new_events = realloc(list->events,
(list->max_events+128)*sizeof(char *));
- if ( new_events == NULL ) return;
+ if ( new_events == NULL ) return 1;
list->max_events += 128;
list->events = new_events;
}
- list->events[list->n_events++] = ev_str;
+ list->events[list->n_events++] = strdup(ev_str);
+
+ return 0;
+}
+
+
+static char *demunge_event(const char *orig)
+{
+ size_t len = strlen(orig);
+ char *slash = malloc(len+3);
+ if ( slash == NULL ) return NULL;
+ strcpy(slash, orig+1);
+ strcat(slash, "//");
+ return slash;
}
@@ -1272,6 +1292,8 @@ static int rec_expand_paths(hid_t gh, struct ev_list *list,
} else if ( obj_info.type == H5O_TYPE_DATASET ) {
+ char *addme;
+
if ( n_pattern_bits != 1 ) {
ERROR("Pattern doesn't match file"
" (too long by %i)\n",
@@ -1281,7 +1303,12 @@ static int rec_expand_paths(hid_t gh, struct ev_list *list,
return 1;
}
- add_to_list(list, ev_str_new);
+ addme = demunge_event(ev_str_new);
+ if ( addme != NULL ) {
+ add_to_list(list, addme);
+ free(addme);
+ }
+ free(ev_str_new);
}
@@ -1293,7 +1320,9 @@ static int rec_expand_paths(hid_t gh, struct ev_list *list,
}
-static char **expand_paths(hid_t fh, char *pattern, int *n_evs)
+/* Not "static" so that ev_enumX can test it.
+ * Not part of public API! */
+char **expand_paths(hid_t fh, char *pattern, int *n_evs)
{
int n_sep;
size_t len;
@@ -1340,13 +1369,85 @@ static char **expand_paths(hid_t fh, char *pattern, int *n_evs)
}
+static int rec_expand_dims(struct ev_list *list,
+ int *placeholder_sizes,
+ int n_placeholder_dims,
+ char *path_ev)
+{
+ int i;
+ char *dim_ev;
+ size_t len;
+
+ len = strlen(path_ev);
+ dim_ev = malloc(len+16);
+ if ( dim_ev == NULL ) return 1;
+
+ if ( n_placeholder_dims == 1 ) {
+ for ( i=0; i<placeholder_sizes[0]; i++ ) {
+ snprintf(dim_ev, 16, "%s/%i", path_ev, i);
+ if ( add_to_list(list, dim_ev) ) return 1;
+ }
+ } else {
+
+ for ( i=0; i<placeholder_sizes[0]; i++ ) {
+ snprintf(dim_ev, 16, "%s/%i", path_ev, i);
+ if ( rec_expand_dims(list,
+ &placeholder_sizes[1],
+ n_placeholder_dims - 1,
+ dim_ev) ) return 1;
+ }
+
+ }
+
+ free(dim_ev);
+ return 0;
+}
+
+
+static char **expand_dims(int *placeholder_sizes,
+ int n_placeholder_dims,
+ char *path_ev,
+ int *n_evs)
+{
+ struct ev_list list;
+
+ list.n_events = 0;
+ list.max_events = 0;
+ list.events = NULL;
+
+ if ( rec_expand_dims(&list, placeholder_sizes,
+ n_placeholder_dims, path_ev) )
+ {
+ *n_evs = 0;
+ return NULL;
+ }
+
+ *n_evs = list.n_events;
+ return list.events;
+}
+
+
+static int n_dims_expected(struct panel_template *p)
+{
+ int i;
+ int n_dims = 0;
+ for ( i=0; i<MAX_DIMS; i++ ) {
+ if ( p->dims[i] != DIM_UNDEFINED ) n_dims++;
+ }
+ return n_dims;
+}
+
+
char **image_hdf5_expand_frames(const DataTemplate *dtempl,
const char *filename,
int *pn_frames)
{
- char **frames = NULL;
- int n_frames;
+ char **path_evs;
+ int n_path_evs;
hid_t fh;
+ int i;
+ int dims_expected;
+ struct ev_list full_evs;
fh = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT);
if ( fh < 0 ) {
@@ -1354,85 +1455,117 @@ char **image_hdf5_expand_frames(const DataTemplate *dtempl,
return NULL;
}
- master_el = initialize_event_list();
- if ( master_el == NULL ) {
- ERROR("Failed to allocate event list.\n");
+ /* First, expand placeholders in the HDF5 paths.
+ *
+ * Since we require the number of placeholders to be the same
+ * for all panels, and the placeholders will be substituted
+ * with the same values for each panel (since they come from
+ * the same event ID), this only needs to be done for the
+ * first panel. */
+ path_evs = expand_paths(fh, dtempl->panels[0].data,
+ &n_path_evs);
+ if ( path_evs == NULL ) {
+ ERROR("Failed to enumerate paths.\n");
H5Fclose(fh);
return NULL;
}
- /* First expand any placeholders in the HDF5 paths */
- if ( dtempl->path_dim != 0 ) {
- int pi;
- for ( pi=0; pi<dtempl->n_panels; pi++ ) {
- if ( fill_paths(fh, dtempl, pi, master_el) ) {
- ERROR("Failed to enumerate paths.\n");
- H5Fclose(fh);
- return NULL;
- }
+ dims_expected = n_dims_expected(&dtempl->panels[0]);
+
+ full_evs.events = NULL;
+ full_evs.n_events = 0;
+ full_evs.max_events = 0;
+
+ /* For each expanded path, enumerate the placeholder
+ * dimensions. Once again, since the number of placeholders
+ * must be the same for each panel, and the substituted values
+ * will be the same, this only needs to be done for one panel.
+ */
+ for ( i=0; i<n_path_evs; i++ ) {
+
+ hid_t dh, sh;
+ char *path;
+ hsize_t *size;
+ int dims;
+ int *placeholder_sizes;
+ int n_placeholder_dims;
+ int j;
+ char **evs_this_path;
+ int n_evs_this_path;
+ struct panel_template *p = &dtempl->panels[0];
+
+ path = substitute_path(path_evs[i], p->data);
+ if ( path == NULL ) {
+ ERROR("Path substitution failed during "
+ "expansion of '%s' with partial event "
+ "ID '%s'\n",
+ p->data, path_evs[i]);
+ return NULL;
}
- }
-
- /* Now enumerate the placeholder dimensions */
- if ( dtempl->dim_dim > 0 ) {
- struct event_list *master_el_with_dims;
- int evi;
-
- /* If there were no HDF5 path placeholders, add a dummy event */
- if ( master_el->num_events == 0 ) {
- struct event *empty_ev;
- empty_ev = initialize_event();
- append_event_to_event_list(master_el, empty_ev);
- free(empty_ev);
+ dh = H5Dopen2(fh, path, H5P_DEFAULT);
+ if ( dh < 0 ) {
+ ERROR("Error opening '%s'\n", path);
+ ERROR("Failed to enumerate events. "
+ "Check your geometry file.\n");
+ H5Fclose(fh);
+ return NULL;
}
- master_el_with_dims = initialize_event_list();
-
- /* For each event so far, expand the dimensions */
- for ( evi=0; evi<master_el->num_events; evi++ ) {
-
- int pi;
- int global_path_dim = -1;
- int mlwd;
-
- /* Check the dimensionality of each panel */
- for ( pi=0; pi<dtempl->n_panels; pi++ ) {
- if ( check_dims(fh, &dtempl->panels[pi],
- master_el->events[evi],
- master_el_with_dims,
- &global_path_dim) )
- {
- ERROR("Failed to enumerate dims.\n");
- H5Fclose(fh);
- return NULL;
- }
- }
+ sh = H5Dget_space(dh);
+ dims = H5Sget_simple_extent_ndims(sh);
+ if ( dims != dims_expected ) {
+ ERROR("Unexpected number of dimensions (%s)\n",
+ path);
+ H5Fclose(fh);
+ return NULL;
+ }
- /* Add this dimensionality to all events */
- for ( mlwd=0; mlwd<global_path_dim; mlwd++ ) {
+ size = malloc(dims*sizeof(hsize_t));
+ placeholder_sizes = malloc(dims*sizeof(int));
+ if ( (size == NULL) || (placeholder_sizes == NULL) ) {
+ ERROR("Failed to allocate dimensions\n");
+ H5Fclose(fh);
+ return NULL;
+ }
- struct event *mlwd_ev;
+ if ( H5Sget_simple_extent_dims(sh, size, NULL) < 0 ) {
+ ERROR("Failed to get size\n");
+ H5Fclose(fh);
+ return NULL;
+ }
- mlwd_ev = copy_event(master_el->events[evi]);
- push_dim_entry_to_event(mlwd_ev, mlwd);
- append_event_to_event_list(master_el_with_dims,
- mlwd_ev);
- free_event(mlwd_ev);
+ n_placeholder_dims = 0;
+ for ( j=0; j<dims; j++ ) {
+ if ( p->dims[j] == DIM_PLACEHOLDER ) {
+ placeholder_sizes[n_placeholder_dims++] = size[j];
}
-
+ }
+ free(size);
+
+ /* Path event ID ends with //, but expand_dims will
+ * add a slash. So, remove one slash */
+ path_evs[i][strlen(path_evs[i])-1] = '\0';
+ evs_this_path = expand_dims(placeholder_sizes,
+ n_placeholder_dims,
+ path_evs[i],
+ &n_evs_this_path);
+
+ for ( j=0; j<n_evs_this_path; j++ ) {
+ add_to_list(&full_evs, evs_this_path[j]);
+ free(evs_this_path[j]);
}
- free_event_list(master_el);
- H5Fclose(fh);
- return master_el_with_dims;
-
- } else {
-
- H5Fclose(fh);
- return master_el;
+ free(placeholder_sizes);
+ free(evs_this_path);
+ free(path);
+ free(path_evs[i]);
}
+
+ free(path_evs);
+ *pn_frames = full_evs.n_events;
+ return full_evs.events;
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 8be42f28..7eee69aa 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -103,43 +103,59 @@ target_include_directories(polarisation_check PRIVATE ${COMMON_INCLUDES})
target_link_libraries(polarisation_check ${COMMON_LIBRARIES})
add_test(polarisation_check polarisation_check)
-add_executable(evparse1 evparse1.c)
+add_executable(evparse1 evparse1.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libcrystfel/src/image-hdf5.c)
target_include_directories(evparse1 PRIVATE ${COMMON_INCLUDES})
target_link_libraries(evparse1 ${COMMON_LIBRARIES} -lhdf5)
add_test(evparse1 evparse1)
-add_executable(evparse2 evparse2.c)
+add_executable(evparse2 evparse2.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libcrystfel/src/image-hdf5.c)
target_include_directories(evparse2 PRIVATE ${COMMON_INCLUDES})
target_link_libraries(evparse2 ${COMMON_LIBRARIES} -lhdf5)
add_test(evparse2 evparse2)
-add_executable(evparse3 evparse3.c)
+add_executable(evparse3 evparse3.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libcrystfel/src/image-hdf5.c)
target_include_directories(evparse3 PRIVATE ${COMMON_INCLUDES})
target_link_libraries(evparse3 ${COMMON_LIBRARIES} -lhdf5)
add_test(evparse3 evparse3)
-add_executable(evparse4 evparse4.c)
+add_executable(evparse4 evparse4.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libcrystfel/src/image-hdf5.c)
target_include_directories(evparse4 PRIVATE ${COMMON_INCLUDES})
target_link_libraries(evparse4 ${COMMON_LIBRARIES} -lhdf5)
add_test(evparse4 evparse4)
-add_executable(evparse5 evparse5.c)
+add_executable(evparse5 evparse5.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libcrystfel/src/image-hdf5.c)
target_include_directories(evparse5 PRIVATE ${COMMON_INCLUDES})
target_link_libraries(evparse5 ${COMMON_LIBRARIES} -lhdf5)
add_test(evparse5 evparse5)
-add_executable(evparse6 evparse6.c)
+add_executable(evparse6 evparse6.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libcrystfel/src/image-hdf5.c)
target_include_directories(evparse6 PRIVATE ${COMMON_INCLUDES})
target_link_libraries(evparse6 ${COMMON_LIBRARIES} -lhdf5)
add_test(evparse6 evparse6)
-add_executable(evparse7 evparse7.c)
+add_executable(evparse7 evparse7.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libcrystfel/src/image-hdf5.c)
target_include_directories(evparse7 PRIVATE ${COMMON_INCLUDES})
target_link_libraries(evparse7 ${COMMON_LIBRARIES} -lhdf5)
add_test(evparse7 evparse7)
-add_executable(ev_enum1 ev_enum1.c)
+add_executable(ev_enum1 ev_enum1.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libcrystfel/src/image-hdf5.c)
target_include_directories(ev_enum1 PRIVATE ${COMMON_INCLUDES})
target_link_libraries(ev_enum1 ${COMMON_LIBRARIES} -lhdf5)
add_test(NAME ev_enum1
COMMAND ev_enum1 ${CMAKE_CURRENT_SOURCE_DIR}/ev_enum1.h5)
+
+add_executable(ev_enum2 ev_enum2.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libcrystfel/src/image-hdf5.c)
+target_include_directories(ev_enum2 PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(ev_enum2 ${COMMON_LIBRARIES} -lhdf5)
+add_test(NAME ev_enum2
+ COMMAND ev_enum2 ${CMAKE_CURRENT_SOURCE_DIR}/ev_enum2.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/ev_enum2.geom)
diff --git a/tests/ev_enum1.c b/tests/ev_enum1.c
index 9c414dc5..c1a93320 100644
--- a/tests/ev_enum1.c
+++ b/tests/ev_enum1.c
@@ -33,9 +33,11 @@
#include <stdio.h>
#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
#include <hdf5.h>
-#include "../libcrystfel/src/image-hdf5.c"
+extern char **expand_paths(hid_t fh, char *pattern, int *n_evs);
int main(int argc, char *argv[])
{
@@ -46,7 +48,7 @@ int main(int argc, char *argv[])
fh = H5Fopen(argv[1], H5F_ACC_RDONLY, H5P_DEFAULT);
if ( fh < 0 ) {
- ERROR("Couldn't open file\n");
+ printf("Couldn't open file\n");
return 1;
}
@@ -55,32 +57,32 @@ int main(int argc, char *argv[])
&n_event_ids);
if ( event_ids == NULL ) {
- STATUS("event_ids = NULL\n");
+ printf("event_ids = NULL\n");
return 1;
}
if ( n_event_ids != 4 ) {
- STATUS("Number of event IDs = %i\n", n_event_ids);
+ printf("Number of event IDs = %i\n", n_event_ids);
return 1;
}
- if ( strcmp(event_ids[0], "/ev_1/dataABCset") != 0 ) {
- STATUS("Wrong event id '%s'\n", event_ids[0]);
+ if ( strcmp(event_ids[0], "ev_1/dataABCset//") != 0 ) {
+ printf("Wrong event id '%s'\n", event_ids[0]);
return 1;
}
- if ( strcmp(event_ids[1], "/ev_2/dataDEFset") != 0 ) {
- STATUS("Wrong event id '%s'\n", event_ids[1]);
+ if ( strcmp(event_ids[1], "ev_2/dataDEFset//") != 0 ) {
+ printf("Wrong event id '%s'\n", event_ids[1]);
return 1;
}
- if ( strcmp(event_ids[2], "/ev_3/dataGHIset") != 0 ) {
- STATUS("Wrong event id '%s'\n", event_ids[2]);
+ if ( strcmp(event_ids[2], "ev_3/dataGHIset//") != 0 ) {
+ printf("Wrong event id '%s'\n", event_ids[2]);
return 1;
}
- if ( strcmp(event_ids[3], "/ev_5/dataNOPset") != 0 ) {
- STATUS("Wrong event id '%s'\n", event_ids[3]);
+ if ( strcmp(event_ids[3], "ev_5/dataNOPset//") != 0 ) {
+ printf("Wrong event id '%s'\n", event_ids[3]);
return 1;
}
diff --git a/tests/ev_enum2.c b/tests/ev_enum2.c
new file mode 100644
index 00000000..f1934a2a
--- /dev/null
+++ b/tests/ev_enum2.c
@@ -0,0 +1,78 @@
+/*
+ * ev_enum2.c
+ *
+ * Check that event enumeration works
+ *
+ * Copyright © 2020 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2020 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <image.h>
+
+int main(int argc, char *argv[])
+{
+ char **event_ids;
+ int n_event_ids;
+ int i;
+ DataTemplate *dtempl;
+
+ dtempl = data_template_new_from_file(argv[2]);
+ if ( dtempl == NULL ) {
+ ERROR("Failed ot load data template\n");
+ return 1;
+ }
+
+ event_ids = image_expand_frames(dtempl, argv[1], &n_event_ids);
+
+ if ( event_ids == NULL ) {
+ printf("event_ids = NULL\n");
+ return 1;
+ }
+
+ for ( i=0; i<n_event_ids; i++ ) {
+ char tmp[64];
+ char c = i < 100 ? 'a' : 'b';
+ int n = i < 100 ? i : (i-100);
+ snprintf(tmp, 64, "%c//%i", c, n);
+ if ( strcmp(tmp, event_ids[i]) != 0 ) {
+ printf("Event ID %i is wrong '%s'\n",
+ i, event_ids[i]);
+ return 1;
+ }
+ free(event_ids[i]);
+ }
+ free(event_ids);
+
+ data_template_free(dtempl);
+
+ return 0;
+}
diff --git a/tests/ev_enum2.geom b/tests/ev_enum2.geom
new file mode 100644
index 00000000..5f48a97c
--- /dev/null
+++ b/tests/ev_enum2.geom
@@ -0,0 +1,14 @@
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/dim0 = %
+panel/dim1 = fs
+panel/dim2 = ss
+panel/dim3 = 1
+panel/data = /data/%/data_array \ No newline at end of file
diff --git a/tests/ev_enum2.h5 b/tests/ev_enum2.h5
new file mode 100644
index 00000000..660ffece
--- /dev/null
+++ b/tests/ev_enum2.h5
Binary files differ
diff --git a/tests/evparse1.c b/tests/evparse1.c
index ad037841..7b8799d6 100644
--- a/tests/evparse1.c
+++ b/tests/evparse1.c
@@ -32,9 +32,10 @@
#include <stdio.h>
+#include <string.h>
#include <stdarg.h>
-#include "../libcrystfel/src/image-hdf5.c"
+extern char **read_path_parts(const char *ev_orig, int *pn_plvals);
int main(int argc, char *argv[])
{
diff --git a/tests/evparse2.c b/tests/evparse2.c
index 1499b13b..6b81ae70 100644
--- a/tests/evparse2.c
+++ b/tests/evparse2.c
@@ -32,9 +32,10 @@
#include <stdio.h>
+#include <string.h>
#include <stdarg.h>
-#include "../libcrystfel/src/image-hdf5.c"
+extern char **read_path_parts(const char *ev_orig, int *pn_plvals);
int main(int argc, char *argv[])
{
diff --git a/tests/evparse3.c b/tests/evparse3.c
index ef6733d0..a7d41629 100644
--- a/tests/evparse3.c
+++ b/tests/evparse3.c
@@ -34,7 +34,7 @@
#include <stdio.h>
#include <stdarg.h>
-#include "../libcrystfel/src/image-hdf5.c"
+extern char **read_path_parts(const char *ev_orig, int *pn_plvals);
int main(int argc, char *argv[])
{
diff --git a/tests/evparse4.c b/tests/evparse4.c
index ca28fa24..7a975c96 100644
--- a/tests/evparse4.c
+++ b/tests/evparse4.c
@@ -34,7 +34,7 @@
#include <stdio.h>
#include <stdarg.h>
-#include "../libcrystfel/src/image-hdf5.c"
+extern int *read_dim_parts(const char *ev_orig, int *pn_dvals);
int main(int argc, char *argv[])
{
diff --git a/tests/evparse5.c b/tests/evparse5.c
index ed0d9b85..06daba13 100644
--- a/tests/evparse5.c
+++ b/tests/evparse5.c
@@ -34,7 +34,7 @@
#include <stdio.h>
#include <stdarg.h>
-#include "../libcrystfel/src/image-hdf5.c"
+extern int *read_dim_parts(const char *ev_orig, int *pn_dvals);
int main(int argc, char *argv[])
{
diff --git a/tests/evparse6.c b/tests/evparse6.c
index 235c6204..63152dda 100644
--- a/tests/evparse6.c
+++ b/tests/evparse6.c
@@ -34,7 +34,7 @@
#include <stdio.h>
#include <stdarg.h>
-#include "../libcrystfel/src/image-hdf5.c"
+extern int *read_dim_parts(const char *ev_orig, int *pn_dvals);
int main(int argc, char *argv[])
{
diff --git a/tests/evparse7.c b/tests/evparse7.c
index 7e7ff104..fca5055d 100644
--- a/tests/evparse7.c
+++ b/tests/evparse7.c
@@ -32,9 +32,10 @@
#include <stdio.h>
+#include <string.h>
#include <stdarg.h>
-#include "../libcrystfel/src/image-hdf5.c"
+extern char *substitute_path(const char *ev, const char *pattern);
int main(int argc, char *argv[])
{
diff --git a/tests/gen-ev-test.py b/tests/gen-ev-test.py
index dc7c0f0a..ddfc273d 100644
--- a/tests/gen-ev-test.py
+++ b/tests/gen-ev-test.py
@@ -5,7 +5,7 @@ import numpy
blank = numpy.zeros((1,1), dtype=float)
-with h5py.File('ev_enum1.h5', 'w') as fh:
+with h5py.File('tests/ev_enum1.h5', 'w') as fh:
fh.create_dataset('/data/panelA/ev_1/panel_data1t/dataABCset/array', data=blank)
fh.create_dataset('/data/panelA/ev_2/panel_data1t/dataDEFset/array', data=blank)
fh.create_dataset('/data/panelA/ev_3/panel_data1t/dataGHIset/array', data=blank)
@@ -21,3 +21,9 @@ with h5py.File('ev_enum1.h5', 'w') as fh:
fh.create_dataset('/data/panelB/ev_3/dataGHIset/array', data=blank)
fh.create_dataset('/data/panelB/ev_4/dataKLMset/array', data=blank)
fh.create_dataset('/data/panelB/ev_5/dataNOPset/array', data=blank)
+
+array = numpy.zeros((100,1,1,2), dtype=float)
+
+with h5py.File('tests/ev_enum2.h5', 'w') as fh:
+ fh.create_dataset('/data/a/data_array', data=array)
+ fh.create_dataset('/data/b/data_array', data=array)