unaligned.t revision 140892
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 140892 2005-01-27 06:50:05Z 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) { 54140892Smarcel print "ok $nr $test # SKIP nonexistent 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; 77139595Smarcelprint "1..$count\n"; 78139595Smarcel 79139595Smarcelmy $nr=0; 80140892Smarcelforeach $access (@accesses) { 81140892Smarcel foreach $type (@types) { 82140892Smarcel foreach $size (@sizes) { 83140892Smarcel foreach $postinc (@postincs) { 84140892Smarcel run ++$nr, $access, $type, $size, $postinc; 85140892Smarcel } 86139595Smarcel } 87140892Smarcel } 88139595Smarcel} 89139595Smarcel 90139595Smarcelsystem("sysctl debug.unaligned_test=0"); 91139595Smarcel 92139595Smarcelexit 0; 93