forked from BlauGroup/RNMC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·87 lines (65 loc) · 2.75 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Red="\033[0;31m" # Red
Green="\033[0;32m" # Green
Color_Off="\033[0m" # Text Reset
function test_core {
if ./build/test_core
then
echo -e "${Green} passed: linear, sparse and tree samplers agree ${Color_Off}"
RC=0
else
echo -e "${Red} failed: linear, sparse and tree samplers disagree ${Color_Off}"
RC=1
fi
}
function test_gmc {
GMC_TEST_DIR="./test_materials/GMC"
cp $GMC_TEST_DIR/initial_state.sqlite $GMC_TEST_DIR/initial_state_copy.sqlite
./build/GMC --reaction_database=$GMC_TEST_DIR/rn.sqlite --initial_state_database=$GMC_TEST_DIR/initial_state_copy.sqlite --number_of_simulations=1000 --base_seed=1000 --thread_count=2 --step_cutoff=200 &> /dev/null
sql='SELECT seed, step, reaction_id FROM trajectories ORDER BY seed ASC, step ASC;'
sqlite3 $GMC_TEST_DIR/initial_state_with_trajectories.sqlite "${sql}" > $GMC_TEST_DIR/trajectories
sqlite3 $GMC_TEST_DIR/initial_state_copy.sqlite "${sql}" > $GMC_TEST_DIR/copy_trajectories
if cmp $GMC_TEST_DIR/trajectories $GMC_TEST_DIR/copy_trajectories > /dev/null
then
echo -e "${Green} passed: no difference in GMC trajectories ${Color_Off}"
RC=0
else
echo -e "${Red} failed: difference in GMC trajectories ${Color_Off}"
RC=1
fi
rm $GMC_TEST_DIR/initial_state_copy.sqlite
rm $GMC_TEST_DIR/trajectories
rm $GMC_TEST_DIR/copy_trajectories
}
function test_npmc {
NPMC_TEST_DIR="./test_materials/NPMC"
cp $NPMC_TEST_DIR/initial_state.sqlite $NPMC_TEST_DIR/initial_state_copy.sqlite
# to check for leaks with valgrind, you need to use the option --fair-sched=yes
./build/NPMC --nano_particle_database=$NPMC_TEST_DIR/np.sqlite --initial_state_database=$NPMC_TEST_DIR/initial_state_copy.sqlite --number_of_simulations=1000 --base_seed=1000 --thread_count=2 --step_cutoff=200 &> /dev/null
sql='SELECT seed, step, site_id_1, site_id_2, interaction_id FROM trajectories ORDER BY seed ASC, step ASC;'
sqlite3 $NPMC_TEST_DIR/initial_state_with_trajectories.sqlite "${sql}" > $NPMC_TEST_DIR/trajectories
sqlite3 $NPMC_TEST_DIR/initial_state_copy.sqlite "${sql}" > $NPMC_TEST_DIR/copy_trajectories
if cmp $NPMC_TEST_DIR/trajectories $NPMC_TEST_DIR/copy_trajectories > /dev/null
then
echo -e "${Green} passed: no difference in NPMC trajectories ${Color_Off}"
RC=0
else
echo -e "${Red} failed: difference in NPMC trajectories ${Color_Off}"
RC=1
fi
rm $NPMC_TEST_DIR/initial_state_copy.sqlite
rm $NPMC_TEST_DIR/trajectories
rm $NPMC_TEST_DIR/copy_trajectories
}
function check_result {
if [[ $RC -ne 0 ]]
then
exit $RC
fi
}
test_core
check_result
test_gmc
check_result
test_npmc
check_result
exit $RC