brl.t revision 160416
1160416Smarcel#!/usr/bin/env perl -w 2160416Smarcel# 3160416Smarcel# Copyright (c) 2006 Marcel Moolenaar 4160416Smarcel# All rights reserved. 5160416Smarcel# 6160416Smarcel# Redistribution and use in source and binary forms, with or without 7160416Smarcel# modification, are permitted provided that the following conditions 8160416Smarcel# are met: 9160416Smarcel# 10160416Smarcel# 1. Redistributions of source code must retain the above copyright 11160416Smarcel# notice, this list of conditions and the following disclaimer. 12160416Smarcel# 2. Redistributions in binary form must reproduce the above copyright 13160416Smarcel# notice, this list of conditions and the following disclaimer in the 14160416Smarcel# documentation and/or other materials provided with the distribution. 15160416Smarcel# 16160416Smarcel# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17160416Smarcel# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18160416Smarcel# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19160416Smarcel# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20160416Smarcel# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21160416Smarcel# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22160416Smarcel# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23160416Smarcel# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24160416Smarcel# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25160416Smarcel# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26160416Smarcel# 27160416Smarcel# $FreeBSD: head/tools/regression/ia64/emulated/brl.t 160416 2006-07-17 00:27:12Z marcel $ 28160416Smarcel 29160416Smarcelmy $srcdir = `dirname $0`; 30160416Smarcelchomp $srcdir; 31160416Smarcel 32160416Smarcelmy @types = ("Call", "Cond"); 33160416Smarcelmy @preds = ("False", "True"); 34160416Smarcelmy %variant_mapping = ( 35160416Smarcel "Call" => "", 36160416Smarcel "Cond" => "Backward Forward" 37160416Smarcel); 38160416Smarcel 39160416Smarcelsub run ($$$$) { 40160416Smarcel local ($nr, $type, $pred, $var) = @_; 41160416Smarcel local $test = "${type}_${pred}_${var}"; 42160416Smarcel local $tmpfile = "/tmp/" . $$ . "_$test"; 43160416Smarcel local $st; 44160416Smarcel 45160416Smarcel $st = system("cc -o $tmpfile -DTYPE=$type -DPRED=$pred -DVAR=$var -Wall -O1 -g $srcdir/test.c"); 46160416Smarcel if ($st != 0) { 47160416Smarcel print "not ok $nr $test # compiling $test\n"; 48160416Smarcel } 49160416Smarcel else { 50160416Smarcel $st = system($tmpfile); 51160416Smarcel if ($st == 0) { 52160416Smarcel print "ok $nr $test\n"; 53160416Smarcel } 54160416Smarcel elsif ($st == 256) { 55160416Smarcel print "not ok $nr $test # invalid combination\n"; 56160416Smarcel } 57160416Smarcel elsif ($st == 512) { 58160416Smarcel print "not ok $nr $test # long branch failure\n"; 59160416Smarcel } 60160416Smarcel else { 61160416Smarcel print "not ok $nr $test # signalled (exit status $st)\n"; 62160416Smarcel return; # Preserve the executable 63160416Smarcel } 64160416Smarcel } 65160416Smarcel unlink $tmpfile; 66160416Smarcel} 67160416Smarcel 68160416Smarcel# 69160416Smarcel# We can only test the long brach emulation on the Merced processor. 70160416Smarcel# Check for that and skip these tests if it's not... 71160416Smarcel# 72160416Smarcel$_ = `sysctl -n hw.model`; 73160416Smarcelif (! /^Merced$/) { 74160416Smarcel print "1..0 # SKIP This test can only be run on the Merced\n"; 75160416Smarcel exit 0; 76160416Smarcel} 77160416Smarcel 78160416Smarcel# 79160416Smarcel# Get the total number of tests we're going to perform. 80160416Smarcel# 81160416Smarcelmy $count = 0; 82160416Smarcelforeach $type (@types) { 83160416Smarcel my @variants = split(/ /, $variant_mapping{$type}); 84160416Smarcel $count += @preds * @variants; 85160416Smarcel} 86160416Smarcel 87160416Smarcelprint "1..$count\n"; 88160416Smarcel 89160416Smarcelmy $nr=0; 90160416Smarcelforeach $type (@types) { 91160416Smarcel my @variants = split(/ /, $variant_mapping{$type}); 92160416Smarcel foreach $pred (@preds) { 93160416Smarcel foreach $var (@variants) { 94160416Smarcel run ++$nr, $type, $pred, $var; 95160416Smarcel } 96160416Smarcel } 97160416Smarcel} 98160416Smarcel 99160416Smarcelexit 0; 100