From patchwork Fri Oct 13 16:24:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 115799 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp932486qgn; Fri, 13 Oct 2017 09:39:50 -0700 (PDT) X-Received: by 10.55.33.203 with SMTP id f72mr2902220qki.176.1507912790488; Fri, 13 Oct 2017 09:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507912790; cv=none; d=google.com; s=arc-20160816; b=m/e8Diq0Gwf6hI+1zuu7AqQfxUarans5bVwNVrCkd90Uuj1Sao1+4IHm5xKykrU3eH BQPOH7LQsRmDz2fdmJWSgDSVNDKiot25Vr2W0GisqV0orGg0O26D5fkmAyL40XFAPu1X lsHWwiV/wk5wk8Q5gWTyq8JGcubEXH4ZpeDCIHbc/kWp4sShfKsLn1PfhdGmo7gTYaVi czZRBzwq8kww0QtR7A16K3YWWn+jik9Uzh2jXAtLaCYkvrpUGDtdqSpqktz2YCRLOqcc XrhrBCXUGi/FMul1eQ+jQOIniOsQ0zwBOY7jj0jJyWwzCp0rj119xYJNl641ga8GY/m/ sOmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=xj+jn6t73JlhKSswsXO8P/txoe4iBUWKkNZdRIQnS9k=; b=lABZglRnaMVmovBr555/FkfKJVpGc6Tx1/nObkzbVyLUcQnpDqdJCxqX5S6oC/6bMl blXg0Nd/gf4Sc5e6sAimzpoQFVXtP3grJeOYakkySoXt8JGTv5wHthE1aC53Hp6bYmy2 Sj30G6tJ7/EctlBTTCTj1HykPglsQUqXZEF5sASe7dXT5UI2SKtz2RaI0RMjwPSfRH8Y M2y7JrG/HlBkh+ZXPJmejCyqBjqgWgQxRUvRz71QqJFdx79KWH0Ux/r+9RVwtyNDALeN I1EJ4V9C5sLqhkoL4Mr2ou6ZyegWAgeOcNZePdZOh+0qcB9hjDUP4+Utq0F4EVr4keet lvew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MGKIdY1i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t65si1093726qkf.22.2017.10.13.09.39.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Oct 2017 09:39:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MGKIdY1i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32zz-0006RM-Sy for patch@linaro.org; Fri, 13 Oct 2017 12:39:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32sU-0000UE-0u for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:32:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e32sS-0002CR-Pi for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:32:02 -0400 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:50728) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e32sS-0002Bh-H8 for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:32:00 -0400 Received: by mail-wm0-x232.google.com with SMTP id u138so22538024wmu.5 for ; Fri, 13 Oct 2017 09:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xj+jn6t73JlhKSswsXO8P/txoe4iBUWKkNZdRIQnS9k=; b=MGKIdY1iQO2WSibuya8Ce0+JcD7wBMYXvYhghgBoedl8iNXMEy8xVUUqwtDhsj2sU9 jAKqndpmq9G7bsWzv4BsXZsyG1WXV0Ha/C1/+LF7B9atgLe+yOzvsvRCbBFdWcb5QzRD TpUKct/trgXSyrjTdyx68X/NXRTqmOG5qAcp4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xj+jn6t73JlhKSswsXO8P/txoe4iBUWKkNZdRIQnS9k=; b=sg5M/d7fOOtuBc9onxtK+7J/MBYT4uj11HI5rHBy0wj3efbK5xwjsvoZzi1Jr0uNFH WLKlHRto8ANnCyO0TA2hZmQm+VDE7fogJwcKfD63jiwSlDzmLfjiKcN6CPgsatZTVyaX prxTcReQD6Jc169vcwYHcyNtCc9klx3V3of1hsZLi5PE8ZbUJzT+RRt6r9JYduUdppaV YRXPRhAy+LAB7v0OFkbbzJSNVD7aqVHNFKVs3ClIN3fCDItkUfYiyo3dHV8ig6pmDdH5 p7d85mjBaWlUDlI39t091XHv1u0nySgMUwT+xJpeqZ0zc3rBVJmxUQ0MLR+66H50wgRx bQnA== X-Gm-Message-State: AMCzsaXU0U/SGa1iuYT6S0IMLwl5TjrwCDbI9s7v+hfNlGNNGmAhVyGF cC0HOsXUtWuuyiWXpV5t2+QJiw== X-Google-Smtp-Source: ABhQp+TTkBU6DzKqJxfTrPJuLJYwLlnyV+sffoc77Oy3TDtsVi36ytdzLdtv55JIVG/MrbvAYi+ZMA== X-Received: by 10.28.24.7 with SMTP id 7mr2146789wmy.78.1507912319374; Fri, 13 Oct 2017 09:31:59 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id n19sm1941695wrn.52.2017.10.13.09.31.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 09:31:58 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 553483E10E9; Fri, 13 Oct 2017 17:24:40 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: richard.henderson@linaro.org Date: Fri, 13 Oct 2017 17:24:34 +0100 Message-Id: <20171013162438.32458-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171013162438.32458-1-alex.bennee@linaro.org> References: <20171013162438.32458-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::232 Subject: [Qemu-devel] [RFC PATCH 26/30] tests/test-softfloat: add a simple test framework X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is a simple pattern based framework for testing our softfloat implementation. It is easier to use while debugging softfloat itself than indirectly with a tool like risu. As the softfloat library is built against given targets we need a version per target architecture we build. Signed-off-by: Alex Bennée --- tests/Makefile.include | 8 ++++++- tests/test-softfloat.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tests/test-softfloat.c -- 2.14.1 diff --git a/tests/Makefile.include b/tests/Makefile.include index 4ca15e6817..8bf1dfd19a 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -156,6 +156,10 @@ check-unit-y += tests/ptimer-test$(EXESUF) gcov-files-ptimer-test-y = hw/core/ptimer.c check-unit-y += tests/test-qapi-util$(EXESUF) gcov-files-test-qapi-util-y = qapi/qapi-util.c +check-unit-y += tests/test-softfloat$(EXESUF) +gcov-files-test-softfloat-y = fpu/softfloat.c +check-unit-y += tests/test-softfloat-aarch64$(EXESUF) +gcov-files-test-softfloat-aarch64-y = fpu/softfloat.c check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh @@ -555,7 +559,7 @@ test-obj-y = tests/check-qnum.o tests/check-qstring.o tests/check-qdict.o \ tests/rcutorture.o tests/test-rcu-list.o \ tests/test-qdist.o tests/test-shift128.o \ tests/test-qht.o tests/qht-bench.o tests/test-qht-par.o \ - tests/atomic_add-bench.o + tests/atomic_add-bench.o tests/test-softfloat.o $(test-obj-y): QEMU_INCLUDES += -Itests QEMU_CFLAGS += -I$(SRC_PATH)/tests @@ -604,6 +608,8 @@ tests/test-qht-par$(EXESUF): tests/test-qht-par.o tests/qht-bench$(EXESUF) $(tes tests/qht-bench$(EXESUF): tests/qht-bench.o $(test-util-obj-y) tests/test-bufferiszero$(EXESUF): tests/test-bufferiszero.o $(test-util-obj-y) tests/atomic_add-bench$(EXESUF): tests/atomic_add-bench.o $(test-util-obj-y) +tests/test-softfloat$(EXESUF): tests/test-softfloat.o $(BUILD_DIR)/aarch64-softmmu/fpu/softfloat.o +tests/test-softfloat-aarch64$(EXESUF): tests/test-softfloat.o $(BUILD_DIR)/aarch64-softmmu/fpu/softfloat.o tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\ diff --git a/tests/test-softfloat.c b/tests/test-softfloat.c new file mode 100644 index 0000000000..d7b740e1cb --- /dev/null +++ b/tests/test-softfloat.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2017, Linaro + * Author: Alex Bennée + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "fpu/softfloat.h" + +typedef struct { + float_status initial_status; + float16 in; + float16 out; + uint8_t final_exception_flags; +} f16_test_data; + +static void test_f16_round_to_int(void) +{ + int i; + float16 out; + float_status flags, *fp = &flags; + f16_test_data test_data[] = { + { { /* defaults */ }, 0x87FF, 0x8000 }, + { { /* defaults */ }, 0xE850, 0xE850 }, + { { /* defaults */ }, 0x0000, 0x0000 }, + { { /* defaults */ }, 0x857F, 0x8000 }, + { { /* defaults */ }, 0x74FB, 0x74FB }, + /* from risu 3b4: 4ef98945 frintp v5.8h, v10.8h */ + { { .float_detect_tininess = 1, .float_rounding_mode = 2}, 0x06b1, 0x3c00, 0 }, + { { .float_detect_tininess = 1, .float_rounding_mode = 2}, 0x6966, 0x6966, 0 }, + { { .float_detect_tininess = 1, .float_rounding_mode = 2}, 0x83c0, 0x8000, 0 }, + { { .float_detect_tininess = 1, .float_rounding_mode = 2}, 0xa619, 0x8000, 0 }, + { { .float_detect_tininess = 1, .float_rounding_mode = 2}, 0x9cf4, 0x8000, 0 }, + { { .float_detect_tininess = 1, .float_rounding_mode = 2}, 0xee11, 0xee11, 0 }, + { { .float_detect_tininess = 1, .float_rounding_mode = 2}, 0xee5c, 0xee5c, 0 }, + { { .float_detect_tininess = 1, .float_rounding_mode = 2}, 0x8004, 0x8000, 0 } + }; + + for (i = 0; i < ARRAY_SIZE(test_data); ++i) { + flags = test_data[i].initial_status; + out = float16_round_to_int(test_data[i].in, fp); + + if (!(test_data[i].out == out)) { + fprintf(stderr, "%s[%d]: expected %#04x got %#04x\n", + __func__, i, test_data[i].out, out); + g_test_fail(); + } + } +} + +int main(int argc, char *argv[]) +{ + g_test_init(&argc, &argv, NULL); + g_test_add_func("/softfloat/f16/round_to_int", test_f16_round_to_int); + return g_test_run(); +}