Emilio G. Cota writes:
> This will allow us to run correctness tests against our
> FP implementation. The test can be run in two modes (called
> "testers"): host and soft. With the former we check the results
> and FP flags on the host machine against the model.
> With the latter we check QEMU's fpu primitives against the
> model. Note that in soft mode we are not instantiating any
> particular CPU (hence the HW_POISON_H hack to avoid macro poisoning);
> for that we need to run the test in host mode under QEMU.
So with the attached patch and my proposed cross build we can now get:
02:15:54 [alex@zen:~/l/q/qemu.git] softfloat-fixes-for-2.12-v1 ± find . -iname
"fp-test" | xargs file
./ppc64-linux-user/tests/fp-test: ELF 64-bit LSB executable, 64-bit
PowerPC or cisco 7500, version 1 (GNU/Linux), statically linked, for GNU/Linux
3.2.0, not stripped
./armeb-linux-user/tests/fp-test: ELF 32-bit LSB executable, ARM, EABI5
version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, not stripped
./aarch64-linux-user/tests/fp-test:ELF 64-bit LSB executable, ARM aarch64,
version 1 (SYSV), statically linked, for GNU/Linux 3.7.0, not stripped
./i386-linux-user/tests/fp-test: ELF 32-bit LSB executable, Intel 80386,
version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, not stripped
./arm-linux-user/tests/fp-test:ELF 32-bit LSB executable, ARM, EABI5
version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, not stripped
./s390x-linux-user/tests/fp-test: ELF 64-bit MSB executable, IBM S/390,
version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, not stripped
./aarch64_be-linux-user/tests/fp-test: ELF 64-bit LSB executable, ARM aarch64,
version 1 (SYSV), statically linked, for GNU/Linux 3.7.0, not stripped
./tests/fp-test/fp-test: ELF 64-bit LSB shared object, x86-64,
version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2,
for GNU/Linux 2.6.32, not stripped
But it did mean having to hack about a little, mainly to get rid of
glib.
--8<---cut here---start->8---
>From 04ed0d9f58f34aa51b9a8284514aab6e36a702b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alex=20Benn=C3=A9e?=
Date: Wed, 11 Apr 2018 01:35:52 +0100
Subject: [PATCH] tests/tcg: add fp-test to per-guest tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The fp-test code was originally designed to be able to include
softfloat. However cross-compiling QEMU based code is harder than it
needs to be so hide softfloat stuff behind USE_SOFTFLOAT. We also need
to tweak:
- manually include what we need
- g_assert -> assert()
- use libc hsearch instead of g_hash_table
Signed-off-by: Alex Bennée
---
tests/fp/fp-test.c | 148 ++---
tests/tcg/Makefile | 3 ++
2 files changed, 121 insertions(+), 30 deletions(-)
diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
index 27637c4617..4cee2a918c 100644
--- a/tests/fp/fp-test.c
+++ b/tests/fp/fp-test.c
@@ -6,12 +6,72 @@
* License: GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
-#ifndef HW_POISON_H
-#error Must define HW_POISON_H to work around TARGET_* poisoning
-#endif
+
+/* If HW_POISON_H isn't defined then we aren't building against qemu's
+ * softfloat */
+#ifdef HW_POISON_H
#include "qemu/osdep.h"
#include "fpu/softfloat.h"
+#define USE_SOFTFLOAT 1
+
+#else /* else define what QEMU would have given us */
+
+#define _GNU_SOURCE
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+/* See include/fpu/softfloat-types.h */
+enum {
+float_tininess_after_rounding = 0,
+float_tininess_before_rounding = 1
+};
+
+enum {
+float_round_nearest_even = 0,
+float_round_down = 1,
+float_round_up = 2,
+float_round_to_zero = 3,
+float_round_ties_away= 4,
+float_round_to_odd = 5,
+};
+
+enum {
+float_flag_invalid = 1,
+float_flag_divbyzero = 4,
+float_flag_overflow = 8,
+float_flag_underflow = 16,
+float_flag_inexact = 32,
+float_flag_input_denormal = 64,
+float_flag_output_denormal = 128
+};
+
+/* See include/compiler.h */
+#ifndef likely
+#if __GNUC__ < 3
+#define __builtin_expect(x, n) (x)
+#endif
+
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#endif
+
+#endif
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
#include
#include
@@ -116,16 +176,18 @@ struct tester {
struct whitelist {
char **lines;
size_t n;
-GHashTable *ht;
+struct hsearch_data ht;
};
static uint64_t test_stats[ERROR_MAX];
static struct whitelist whitelist;
static uint8_t default_exceptions;
static bool die_on_error = true;
+#ifdef USE_SOFTFLOAT
static struct float_status soft_status = {
.float_det