From patchwork Fri Nov 11 08:08:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623720 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp633023pvb; Fri, 11 Nov 2022 00:26:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf4u/uRcHmM6nVh6e+2YrNvXMR1avpnsL2tLb+9nmVg9FaXoMkyXiS1rgHyLm4+EqOh5kQNU X-Received: by 2002:a37:b2c6:0:b0:6fa:15e3:2fac with SMTP id b189-20020a37b2c6000000b006fa15e32facmr273586qkf.116.1668155174177; Fri, 11 Nov 2022 00:26:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668155174; cv=none; d=google.com; s=arc-20160816; b=B8tQpEs0JWdivt6NqiKEadTFuT+SlO5xeQIC5D/ov9IB07DJJ8dOzi4sC6rfzXiMtJ 3mxlV44bgyWDUQmDYA9Z/PWP+zCOClcnibIg/46l1JUPqd8BG28p/G19XzNtLWG+aY3p Y3D495+8O+A/2a29K5YWWhlJe9AyPrEziyvClcjjDR8OUkbUkmfrE+WEGXbg+qB/Ou5k wc8dT5mdJtcOfbExnRgBOFohgNffXTUeGfJpaNGc7YMMtZLlLVR6pUPKlDLeANxv26Ol sOQgISU2PbGmCT/5N8HAnMdr4OaCvO2yk+xUrMKLGjTNwlIDeQXNxaFxm6jLrbjRBucB 3XsQ== 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=PxHWbTLBt75QkXuOPRYOftWdgiPc2j16eqFUY1iv3hMTcnJZ/bt/arIU5fjWOJ0+TV N8L3vfhZYIirPVAuVI035ra7biUZCi6u/nKFOjDkf5hPgjNXEtRWfm68neHR2j/LNAvY isA0O8is/dPUxustcFrLVd/uLKTRHb5+gjBzDbCTOBKML//u5di1OLniT+SOu+3drntT KniZzGbqnMOBUwxkeT2VkzymnN5oUowoN8ER/+14FCSpKW7fvEn4/Kngwi1T3YN9mamn BSoWkyrpKIU7dBDX0f8BuYH0jLun4v8kHvQ39vQVqFsKi6xWyTB4K/A1qHG3ZpsEBH8C TtSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qkhUeX01; 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 bq16-20020a05620a469000b006fa696a06efsi713303qkb.633.2022.11.11.00.26.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:26:14 -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=qkhUeX01; 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 1otP5o-00019K-8j; Fri, 11 Nov 2022 03:08:52 -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 1otP5X-00010b-KQ for qemu-devel@nongnu.org; Fri, 11 Nov 2022 03:08:38 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otP5V-0002EB-Sv for qemu-devel@nongnu.org; Fri, 11 Nov 2022 03:08:35 -0500 Received: by mail-pl1-x62d.google.com with SMTP id b21so3658913plc.9 for ; Fri, 11 Nov 2022 00:08:33 -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=qkhUeX01mXmwLEpnlMn4JGC+33leHf2BgJAFuiM5Szg4YM5J7/Sm8aXK5O3aSrl4Ox tZK453w4opLKeeAsAMGW77RLJ/U3hPcE5VXw0r1wbuFbqqinGPkjoZRiWqe07ilDvXlf HLxeTN07hdz1IBsqjrrZvojSmwid2fdlZWpfwIxp9Fcvf88qqV5+Nvey7K31oi/cIEwB RYdls/oNIPm/k0tzv7KUavdx8gbBTGMVyL7BVtdO5G50mbQ48IYp/wvOKmpVyDFHwhgl GiKbyRvNFVGa4zs5Lsps8mKMFASpOlpxxkozWe9P5OpQMb6CWyMhUZoylJlTUcgO1YaX cMDA== 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=AYDNyPAdyIYv3IYuYyScvbh5oUXTnQsNY35FMZE7yvMZqS5L1QwntxAy/CKO8Wer/7 Gda4hMIaQvZOtPUXnBJpUlPatdQ9RloX+DAJEZZOmyYcqniIQGp/88nI1DM7jsLxh7Oe J+orlsWHYBvxMhiKu3/hkFlvTDKaUMl1JRrf1QPkqjqcor3SPUwWdv2JHhM5L4oL2tIP 4FS4h0Dq/14IolLqnMMzA1kEPYzwaIWbmZ+OEZgtddVGx4kiqYvlX2cScQnQ8Zzy8rrD dHWAA1oYUk+lGJtGtnDTlfI5dw8ixkycXvutact1CMDiILi8ZZZStoSQ7t6evFHyBvpn 3puQ== X-Gm-Message-State: ANoB5pmNRjyFI7CzpVV9F/UGtY0XHA8pIoj6UCB63micame6W1XT11gu gA/IFz4RQI4LbztcwNZupUz+/Rq3NF3bQMMp X-Received: by 2002:a17:90a:2c4a:b0:206:f02a:cb4b with SMTP id p10-20020a17090a2c4a00b00206f02acb4bmr705255pjm.159.1668154112628; Fri, 11 Nov 2022 00:08:32 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id j4-20020a170902c3c400b00186a2dd3ffdsm1046341plj.15.2022.11.11.00.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 00:08:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, david@redhat.com Subject: [PATCH for-8.0 v2 02/13] tests/tcg/s390x: Add clst.c Date: Fri, 11 Nov 2022 18:08:09 +1000 Message-Id: <20221111080820.2132412-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111080820.2132412-1-richard.henderson@linaro.org> References: <20221111080820.2132412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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