1/*
2 *  ticket-787.sli
3 *
4 *  This file is part of NEST.
5 *
6 *  Copyright (C) 2004 The NEST Initiative
7 *
8 *  NEST is free software: you can redistribute it and/or modify
9 *  it under the terms of the GNU General Public License as published by
10 *  the Free Software Foundation, either version 2 of the License, or
11 *  (at your option) any later version.
12 *
13 *  NEST is distributed in the hope that it will be useful,
14 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *  GNU General Public License for more details.
17 *
18 *  You should have received a copy of the GNU General Public License
19 *  along with NEST.  If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23/** @BeginDocumentation
24
25Name: testsuite::ticket-787 Ensure that all commands raise errors instead of crashing
26
27Synopsis: (ticket-787) run -> NEST fails if test fails
28
29Description:
30This ticket executes all tries, procedures and functions in systemdict.
31
32Candidates with names beginning with :, ending with _ or explicitly
33excluded are not tested, since they are internals that need not implement
34complete error checking.
35
36As long as they all either pass or raise proper errors, the test will pass.
37
38Remark:
39- This test will only run in serial mode, as it needs to spawn subprocesses.
40- Functions defined in other dictionaries that systemdict are not tested.
41
42Author: Hans Ekkehard Plesser, 2014-11-26
43 */
44
45(unittest) run
46/unittest using
47
48M_ERROR setverbosity
49
50% preparatory work for proper test code in case NEST is complied with MPI support
51% For now we just ignore this test, this will later be replaced
52% by a restart of NEST with a serial binary.
53skip_if_have_mpi
54
55% entries to skip
56
57% functions that confuse the test setup
58/special_skip [/abort /license /helpindex /helpdesk /help /help_any] def
59
60% functions that depend on readline and should not be checked if
61% NEST was compiled without support for the GNU readline library
62/readline_skip [] def
63systemdict /GNUReadline known not {
64  /readline_skip [/executive /mathexecutive /GNUreadline /break] def
65} if
66
67% private functions not expected to implement full error checking
68/private_skip [
69	/CompareFiles_s_s /ConnectLayers_i_i_D /Connect_g_g_D_D
70	/Connect_i_i_D_l /Connect_i_i_d_d_l /Connect_i_i_l
71        /CopyModel_l_l /CopyModel_l_l_D /CreateLayer_D
72	/CreateMask_D /CreateRDV_g_vf /CreateRNG_gt_i
73	/Create_l /Create_l_D /Create_l_i /Create_l_i_D /CyclicValue_d_a
74	/CyclicValue_d_d_d /Displacement_a_i
75	/Distance_a_i /DumpLayerConnections_os_i_l
76	/DumpLayerNodes_os_i /FileNames_r /FileNames_s /FixedPoint__p
77	/FixedPoint__p_i /Flatten_a /Flatten_a_i
78	/GetConnections_D /GetDefaults_l /GetPosition_i /GetStatus_C /GetStatus_a
79	/GetStatus_dict /GetStatus_i /GetValue_a_P /Inside_a_M
80	/JoinTo_ald /JoinTo_cont /JoinTo_d /MapIndexed_a /MapIndexed_s /MapThread_a
81	/Map_s /MathematicaToSliIndex_a /MathematicaToSliIndex_i
82	/Part_a /Partition_a_i_i /RandomArray_v_i
83	/Random_i /SetDefaults_l_D
84	/SetStatus_CD /SetStatus_aa /SetStatus_dict /SetStatus_id
85	/Simulate_d /Take_a_a /Take_a_i /TimeCommunicationAlltoall_i_i
86	/TimeCommunicationAlltoallv_i_i /TimeCommunication_i_i_b
87	/TimeCommunicationv_i_i /UnitStep_d /UnitStep_da /UnitStep_i
88	/UnitStep_ia /_:out /abs_d /abs_i /acos_d /add_P_P /add_a_a /add_a_i
89	/add_d_dv /add_dd /add_di /add_dv_dv /add_i_a /add_i_iv /add_id
90	/add_ii /add_iv_iv /and_M_M /and_bb /and_ii /append_a /append_p
91	/append_s /asin_d /available_is /backtrace_off /backtrace_on
92	/breakup_sa /breakup_sa_i /calibrate_node /capacity_a /capacity_s
93	/ceil_d /cos_d /cv_dv /cv_iv /cva_C /cva_d /cva_t /cvd_s /cvdict_C
94	/cvdict_M /cvnodecollection_i_i /cvnodecollection_ia /cvnodecollection_iv
95	/cvi_s /cvlit_n /cvlit_p /cvlp_p /cvn_l /cvn_s /cvs_f /cvt_a /cvx_a
96	/cvx_f /dexp_i /div_P_P /div_a_a /div_a_i /div_dd /div_di /div_dv_dv
97	/div_i_a /div_id /div_ii /div_iv_iv /double_i /drand_g /dup2_is_is
98	/dup2_is_os /dup2_os_is /dup2_os_os /empty_D /empty_a /empty_s /eq_dv
99	/eq_iv /erase_a /erase_p /erase_s /exp_d /finite_q_d /floor_d /for_a
100	/for_i /forall_a /forall_di /forall_dv /forall_iter /forall_iv
101	/forall_s /forallindexed_a /forallindexed_s /frexp_d /geq_dd /geq_di
102	/geq_id /geq_ii /get_a /get_a_a /get_d /get_d_a /get_dv_i /get_dv_iv
103	/get_iv_i /get_iv_iv /get_lp /get_p /get_s /getinterval_a
104	/getinterval_s /getline_is /gt_dd /gt_di /gt_id /gt_ii /gt_ss /help_l
105	/info_d /info_ds /insert_a /insert_s /insertelement_a /insertelement_s
106	/int_d /inv_dv /irand_g_i /iround_d /isatty_is /isatty_os /join_a
107	/join_d /join_p /join_s /kill_i_i /kill_i_l /ldexp_di /length_a
108	/length_d /length_dv /length_iv /length_lp /length_p /length_s /leq_dd
109	/leq_di /leq_id /leq_ii /ln_d /log_d /lt_dd /lt_di /lt_id /lt_ii
110	/lt_ss /max_d_d /max_d_i /max_i_d /max_i_i /min_d_d
111	/min_d_i /min_i_d /min_i_i /mkfifo_s /modf_d /mul_P_P /mul_a_a
112	/mul_a_i /mul_d_dv /mul_d_iv /mul_dd /mul_di /mul_dv_dv /mul_i_a
113	/mul_i_iv /mul_id /mul_ii /mul_iv_iv /neg_d /neg_dv /neg_i /neg_iv
114	/not_b /not_i /ones_dv /ones_iv /or_M_M /or_bb /or_ii /pow_dd /pow_di
115	/prepend_a /prepend_p /prepend_s /put_a /put_a_a_t /put_d /put_dv_i_d
116	/put_iv_i_i /put_lp /put_p /put_s /quit_i /references_a
117	/regex_find_r /regex_find_rf /regex_find_s /regex_find_sf
118	/regex_replace_r /regex_replace_rf /regex_replace_s /regex_replace_sf
119	/replace_a /replace_s /reserve_a /reserve_s /reverse_sa /round_d
120	/search_a /search_s /searchif_sa /seed_g_i
121	/setNONBLOCK_is_b /setverbosity_i /shrink_a /sin_d /size_a /size_g
122	/size_iter /size_s /sleep_d /sleep_i /spawn_as_i /sqr_d /sqrt_d
123	/sub_M_M /sub_P_P /sub_a_a /sub_a_i /sub_dd /sub_di /sub_dv_dv
124	/sub_i_a /sub_id /sub_ii /sub_iv_iv /symbol_s /sysexec_a /sysexec_s
125	/system_as_i_p /token_is /token_s /topinfo_d /trieheads_iter
126	/trieinfo_os_t /trim_sa /valid_a /waitPID_i_b /wait_b /zeros_dv
127	/zeros_iv
128] def
129
130
131% find all tries, functions and procedures in systemdict
132/candidates
133  systemdict keys
134  {
135    /k Set
136    systemdict k get type [/trietype /functiontype /proceduretype] exch MemberQ
137    k cvs 1 Take (:) neq and
138    k cvs -1 Take (_) neq and
139    private_skip k MemberQ not and
140    special_skip k MemberQ not and
141    readline_skip k MemberQ not and
142  } Select
143def
144
145candidates dup == length ==
146
147% try executing each one of them, print name before trying for analysis
148candidates
149{
150  /cand Set
151  cand ==
152
153  % we trick a little to turn the item into a procedure ...
154  cand cvs cvx passorfailbutnocrash_or_die
155} forall
156
157endusing
158