Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 58306a0

Browse files
sergiorg-hpcBlanco Alonso Jorge
andauthored
Improves the CI tests for reporting (#479)
* Added reference files for better report comparison. * Renamed cmake variables to increase readability. * Enabled libsonata tests in reports. Co-authored-by: Blanco Alonso Jorge <[email protected]>
1 parent 72eadd4 commit 58306a0

File tree

7 files changed

+148
-44
lines changed

7 files changed

+148
-44
lines changed

CMakeLists.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,27 @@ if(CORENRN_ENABLE_REPORTING)
204204
find_package(reportinglib)
205205
find_package(sonata)
206206
find_program(H5DUMP_EXECUTABLE h5dump)
207-
if(NOT reportinglib_FOUND AND NOT sonata_FOUND)
208-
message(SEND_ERROR "Neither reportinglib nor SONATA libraries were found")
209-
elseif(reportinglib_FOUND AND sonata_FOUND)
210-
add_definitions("-DENABLE_BIN_REPORTS")
211-
add_definitions("-DENABLE_SONATA_REPORTS")
212-
elseif(reportinglib_FOUND)
207+
208+
if(reportinglib_FOUND)
213209
add_definitions("-DENABLE_BIN_REPORTS")
214-
else() # sonata_FOUND
210+
set(ENABLE_BIN_REPORTS_TESTS ON)
211+
else()
212+
set(reportinglib_INCLUDE_DIR "")
213+
set(reportinglib_LIBRARY "")
214+
endif()
215+
if(sonata_FOUND)
215216
if(TARGET sonata::sonata_report)
216217
add_definitions("-DENABLE_SONATA_REPORTS")
217-
set(reportinglib_INCLUDE_DIR "")
218-
set(reportinglib_LIBRARY "")
218+
set(ENABLE_SONATA_REPORTS_TESTS ON)
219219
else()
220220
message(SEND_ERROR "SONATA library was found but without reporting support")
221221
endif()
222222
endif()
223+
224+
if(NOT reportinglib_FOUND AND NOT sonata_FOUND)
225+
message(SEND_ERROR "Neither reportinglib nor SONATA libraries were found")
226+
endif()
227+
223228
include_directories(${reportinglib_INCLUDE_DIR})
224229
include_directories(${sonatareport_INCLUDE_DIR})
225230
endif()

tests/integration/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ if(CORENRN_ENABLE_REPORTING)
101101
configure_file(reportinglib/${TEST_NAME}.conf.in ${SIM_NAME}/${TEST_NAME}.conf @ONLY)
102102
configure_file(reportinglib/reporting_test.sh.in ${SIM_NAME}/reporting_test.sh @ONLY)
103103
configure_file(reportinglib/${TEST_NAME}.check.in ${SIM_NAME}/${TEST_NAME}.check @ONLY)
104+
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/reportinglib/test_ref.out" DESTINATION "${SIM_NAME}/")
104105
add_test(
105106
NAME ${SIM_NAME}
106107
COMMAND "/bin/sh" ${CMAKE_CURRENT_BINARY_DIR}/${SIM_NAME}/reporting_test.sh

tests/integration/integration_test.sh.in

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#! /bin/sh
22

33
export OMP_NUM_THREADS=1
4+
export LIBSONATA_ZERO_BASED_GIDS=true
45

56
# Run the executable
67
SRUN_EXTRA=
@@ -23,18 +24,18 @@ fi
2324
cd @CMAKE_CURRENT_BINARY_DIR@/@SIM_NAME@
2425

2526
# We convert spikes to out.dat format
26-
reports=@ENABLE_SONATA_REPORTS@
27+
reports=@ENABLE_SONATA_REPORTS_TESTS@
2728
if [ "$reports" = "ON" ]
2829
then
29-
data=$(@H5DUMP_EXECUTABLE@ -d /spikes/timestamps -d /spikes/node_ids -y -O out.h5 | tr "," "\n")
30-
echo $data | awk '{n=NF/2; for (i=1;i<=n;i++) print $i "\t" $(n+i) }' >> out_SONATA.dat
30+
data=$(@H5DUMP_EXECUTABLE@ -d /spikes/All/timestamps -d /spikes/All/node_ids -y -O out.h5 | sed 's/"ms"//g;s/,/\n/g')
31+
echo $data | awk '{n=NF/2; for (i=1;i<=n;i++) print $i "\t" $(n+i) }' > out_SONATA.dat
3132

3233
if [ ! -f out_SONATA.dat ]
3334
then
3435
echo "[ERROR] No SONATA output files. Test failed!" >&2
3536
exit 1
3637
fi
37-
diff -w out_SONATA.dat @CMAKE_CURRENT_SOURCE_DIR@/@SIM_NAME@/out.dat.ref > diff_SONATA.dat 2>&1
38+
diff -w out_SONATA.dat out.dat.ref > diff_SONATA.dat 2>&1
3839
if [ -s diff_SONATA.dat ]
3940
then
4041
echo "[ERROR] SONATA Results are different, check the file diff_SONATA.dat. Test failed!" >&2
@@ -48,7 +49,7 @@ then
4849
exit 1
4950
fi
5051

51-
diff -w out.dat @CMAKE_BINARY_DIR@/tests/integration/@SIM_NAME@/out.dat.ref > diff.dat 2>&1
52+
diff -w out.dat out.dat.ref > diff.dat 2>&1
5253

5354
if [ -s diff.dat ]
5455
then

tests/integration/negative_integration_test.sh.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@CMAKE_BINARY_DIR@/lib
44
export OMP_NUM_THREADS=1
5+
export LIBSONATA_ZERO_BASED_GIDS=true
56

67
# Run the executable
78
#SRUN_EXTRA="--propagate=CORE"
@@ -25,11 +26,11 @@ fi
2526
cd @CMAKE_CURRENT_BINARY_DIR@/@SIM_NAME@
2627

2728
# We convert spikes to out.dat format
28-
reports=@ENABLE_SONATA_REPORTS@
29+
reports=@ENABLE_SONATA_REPORTS_TESTS@
2930
if [ "$reports" = "ON" ]
3031
then
31-
data=$(@H5DUMP_EXECUTABLE@ -d /spikes/timestamps -d /spikes/node_ids -y -O spikes | tr "," "\n")
32-
echo $data | awk '{n=NF/2; for (i=1;i<=n;i++) print $i "\t" $(n+i) }' >> out_SONATA.dat
32+
data=$(@H5DUMP_EXECUTABLE@ -d /spikes/All/timestamps -d /spikes/All/node_ids -y -O spikes | sed 's/"ms"//g;s/,/\n/g')
33+
echo $data | awk '{n=NF/2; for (i=1;i<=n;i++) print $i "\t" $(n+i) }' > out_SONATA.dat
3334

3435
if [ ! -f out_SONATA.dat ]
3536
then
Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
#! /bin/sh
2-
3-
#NOTE: binary diff is not a good idea as it dont reflect what people use to read reports
1+
#!/bin/sh
42

53
OK=0
64
FAILED=1
7-
sonata_reports=@ENABLE_SONATA_REPORTS@
8-
bin_reports=@ENABLE_BIN_REPORTS@
5+
sonata_reports=@ENABLE_SONATA_REPORTS_TESTS@
6+
bin_reports=@ENABLE_BIN_REPORTS_TESTS@
7+
test_ref=@CMAKE_CURRENT_BINARY_DIR@/@SIM_NAME@/test_ref.out
98

109
if [ "$bin_reports" = "ON" ]
1110
then
1211
if [ -f test_1.bbp ]
1312
then
14-
#checking something with @reportinglib_BIN_DIR@/dump test_1.bbp
15-
# for ascii files that will be using grep for instance.
16-
nb_recorded=$(@reportinglib_somaDump@ test_1.bbp 1| wc -l)
17-
# 101 because a white space
18-
if [ $nb_recorded -eq 100 ]; then
19-
exit $OK
20-
else
21-
echo "[ERROR] The number of steps recorded by ReportingLib doesn't match.
22-
Found $nb_recorded, expected 100. Test failed!" >&2
23-
exit $FAILED
24-
fi
13+
somaDump_diff=$(@reportinglib_somaDump@ test_1.bbp 1 | sed 's/ //g' | diff $test_ref -)
14+
15+
if [ $? -ne 0 ]
16+
then
17+
echo -e "[ERROR] The report output generated by Reportinglib differs!\n$somaDump_diff" >&2
18+
exit $FAILED
19+
fi
2520
else
2621
echo "[ERROR] Expected ReportingLib soma file 'test_1.bbp' is missing. Test failed!" >&2
2722
exit $FAILED
@@ -32,19 +27,18 @@ if [ "$sonata_reports" = "ON" ]
3227
then
3328
if [ -f test_2.h5 ]
3429
then
35-
#checking something with @reportinglib_BIN_DIR@/dump test_1.bbp
36-
# for ascii files that will be using grep for instance.
37-
nb_recorded_sonata=$(@H5DUMP_EXECUTABLE@ -d /report/data -y -O test_2.h5 | wc -l)
38-
# 101 because a white space
39-
if [ $nb_recorded_sonata -eq 101 ]; then
40-
exit $OK
41-
else
42-
echo "[ERROR] The number of steps recorded by SONATA doesn't match.
43-
Found $nb_recorded, expected 101. Test failed!" >&2
44-
exit $FAILED
45-
fi
30+
h5dump_diff=$(@H5DUMP_EXECUTABLE@ -d /report/All/data -y -O test_2.h5 | sed '1d;$d;s/,//g;s/ //g' | diff $test_ref -)
31+
32+
if [ $? -ne 0 ]
33+
then
34+
echo -e "[ERROR] The report output generated by Libsonata differs!\n$h5dump_diff" >&2
35+
exit $FAILED
36+
fi
4637
else
4738
echo "[ERROR] Expected SONATA soma file 'test_2.h5' doesn't exist. Test failed!" >&2
4839
exit $FAILED
4940
fi
5041
fi
42+
43+
# If we reach this point, all tests were successful
44+
exit $OK

tests/integration/reportinglib/reporting_test.sh.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
set -e -o pipefail
44

55
export OMP_NUM_THREADS=1
6+
export LIBSONATA_ZERO_BASED_GIDS=true
7+
68
@SRUN_PREFIX@ @CMAKE_BINARY_DIR@/bin/@CMAKE_SYSTEM_PROCESSOR@/special-core --mpi --read-config @CMAKE_CURRENT_BINARY_DIR@/@SIM_NAME@/@[email protected]
79
chmod +x @CMAKE_CURRENT_BINARY_DIR@/@SIM_NAME@/@[email protected]
810
exit `@CMAKE_CURRENT_BINARY_DIR@/@SIM_NAME@/@[email protected]`
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
-65
2+
-64.9973
3+
-64.9951
4+
-64.9932
5+
-64.9916
6+
-64.9902
7+
-64.9889
8+
-64.9877
9+
-64.9867
10+
-64.9858
11+
-64.985
12+
-64.9842
13+
-64.9836
14+
-64.9829
15+
-64.9824
16+
-64.9819
17+
-64.9815
18+
-64.9811
19+
-64.9807
20+
-64.9804
21+
-64.9802
22+
-64.9799
23+
-64.9797
24+
-64.9796
25+
-64.9794
26+
-64.9793
27+
-64.9792
28+
-64.9791
29+
-64.979
30+
-64.979
31+
-64.979
32+
-64.979
33+
-64.979
34+
-64.979
35+
-64.979
36+
-64.9791
37+
-64.9791
38+
-64.7371
39+
-63.6264
40+
-62.1068
41+
-60.4682
42+
-58.847
43+
-57.2905
44+
-55.7913
45+
-54.3056
46+
-52.7594
47+
-51.044
48+
-48.9961
49+
-46.3491
50+
-42.6233
51+
-36.8741
52+
-27.1665
53+
-10.1852
54+
13.977
55+
31.4561
56+
36.143
57+
35.2487
58+
32.4239
59+
28.6338
60+
24.2472
61+
19.4933
62+
14.5405
63+
9.51339
64+
4.50006
65+
-0.440951
66+
-5.27461
67+
-9.98373
68+
-14.5648
69+
-19.0258
70+
-23.3868
71+
-27.6838
72+
-31.9759
73+
-36.353
74+
-40.9401
75+
-45.8855
76+
-51.303
77+
-57.1176
78+
-62.8313
79+
-67.5469
80+
-70.6416
81+
-72.2969
82+
-73.0829
83+
-73.4434
84+
-73.6102
85+
-73.6866
86+
-73.7171
87+
-73.7212
88+
-73.7082
89+
-73.6828
90+
-73.6479
91+
-73.6053
92+
-73.5561
93+
-73.5012
94+
-73.4414
95+
-73.3771
96+
-73.3089
97+
-73.237
98+
-73.1618
99+
-73.0836
100+
-73.0025

0 commit comments

Comments
 (0)