3 # Copyright (c) 2005 Marcel Moolenaar
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 my $srcdir = `dirname $0`;
32 my @accesses = ("Load", "Store");
33 my @types = ("Integer", "FloatingPoint");
34 my @sizes = ("Small", "Medium", "Large");
35 my @postincs = ("NoPostInc", "MinConstPostInc", "PlusConstPostInc",
36 "ScratchRegPostInc", "PreservedRegPostInc");
39 local ($nr, $access, $type, $size, $postinc) = @_;
40 local $test = "${access}_${type}_${size}_${postinc}";
41 local $tmpfile = "/tmp/" . $$ . "_$test";
44 $st = system("cc -o $tmpfile -DACCESS=$access -DTYPE=$type -DSIZE=$size -DPOSTINC=$postinc -Wall -O -g $srcdir/test.c");
46 print "not ok $nr $test # compiling $test\n";
49 $st = system($tmpfile);
51 print "ok $nr $test\n";
54 print "not ok $nr $test # invalid combination\n";
57 print "not ok $nr $test # value mismatch\n";
60 print "not ok $nr $test # post increment mismatch\n";
63 print "not ok $nr $test # signalled (exit status $st)\n";
64 return; # Preserve the executable
70 system("sysctl debug.unaligned_test=1");
71 if (`sysctl -n debug.unaligned_test` != "1") {
72 print "1..0 # SKIP The debug.unaligned_test sysctl could not be set\n";
76 my $count = @accesses * @types * @sizes * @postincs;
78 # There's no register based post inc. for stores.
84 foreach $access (@accesses) {
85 foreach $postinc (@postincs) {
86 $_ = "$access $postinc";
87 if (! /Store.+RegPostInc/) {
88 foreach $type (@types) {
89 foreach $size (@sizes) {
90 run ++$nr, $access, $type, $size, $postinc;
97 system("sysctl debug.unaligned_test=0");