From patchwork Sat Feb 4 16:32:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 650653 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp1446666pva; Sat, 4 Feb 2023 08:36:07 -0800 (PST) X-Google-Smtp-Source: AK7set8bj9whbFseniX53U88uQexJi7YsNwIn3HPg9tUEBaLeAki5ZdXLsL4VUrAtuzGSnjtsnvM X-Received: by 2002:a05:6214:c86:b0:56b:ec7f:6c93 with SMTP id r6-20020a0562140c8600b0056bec7f6c93mr2753514qvr.19.1675528567102; Sat, 04 Feb 2023 08:36:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675528567; cv=none; d=google.com; s=arc-20160816; b=ncx3GhSQn0Jy56O2lvUPD4awgY+6fUcHNKI5ml7eQDCtMLakgJjBwFhnWDSCMy8czg d3ygV2apEcUQ5COwpVMNrlZn7BA3BpVgrMiYiQkhxM2CqZrZN9ExA37ZjfmUaE7W7Lzl yj8eKyTGmtIWl4hW2WltWXfe6RbR/VB14rgeM/EpV3R6REYlTU7370xDVBuQfOn8OpTa zLPE6ZE4BWPcShiCl6vTfUpyjSkCUk5GjBp5TCRkS7QsJewZ7W+GBc3XV6Tugi5hVTH5 5XQA/M/04LUotmVC09ypVlZZgaduxOIz8jvnzfN8blMUlhGFAumh/kFp9zARFBqECST/ nAdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LHzGWvWFa4q7FhR/Zjnl6sZxcznG5V94Bca4nmBi0Ko=; b=wc8BRnU5dsyNXxXLP6++IWvpEAl5us9KgXrjoYsDsTSZ/qtKH9w6F3GMQpyMFT+wF9 UekiXfeKqLr/rLdhId+0GE1otZzdzA12/jZclziO1BcC75KbfHDKCC5O9DqzvPIk1Hfn Ct/P5biT74jGpNpAJIk6qJL1mRN6ul8HZ5s0t14VmnG7dSX4DdNhtpyFFuc5ojuLqmGK nwpCQmE1oAor/kUTjHS0UsD+8Ny/XV3tpawzVESymDTtCHhoaz4KLX+/a/HIezAEvvWb /9e2/DdrMS0Of6wjg+qE1vYZp2iELXrQCPiLWFrQKeXSlSCVqLRfhzLRNeBhgULvdHHq zLtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ig4/SysT"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g10-20020a0cd7ca000000b0053777b28b0asi3803312qvj.76.2023.02.04.08.36.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 Feb 2023 08:36:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ig4/SysT"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOLUC-0005Cc-2i; Sat, 04 Feb 2023 11:33:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOLUA-0005C6-6t for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:33:54 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pOLU8-0002Zi-FW for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:33:53 -0500 Received: by mail-pl1-x62e.google.com with SMTP id m2so8169531plg.4 for ; Sat, 04 Feb 2023 08:33:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LHzGWvWFa4q7FhR/Zjnl6sZxcznG5V94Bca4nmBi0Ko=; b=ig4/SysTRaWjy2kyKN1pQPtwnwTQ23MIrRrPphhzpDDLN6X3lxvmd39ocT8EqDforg s9IEOl0blc00WrgVEsfM1Vmdb/OWM/Y/9eou+fIZk6LeBf/NWRGjuKBBdP2UgxTJsgVh dNmUu2IpC0qnmRqszQb/x0lJpf5LZSHNwIEembdLoSdvhDMhwAHN6JAecDXK5AfKy/4B 9yO3riMlUyEA+3CvdvUddanZlvZ44GKho3z+AiNtjPVbfhjSnge+kTM/js0ajzWfzruJ iAcrJv03MEbk0avFB5HRcik2QrRyu76h+oJgJWTybAO/poRpUahbkBVpcnxXtHMsKkku HZfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LHzGWvWFa4q7FhR/Zjnl6sZxcznG5V94Bca4nmBi0Ko=; b=YDwvENVmkW4f1oONHQp7XyoUmsmkcMFakui365jgWtVmXGXMRskXs06B5c0rismpvD qYTxo/uWTuLDGf1C82IBghW+bynhJZrDNyku9B7br/2VyUej8e5JNXSpbuY8PA84Zxqr mdxMAMwB2ejpF4uumazEEhNnmMQhjKQuGIPkDcee0EClqDY9AA2zSkoyf/bje7Tw82Te Fa8Lxlm5jE/s14PTiTjHqRIkgRiwPWKo1jOxWWZlONncozJ1FkIk7mUUC0Dp/qiAK8ix 3+XJmA7IWPh4cMHBLn9n59k0tixhPLys5FYXTwUdsUXr8xGGLKlaMjTEh3SkNn1NAiTi aIRw== X-Gm-Message-State: AO0yUKUsewoi1s/AOpGTu8jrzTYQwDdFjSEaxmk7Z4P9A5dsqp/2jjBT 4rofYaL+gYzeO6BITUX/2lkTcQ4NPyauqLS6 X-Received: by 2002:a05:6a20:d704:b0:bf:8866:f46d with SMTP id iz4-20020a056a20d70400b000bf8866f46dmr11106923pzb.34.1675528431077; Sat, 04 Feb 2023 08:33:51 -0800 (PST) Received: from stoup.. (rrcs-173-197-98-118.west.biz.rr.com. [173.197.98.118]) by smtp.gmail.com with ESMTPSA id w19-20020a1709029a9300b00186b69157ecsm3660859plp.202.2023.02.04.08.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 08:33:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Ilya Leoshkevich Subject: [PULL 24/40] tests/tcg/s390x: Add clst.c Date: Sat, 4 Feb 2023 06:32:54 -1000 Message-Id: <20230204163310.815536-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204163310.815536-1-richard.henderson@linaro.org> References: <20230204163310.815536-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Ilya Leoshkevich Add a basic test to prevent regressions. Signed-off-by: Ilya Leoshkevich Message-Id: <20221025213008.2209006-2-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- tests/tcg/s390x/clst.c | 82 +++++++++++++++++++++++++++++++++ tests/tcg/s390x/Makefile.target | 1 + 2 files changed, 83 insertions(+) create mode 100644 tests/tcg/s390x/clst.c diff --git a/tests/tcg/s390x/clst.c b/tests/tcg/s390x/clst.c new file mode 100644 index 0000000000..ed2fe7326c --- /dev/null +++ b/tests/tcg/s390x/clst.c @@ -0,0 +1,82 @@ +#define _GNU_SOURCE +#include +#include + +static int clst(char sep, const char **s1, const char **s2) +{ + const char *r1 = *s1; + const char *r2 = *s2; + int cc; + + do { + register int r0 asm("r0") = sep; + + asm("clst %[r1],%[r2]\n" + "ipm %[cc]\n" + "srl %[cc],28" + : [r1] "+r" (r1), [r2] "+r" (r2), "+r" (r0), [cc] "=r" (cc) + : + : "cc"); + *s1 = r1; + *s2 = r2; + } while (cc == 3); + + return cc; +} + +static const struct test { + const char *name; + char sep; + const char *s1; + const char *s2; + int exp_cc; + int exp_off; +} tests[] = { + { + .name = "cc0", + .sep = 0, + .s1 = "aa", + .s2 = "aa", + .exp_cc = 0, + .exp_off = 0, + }, + { + .name = "cc1", + .sep = 1, + .s1 = "a\x01", + .s2 = "aa\x01", + .exp_cc = 1, + .exp_off = 1, + }, + { + .name = "cc2", + .sep = 2, + .s1 = "abc\x02", + .s2 = "abb\x02", + .exp_cc = 2, + .exp_off = 2, + }, +}; + +int main(void) +{ + const struct test *t; + const char *s1, *s2; + size_t i; + int cc; + + for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { + t = &tests[i]; + s1 = t->s1; + s2 = t->s2; + cc = clst(t->sep, &s1, &s2); + if (cc != t->exp_cc || + s1 != t->s1 + t->exp_off || + s2 != t->s2 + t->exp_off) { + fprintf(stderr, "%s\n", t->name); + return EXIT_FAILURE; + } + } + + return EXIT_SUCCESS; +} diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target index ab7a3bcfb2..79250f31dd 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -25,6 +25,7 @@ TESTS+=signals-s390x TESTS+=branch-relative-long TESTS+=noexec TESTS+=div +TESTS+=clst Z13_TESTS=vistr $(Z13_TESTS): CFLAGS+=-march=z13 -O2