1272343Sngie# $NetBSD: t_asm.sh,v 1.1 2013/02/16 12:44:26 jmmv Exp $ 2272343Sngie# 3272343Sngie# Copyright (c) 2011 The NetBSD Foundation, Inc. 4272343Sngie# All rights reserved. 5272343Sngie# 6272343Sngie# Redistribution and use in source and binary forms, with or without 7272343Sngie# modification, are permitted provided that the following conditions are 8272343Sngie# met: 9272343Sngie# 10272343Sngie# 1. Redistributions of source code must retain the above copyright 11272343Sngie# notice, this list of conditions and the following disclaimer. 12272343Sngie# 2. Redistributions in binary form must reproduce the above copyright 13272343Sngie# notice, this list of conditions and the following disclaimer in the 14272343Sngie# documentation and/or other materials provided with the distribution. 15272343Sngie# 16272343Sngie# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17272343Sngie# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18272343Sngie# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19272343Sngie# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 20272343Sngie# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21272343Sngie# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22272343Sngie# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23272343Sngie# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24272343Sngie# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25272343Sngie# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26272343Sngie# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27272343Sngie# 28272343Sngie 29272343Sngie# check_implemented <example_name> 30272343Sngie# 31272343Sngie# Verifies if a particular asm example is implemented for the current 32272343Sngie# platform. The example_name argument is the name of the subdirectory 33272343Sngie# of the examples/asm/ subtree that includes the code for the example 34272343Sngie# under test. 35272343Sngie# 36272343Sngie# If the example is not implemented, the calling test is skipped. If the 37272343Sngie# check for implementation fails, the calling test is failed. 38272343Sngiecheck_implemented() { 39272343Sngie local name="${1}"; shift 40272343Sngie 41272343Sngie local implemented=$(cd /usr/share/examples/asm/${name}/ && \ 42272343Sngie make check-implemented) 43272343Sngie [ $? -eq 0 ] || atf_fail "Failed to determine if the sample" \ 44272343Sngie "program is supported" 45272343Sngie [ "${implemented}" = yes ] || atf_skip "Example program not" \ 46272343Sngie "implemented on this platform" 47272343Sngie} 48272343Sngie 49272343Sngie# copy_example <example_name> 50272343Sngie# 51272343Sngie# Copies the example code and supporting Makefiles into the current 52272343Sngie# directory. 53272343Sngiecopy_example() { 54272343Sngie local name="${1}"; shift 55272343Sngie 56272343Sngie cp /usr/share/examples/asm/${name}/* . 57272343Sngie} 58272343Sngie 59272343Sngieatf_test_case hello 60272343Sngiehello_head() { 61272343Sngie atf_set "descr" "Builds, runs and validates the 'hello' asm example" 62272343Sngie atf_set "require.files" "/usr/share/examples/asm/hello/" 63272343Sngie atf_set "require.progs" "make" 64272343Sngie} 65272343Sngiehello_body() { 66272343Sngie check_implemented hello 67272343Sngie copy_example hello 68272343Sngie atf_check -s exit:0 -o ignore -e ignore make 69272343Sngie atf_check -s exit:0 -o inline:'Hello, world!\n' -e empty ./hello 70272343Sngie} 71272343Sngie 72272343Sngieatf_init_test_cases() { 73272343Sngie atf_add_test_case hello 74272343Sngie} 75