/*
* ticket-396.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::ticket-396 - Ensure that the number of threads cannot be changed after resolution.
Synopsis: (ticket-396) run -> NEST exits if test fails
Description:
This ticket ensures that the number of threads cannot be changed if the resolution
differs from the default resolution.
Author: Hans Ekkehard Plesser, 2012-12-03
*/
/unittest (9726) require
/unittest using
M_ERROR setverbosity
% test against changing local_num_threads
{
ResetKernel
/new_res 0 /resolution get 2 mul def
/new_threads 0 /local_num_threads get 2 mul def
0 << /resolution new_res >> SetStatus
0 << /local_num_threads new_threads >> SetStatus
} fail_or_die
% test against changing total_num_virtual_procs
{
ResetKernel
/new_res 0 /resolution get 2 mul def
/new_procs 0 /total_num_virtual_procs get 2 mul def
0 << /resolution new_res >> SetStatus
0 << /total_num_virtual_procs new_procs >> SetStatus
} fail_or_die
% don't run the remaining tests if we didn't compile with threads
statusdict/threading :: (no) eq {statusdict/exitcodes/success :: quit_i} if
% check that we can change either way before setting resolution
{
ResetKernel
/new_res 0 /resolution get 2 mul def
/new_threads 0 /local_num_threads get 2 mul def
0 << /local_num_threads new_threads >> SetStatus
0 << /resolution new_res >> SetStatus
0 /resolution get new_res eq
0 /local_num_threads get new_threads eq
and
} assert_or_die
{
ResetKernel
/new_res 0 /resolution get 2 mul def
/new_procs 0 /total_num_virtual_procs get 2 mul def
0 << /total_num_virtual_procs new_procs >> SetStatus
0 << /resolution new_res >> SetStatus
0 /resolution get new_res eq
0 /total_num_virtual_procs get new_procs eq
and
} assert_or_die
% test that we can set in single call
{
ResetKernel
/new_res 0 /resolution get 2 mul def
/new_threads 0 /local_num_threads get 2 mul def
0 << /local_num_threads new_threads
/resolution new_res >> SetStatus
0 /resolution get new_res eq
0 /local_num_threads get new_threads eq
and
} assert_or_die
{
ResetKernel
/new_res 0 /resolution get 2 mul def
/new_procs 0 /total_num_virtual_procs get 2 mul def
0 << /total_num_virtual_procs new_procs
/resolution new_res >> SetStatus
0 /resolution get new_res eq
0 /total_num_virtual_procs get new_procs eq
and
} assert_or_die
endusing