From 89e46b85b8ec5ce69d5db93590b404a346887754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20M=C3=B8rk?= Date: Fri, 9 Dec 2016 15:38:40 +0100 Subject: [PATCH 1/5] Now throws an error for illegal connections. --- nestkernel/connection_manager.cpp | 6 ++++-- testsuite/regressiontests/issue-211.sli | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/nestkernel/connection_manager.cpp b/nestkernel/connection_manager.cpp index 0838a95897..b8aaabf9c1 100644 --- a/nestkernel/connection_manager.cpp +++ b/nestkernel/connection_manager.cpp @@ -413,7 +413,8 @@ nest::ConnectionManager::connect( index sgid, // we do not allow to connect a device to a global receiver at the moment if ( not source->has_proxies() ) { - return; + throw IllegalConnection( "The models " + target->get_name() + " and " + + source->get_name() + " cannot be connected." ); } connect_( *source, *target, sgid, tid, syn, d, w ); } @@ -474,7 +475,8 @@ nest::ConnectionManager::connect( index sgid, // we do not allow to connect a device to a global receiver at the moment if ( not source->has_proxies() ) { - return; + throw IllegalConnection( "The models " + target->get_name() + " and " + + source->get_name() + " cannot be connected." ); } connect_( *source, *target, sgid, tid, syn, params, d, w ); } diff --git a/testsuite/regressiontests/issue-211.sli b/testsuite/regressiontests/issue-211.sli index efd14c893b..28901ff062 100644 --- a/testsuite/regressiontests/issue-211.sli +++ b/testsuite/regressiontests/issue-211.sli @@ -68,8 +68,8 @@ n2 d4 << /weight 1. >> Connect [g5 g5] [n1] Connect g5 n3 << /weight 1. >> Connect -% device-device; but g5g5 should be ignored -[g5 g5] [d4 g5] /one_to_one Connect +% device-device +[g5] [d4] /one_to_one Connect [g5 g5] [d4] Connect g5 d4 << /weight 1. >> Connect @@ -78,7 +78,6 @@ n1 v6 Connect n2 v6 Connect /conn << >> GetConnections def - % expected connections with expected threads /target_conn <[1 3 1] [2 3 1] [2 1 1] [3 1 1] [2 1 1] % neuron-neuron [1 4 1] [1 3 1] [2 4 0] [3 4 1] [2 4 0] % neuron-device From 699102fdb4e5acd1f944aed0fef6b4006d8012b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20M=C3=B8rk?= Date: Thu, 23 Mar 2017 15:53:30 +0100 Subject: [PATCH 2/5] Fixed a test, added new tests Removed a redundant test connecting device to device, and added a new test for illegal connections. --- testsuite/regressiontests/issue-211.sli | 7 +--- testsuite/unittests/test_connect.sli | 49 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/testsuite/regressiontests/issue-211.sli b/testsuite/regressiontests/issue-211.sli index 28901ff062..34d5bd6fe8 100644 --- a/testsuite/regressiontests/issue-211.sli +++ b/testsuite/regressiontests/issue-211.sli @@ -68,21 +68,16 @@ n2 d4 << /weight 1. >> Connect [g5 g5] [n1] Connect g5 n3 << /weight 1. >> Connect -% device-device -[g5] [d4] /one_to_one Connect -[g5 g5] [d4] Connect -g5 d4 << /weight 1. >> Connect - % neuron-globally receiving device (volume transmitter) n1 v6 Connect n2 v6 Connect /conn << >> GetConnections def + % expected connections with expected threads /target_conn <[1 3 1] [2 3 1] [2 1 1] [3 1 1] [2 1 1] % neuron-neuron [1 4 1] [1 3 1] [2 4 0] [3 4 1] [2 4 0] % neuron-device [5 2 0] [5 3 1] [5 1 1] [5 1 1] [5 3 1] % device-neuron - [5 4 0] [5 4 0] [5 4 0] [5 4 0] % device-device [1 6 0] [1 6 1] [2 6 0] [2 6 1]> def % neuron-globally receiving device conn { diff --git a/testsuite/unittests/test_connect.sli b/testsuite/unittests/test_connect.sli index 4b9c0b9c15..5ed58fe947 100644 --- a/testsuite/unittests/test_connect.sli +++ b/testsuite/unittests/test_connect.sli @@ -177,3 +177,52 @@ ResetKernel Last /target get 6 eq assert_or_die } forall + +(Running Connect tests with illegal combinations) = +ResetKernel +/generator /poisson_generator Create def +/multimeter /multimeter Create def +/recordable /iaf_psc_alpha Create def + +{ + generator generator Connect +} fail_or_die + +% removing items on stack +pop pop pop pop + +{ + generator multimeter Connect +} fail_or_die + +% removing items on stack +pop pop pop pop + +{ + % recordable -> multimeter + recordable multimeter Connect +} fail_or_die + +% removing items on stack +pop pop pop pop + +{ + recordable generator Connect +} fail_or_die + +% removing items on stack +pop pop pop pop + +{ + multimeter multimeter Connect +} fail_or_die + +% removing items on stack +pop pop pop pop + +{ + multimeter generator Connect +} fail_or_die + +% removing items on stack +pop pop pop pop From 86dc491d8f2624cc8d250e1c20aa261b5f016019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20M=C3=B8rk?= Date: Tue, 4 Apr 2017 14:17:25 +0200 Subject: [PATCH 3/5] Reinstated parts of a deleted test. --- testsuite/regressiontests/issue-211.sli | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testsuite/regressiontests/issue-211.sli b/testsuite/regressiontests/issue-211.sli index 34d5bd6fe8..d49307fc7f 100644 --- a/testsuite/regressiontests/issue-211.sli +++ b/testsuite/regressiontests/issue-211.sli @@ -68,6 +68,10 @@ n2 d4 << /weight 1. >> Connect [g5 g5] [n1] Connect g5 n3 << /weight 1. >> Connect +% device-device +[g5 g5] [d4] Connect +g5 d4 << /weight 1. >> Connect + % neuron-globally receiving device (volume transmitter) n1 v6 Connect n2 v6 Connect @@ -78,6 +82,7 @@ n2 v6 Connect /target_conn <[1 3 1] [2 3 1] [2 1 1] [3 1 1] [2 1 1] % neuron-neuron [1 4 1] [1 3 1] [2 4 0] [3 4 1] [2 4 0] % neuron-device [5 2 0] [5 3 1] [5 1 1] [5 1 1] [5 3 1] % device-neuron + [5 4 0] [5 4 0] [5 4 0] % device-device [1 6 0] [1 6 1] [2 6 0] [2 6 1]> def % neuron-globally receiving device conn { From 10b43d1b10a2234ab412c7d0fca740029955fadb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20M=C3=B8rk?= Date: Tue, 4 Apr 2017 16:50:04 +0200 Subject: [PATCH 4/5] Expanded connection tests, added missing IllegalConnection. Now tests creating of connection between all combinations of models, checking for silent failures. Also, added a missing throw IllegalConnection. --- nestkernel/connection_manager.cpp | 3 +- testsuite/unittests/test_connect.sli | 73 ++++++++++++---------------- 2 files changed, 33 insertions(+), 43 deletions(-) diff --git a/nestkernel/connection_manager.cpp b/nestkernel/connection_manager.cpp index b8aaabf9c1..e00efd86a3 100644 --- a/nestkernel/connection_manager.cpp +++ b/nestkernel/connection_manager.cpp @@ -543,7 +543,8 @@ nest::ConnectionManager::connect( index sgid, // we do not allow to connect a device to a global receiver at the moment if ( not source->has_proxies() ) { - return false; + throw IllegalConnection( "The models " + target->get_name() + " and " + + source->get_name() + " cannot be connected." ); } connect_( *source, *target, sgid, tid, syn, params ); } diff --git a/testsuite/unittests/test_connect.sli b/testsuite/unittests/test_connect.sli index 5ed58fe947..04b5e40048 100644 --- a/testsuite/unittests/test_connect.sli +++ b/testsuite/unittests/test_connect.sli @@ -180,49 +180,38 @@ ResetKernel (Running Connect tests with illegal combinations) = ResetKernel -/generator /poisson_generator Create def -/multimeter /multimeter Create def -/recordable /iaf_psc_alpha Create def +/n_connections 0 def +modeldict { - generator generator Connect -} fail_or_die + pop % remove model id + /model_a Set + /type_a model_a GetDefaults /element_type get def + /m_a model_a Create def + modeldict + { + pop % remove model id + /model_b Set + /type_b model_b GetDefaults /element_type get def + /m_b model_b Create def + + % try to connect model_a and model_b + { + m_a m_b Connect + } stopped not + { % if there is no error, check that a connection has been made + { + n_connections 1 add + 0 GetStatus /num_connections get + eq + } assert_or_die + /n_connections n_connections 1 add def + } + { + 5 npop + } ifelse + } forall -% removing items on stack -pop pop pop pop - -{ - generator multimeter Connect -} fail_or_die - -% removing items on stack -pop pop pop pop - -{ - % recordable -> multimeter - recordable multimeter Connect -} fail_or_die - -% removing items on stack -pop pop pop pop - -{ - recordable generator Connect -} fail_or_die - -% removing items on stack -pop pop pop pop - -{ - multimeter multimeter Connect -} fail_or_die - -% removing items on stack -pop pop pop pop - -{ - multimeter generator Connect -} fail_or_die +} forall +(All illegal connections throw an error) = -% removing items on stack -pop pop pop pop From afb5531a95ba8f39463243ecd7a1a8a365689637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20M=C3=B8rk?= Date: Wed, 5 Apr 2017 10:34:34 +0200 Subject: [PATCH 5/5] Removed unneeded saving of element type and shortened the test. --- testsuite/unittests/test_connect.sli | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/testsuite/unittests/test_connect.sli b/testsuite/unittests/test_connect.sli index 04b5e40048..5b645ddb7e 100644 --- a/testsuite/unittests/test_connect.sli +++ b/testsuite/unittests/test_connect.sli @@ -184,20 +184,14 @@ ResetKernel /n_connections 0 def modeldict { - pop % remove model id - /model_a Set - /type_a model_a GetDefaults /element_type get def - /m_a model_a Create def + pop Create /node_a Set modeldict { - pop % remove model id - /model_b Set - /type_b model_b GetDefaults /element_type get def - /m_b model_b Create def + pop Create /node_b Set - % try to connect model_a and model_b + % try to connect node_a and node_b { - m_a m_b Connect + node_a node_b Connect } stopped not { % if there is no error, check that a connection has been made { @@ -213,5 +207,4 @@ modeldict } forall } forall -(All illegal connections throw an error) =