summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2005-01-02 21:33:40 +0000
committermarcel <marcel@FreeBSD.org>2005-01-02 21:33:40 +0000
commit5370f7380f710aca50f958ddbd1f645480c15f99 (patch)
tree5568e36872359fe306396fc4024641c092b4a4d2 /tools
parent13cad23620e00678d1e92fa5fbfb6c363e4cf977 (diff)
downloadFreeBSD-src-5370f7380f710aca50f958ddbd1f645480c15f99.zip
FreeBSD-src-5370f7380f710aca50f958ddbd1f645480c15f99.tar.gz
Regression test for unaligned loads and stores for short, int, long,
float, double and long double types. No post-increment tests yet. All tests are skipped if the debug.unaligned_test sysctl variable cannot be set to 1.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/ia64/unaligned/test.c60
-rw-r--r--tools/regression/ia64/unaligned/unaligned.t84
2 files changed, 144 insertions, 0 deletions
diff --git a/tools/regression/ia64/unaligned/test.c b/tools/regression/ia64/unaligned/test.c
new file mode 100644
index 0000000..2d8e4e4
--- /dev/null
+++ b/tools/regression/ia64/unaligned/test.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2005 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <string.h>
+
+struct {
+ DATA_TYPE aligned;
+ char _;
+ char misaligned[sizeof(DATA_TYPE)];
+} data;
+
+int
+main()
+{
+ DATA_TYPE *aligned = &data.aligned;
+ DATA_TYPE *misaligned = (DATA_TYPE *)data.misaligned;
+ DATA_TYPE value = DATA_VALUE;
+
+ /* Set PSR.ac. */
+ asm volatile("sum 8");
+
+#if defined(TEST_STORE)
+ /* Misaligned store. */
+ *misaligned = value;
+ memcpy(aligned, misaligned, sizeof(DATA_TYPE));
+#elif defined(TEST_LOAD)
+ memcpy(misaligned, &value, sizeof(DATA_TYPE));
+ /* Misaligned load. */
+ *aligned = *misaligned;
+#else
+#error Define TEST_LOAD or TEST_STORE
+#endif
+
+ return (*aligned == value) ? 0 : 1;
+}
diff --git a/tools/regression/ia64/unaligned/unaligned.t b/tools/regression/ia64/unaligned/unaligned.t
new file mode 100644
index 0000000..57a31cd
--- /dev/null
+++ b/tools/regression/ia64/unaligned/unaligned.t
@@ -0,0 +1,84 @@
+#!/usr/bin/env perl -w
+#
+# Copyright (c) 2005 Marcel Moolenaar
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+
+my $srcdir = `dirname $0`;
+chomp $srcdir;
+
+my $tmpfile = "/tmp/unaligned." . $$;
+
+my @types = ("short", "int", "long", "float", "double", "long double");
+my %values = ( "short" => "0x1234",
+ "int" => "0x12345678",
+ "long" => "0x123456789abcdef0",
+ "float" => "1.04716",
+ "double" => "3.1415",
+ "long double" => "0.33312112048384"
+ );
+my @tests = ("TEST_LOAD", "TEST_STORE");
+
+sub run ($$$) {
+ local ($nr, $type, $test) = @_;
+ local $value = $values{$type};
+ local $st;
+ $st = system("cc -o $tmpfile -DDATA_TYPE='$type' -DDATA_VALUE=$value -D$test -Wall $srcdir/test.c");
+ if ($st != 0) {
+ print "not ok $nr ($type,$test) # compiling $tmpfile\n";
+ return;
+ }
+ $st = system($tmpfile);
+ if ($st == 0) {
+ print "ok $nr ($type,$test)\n";
+ }
+ elsif ($st == 1) {
+ print "not ok $nr ($type,$test) # value mismatch\n";
+ }
+ else {
+ print "not ok $nr ($type,$test) # signalled\n";
+ }
+ unlink $tmpfile;
+}
+
+system("sysctl debug.unaligned_test=1");
+if (`sysctl -n debug.unaligned_test` != "1") {
+ print "1..0 # SKIP The debug.unaligned_test sysctl could not be set\n";
+ exit 0;
+}
+
+my $count = @types * @tests;
+print "1..$count\n";
+
+my $nr=0;
+foreach $type (@types) {
+ foreach $test (@tests) {
+ run ++$nr, $type, $test;
+ }
+}
+
+system("sysctl debug.unaligned_test=0");
+
+exit 0;
OpenPOWER on IntegriCloud