aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-06-26 12:06:20 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:44 +0200
commitbb4070ecc7d92cb8ce3211ca7f637e07756eaae8 (patch)
tree33d0890cc13ce35e984f8bc6ac1a150cfdf3d17d /tests
parentbed1e11f220c315e1a01b917abf200e927a1621a (diff)
Implement dimension part of event expansion, and clean up tests
Diffstat (limited to 'tests')
-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
13 files changed, 147 insertions, 28 deletions
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)