1*32b59da6Schristos# $NetBSD: t_dotcmd.sh,v 1.2 2016/03/27 14:57:50 christos Exp $ 29462261dSchristos# 39462261dSchristos# Copyright (c) 2014 The NetBSD Foundation, Inc. 49462261dSchristos# All rights reserved. 59462261dSchristos# 69462261dSchristos# This code is derived from software contributed to The NetBSD Foundation 79462261dSchristos# by Jarmo Jaakkola. 89462261dSchristos# 99462261dSchristos# Redistribution and use in source and binary forms, with or without 109462261dSchristos# modification, are permitted provided that the following conditions 119462261dSchristos# are met: 129462261dSchristos# 1. Redistributions of source code must retain the above copyright 139462261dSchristos# notice, this list of conditions and the following disclaimer. 149462261dSchristos# 2. Redistributions in binary form must reproduce the above copyright 159462261dSchristos# notice, this list of conditions and the following disclaimer in the 169462261dSchristos# documentation and/or other materials provided with the distribution. 179462261dSchristos# 189462261dSchristos# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 199462261dSchristos# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 209462261dSchristos# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 219462261dSchristos# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 229462261dSchristos# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 239462261dSchristos# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 249462261dSchristos# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 259462261dSchristos# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 269462261dSchristos# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 279462261dSchristos# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 289462261dSchristos# POSSIBILITY OF SUCH DAMAGE. 299462261dSchristos# 309462261dSchristos 319462261dSchristos# Test loop and function flow control statements in various scopes in a file 329462261dSchristos# sourced by a dotcmd in various scopes. Basically, dotcmd is like #include 339462261dSchristos# in C/C++ so, for example, if the dotcmd is in a loop's body, a break in 349462261dSchristos# the sourced file can be used to break out of that loop. 359462261dSchristos 36*32b59da6Schristos# Note that the standard does not require this, and allows lexically 37*32b59da6Schristos# scoped interpretation of break/continue (and permits dynamic scope 38*32b59da6Schristos# as an optional extension.) 39*32b59da6Schristos 409462261dSchristoscmds='return break continue' 419462261dSchristosscopes='case compound file for func subshell until while' 429462261dSchristos 439462261dSchristoscase_ids='' 449462261dSchristos 459462261dSchristosfor dot_scope in ${scopes} 469462261dSchristosdo 479462261dSchristos for cmd in ${cmds} 489462261dSchristos do 499462261dSchristos for cmd_scope in ${scopes} 509462261dSchristos do 519462261dSchristos case_id="${dot_scope}_${cmd}_${cmd_scope}" 529462261dSchristos case_ids="${case_ids} ${case_id}" 539462261dSchristos atf_test_case "${case_id}" 549462261dSchristos eval " 559462261dSchristos${case_id}_head() 569462261dSchristos{ 579462261dSchristos atf_set 'descr' \\ 589462261dSchristos 'dotcmd in ${dot_scope}, file contains ${cmd} in ${cmd_scope}' 599462261dSchristos} 609462261dSchristos 619462261dSchristos${case_id}_body() 629462261dSchristos{ 639462261dSchristos srcdir=\$(atf_get_srcdir) 649462261dSchristos # for dotcmd to find the sourced files 659462261dSchristos PATH=\"\${PATH}:\${srcdir}\" 669462261dSchristos atf_check -o file:\"\${srcdir}/out/${case_id}.out\" \\ 679462261dSchristos \"\${srcdir}/${case_id}\" 689462261dSchristos} 699462261dSchristos" # end eval 709462261dSchristos done 719462261dSchristos done 729462261dSchristosdone 739462261dSchristos 749462261dSchristosatf_init_test_cases() 759462261dSchristos{ 769462261dSchristos for case_id in ${case_ids} 779462261dSchristos do 789462261dSchristos atf_add_test_case "${case_id}" 799462261dSchristos done 809462261dSchristos} 81