/*
 *  issue-527.sli
 *
 *  This file is part of NEST.
 *
 *  Copyright (C) 2004 The NEST Initiative
 *
 *  NEST 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 2 of the License, or
 *  (at your option) any later version.
 *
 *  NEST 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 NEST.  If not, see <http://www.gnu.org/licenses/>.
 *
 */


 /* BeginDocumentation
  Name: testsuite::issue-527
  
  Synopsis: (issue-527) run -> NEST exits if test fails
  
  Description:
  This test ensures that NEST raises an error if the user tries to use 
  DataConnect in multithreaded mode.
  
  Author: Stine B. Vennemo
  FirstVersion: July 2017
  SeeAlso:
*/

(unittest) run
/unittest using

skip_if_not_threaded

/test_threaded_DataConnect
{
  dup /threads Set
  ResetKernel
  0 << /local_num_threads threads >> SetStatus
  
  % Create set of neurons
  /A /iaf_psc_alpha 1 Create def
  /B /iaf_psc_alpha 1000 Create def
  
  % Make target array
  /t [A 1 add 1.0 mul B 1.0 mul] Range def
  
  % Make weight array
  /w [1000] 1.0 LayoutArray def
  
  % Make delay array
  /d [1000] 1.0 LayoutArray def
  
  % Connect using DataConnect
  A << /target t /weight w /delay d >> /static_synapse DataConnect

} def

/* test runs with different number of threads */
[2 16 2] Range
{
  { test_threaded_DataConnect } fail_or_die
}
forall

endusing
