unaligned.t revision 140920
1139595Smarcel#!/usr/bin/env perl -w 2139595Smarcel# 3139595Smarcel# Copyright (c) 2005 Marcel Moolenaar 4139595Smarcel# All rights reserved. 5139595Smarcel# 6139595Smarcel# Redistribution and use in source and binary forms, with or without 7139595Smarcel# modification, are permitted provided that the following conditions 8139595Smarcel# are met: 9139595Smarcel# 10139595Smarcel# 1. Redistributions of source code must retain the above copyright 11139595Smarcel# notice, this list of conditions and the following disclaimer. 12139595Smarcel# 2. Redistributions in binary form must reproduce the above copyright 13139595Smarcel# notice, this list of conditions and the following disclaimer in the 14139595Smarcel# documentation and/or other materials provided with the distribution. 15139595Smarcel# 16139595Smarcel# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17139595Smarcel# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18139595Smarcel# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19139595Smarcel# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20139595Smarcel# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21139595Smarcel# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22139595Smarcel# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23139595Smarcel# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24139595Smarcel# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25139595Smarcel# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26139595Smarcel# 27139595Smarcel# $FreeBSD: head/tools/regression/ia64/unaligned/unaligned.t 140920 2005-01-27 23:15:58Z marcel $ 28139595Smarcel 29139595Smarcelmy $srcdir = `dirname $0`; 30139595Smarcelchomp $srcdir; 31139595Smarcel 32140892Smarcelmy @accesses = ("Load", "Store"); 33140892Smarcelmy @types = ("Integer", "FloatingPoint"); 34140892Smarcelmy @sizes = ("Small", "Medium", "Large"); 35140892Smarcelmy @postincs = ("NoPostInc", "MinConstPostInc", "PlusConstPostInc", 36140892Smarcel "ScratchRegPostInc", "PreservedRegPostInc"); 37139595Smarcel 38140892Smarcelsub run ($$$$$) { 39140892Smarcel local ($nr, $access, $type, $size, $postinc) = @_; 40140892Smarcel local $test = "${access}_${type}_${size}_${postinc}"; 41140892Smarcel local $tmpfile = "/tmp/" . $$ . "_$test"; 42140892Smarcel local $st; 43139595Smarcel 44140892Smarcel $st = system("cc -o $tmpfile -DACCESS=$access -DTYPE=$type -DSIZE=$size -DPOSTINC=$postinc -Wall -O -g $srcdir/test.c"); 45140892Smarcel if ($st != 0) { 46140892Smarcel print "not ok $nr $test # compiling $test\n"; 47140892Smarcel } 48140892Smarcel else { 49139595Smarcel $st = system($tmpfile); 50139595Smarcel if ($st == 0) { 51140892Smarcel print "ok $nr $test\n"; 52139595Smarcel } 53140892Smarcel elsif ($st == 256) { 54140920Smarcel print "not ok $nr $test # invalid combination\n"; 55139595Smarcel } 56140892Smarcel elsif ($st == 512) { 57140892Smarcel print "not ok $nr $test # value mismatch\n"; 58140892Smarcel } 59140892Smarcel elsif ($st == 1024) { 60140892Smarcel print "not ok $nr $test # post increment mismatch\n"; 61140892Smarcel } 62139595Smarcel else { 63140892Smarcel print "not ok $nr $test # signalled (exit status $st)\n"; 64140892Smarcel return; # Preserve the executable 65139595Smarcel } 66140892Smarcel } 67140892Smarcel unlink $tmpfile; 68139595Smarcel} 69139595Smarcel 70139595Smarcelsystem("sysctl debug.unaligned_test=1"); 71139595Smarcelif (`sysctl -n debug.unaligned_test` != "1") { 72139595Smarcel print "1..0 # SKIP The debug.unaligned_test sysctl could not be set\n"; 73139595Smarcel exit 0; 74139595Smarcel} 75139595Smarcel 76140892Smarcelmy $count = @accesses * @types * @sizes * @postincs; 77140920Smarcel 78140920Smarcel# There's no register based post inc. for stores. 79140920Smarcel$count -= 12; 80140920Smarcel 81139595Smarcelprint "1..$count\n"; 82139595Smarcel 83139595Smarcelmy $nr=0; 84140892Smarcelforeach $access (@accesses) { 85140920Smarcel foreach $postinc (@postincs) { 86140920Smarcel $_ = "$access $postinc"; 87140920Smarcel if (! /Store.+RegPostInc/) { 88140920Smarcel foreach $type (@types) { 89140920Smarcel foreach $size (@sizes) { 90140920Smarcel run ++$nr, $access, $type, $size, $postinc; 91140920Smarcel } 92140892Smarcel } 93139595Smarcel } 94140892Smarcel } 95139595Smarcel} 96139595Smarcel 97139595Smarcelsystem("sysctl debug.unaligned_test=0"); 98139595Smarcel 99139595Smarcelexit 0; 100