Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iGpP1-0007Kx-OA for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Oct 2019 19:07:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iGpOz-0004Y4-S3 for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Oct 2019 19:07:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iGpOy-0004XY-Kx for pgsql-hackers@lists.postgresql.org; Sat, 05 Oct 2019 19:07:37 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iGpOu-0000jk-SF for pgsql-hackers@lists.postgresql.org; Sat, 05 Oct 2019 19:07:35 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 6F8EB21540; Sat, 5 Oct 2019 15:07:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 05 Oct 2019 15:07:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=hwZQVGAcNTJYl0Qf2CCMGg04E6v FoYf0ZoPblwfE/40=; b=B8ionaWARcqMvy9imaGvu4mprYh0xwfyioopVTSi3KB GRfG/nVBYgWPBpxT/fUZVTZD3t55yCampN1/vImp4k+A0TL6Ivh2A2ls/q6u5k9c wuxJkgA5jIiidNZ3Sj5Lm2a1kqh8ETeUHX6nAu7OpWvvIbWqHb4w7ChLuOY6wtl4 sEABerWuuUZu/TsBWx4QnRmDkq51erhuNTwgIFItale7ItCJV9Qwo1mvLGjw5uP4 0QksGvt/K0rGLwd7x47D1Va7/Gu/8EK7ZFSy7dgXJ7Pf8JrLItdOhtWpWxHvhMGo QU9UauKYlxvEeMUSKHxbsA0PX4wpBRuPzy/dEbbVnRQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=hwZQVG AcNTJYl0Qf2CCMGg04E6vFoYf0ZoPblwfE/40=; b=mMTXjjMR/cnFFIl+9/bbtz q1Dizg4Huhs/7B0V8lavrZq2WDz/2vUahPZQdR+Ce+CvkjVqjBMIBUJiLNO1bLi3 TQ/Ut/MM9q2Bl6vMt2pP6tSZMcK9H2dl/gwwIl8qttRezraD9+phhUlGEWKp29eR 299wWuHa1Q9RhqZ3fJcZLkmE79PQHCU+grd/tCe6wMS1ZWSM7MXWaMRUSPaY4XmG 3+Syz4WPI5i/LBe/bepc7fXu3lUOEXFg3zLpMMoa/cyGJ+p+Ie0OxslC++S/pwSE PT5VlRJ7fI4wcoJ5h1ysWQSYlCr9RYJBLrZfTCMhCsRXHkrkNPp4TtND5xnbd+Hg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrheefgddufeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucffohhmrg hinhepphhoshhtghhrvghsqhhlrdhorhhgnecukfhppeeijedrudeitddrvddukedrvdef jeenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdrug gvnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-218-237.hsd1.ca.comcast.net [67.160.218.237]) by mail.messagingengine.com (Postfix) with ESMTPA id BEC1ED60057; Sat, 5 Oct 2019 15:07:30 -0400 (EDT) Date: Sat, 5 Oct 2019 12:07:29 -0700 From: Andres Freund To: Noah Misch Cc: pgsql-hackers@lists.postgresql.org Subject: expressive test macros (was: Report test_atomic_ops() failures consistently, via macros) Message-ID: <20191005190729.6sx7g23ifdu65s7s@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-10-05 17:08:38 +0000, Noah Misch wrote: > Report test_atomic_ops() failures consistently, via macros. > > This prints the unexpected value in more failure cases, and it removes > forty-eight hand-maintained error messages. Back-patch to 9.5, which > introduced these tests. Thanks for these, that's a nice improvement. https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=639feb92e1186e1de495d1bfdb191869cb56450a ... +#define EXPECT_EQ_U32(result_expr, expected_expr) \ + do { \ + uint32 result = (result_expr); \ + uint32 expected = (expected_expr); \ + if (result != expected) \ + elog(ERROR, \ + "%s yielded %u, expected %s in file \"%s\" line %u", \ + #result_expr, result, #expected_expr, __FILE__, __LINE__); \ + } while (0) ... I wonder if we should put these (and a few more, for other types), into a more general place. I would like to have them for writing both tests like regress.c:test_atomic_ops(), and for writing assertions that actually display useful error messages. For the former it makes sense to ERROR out, for the latter they ought to abort, as currently. Seems like putting ASSERT_{EQ,LT,...}_{U32,S32,...} (or Assert_Eq_..., but that'd imo look weirder than the inconsistency) into c.h would make sense, and EXPECT_ somewhere in common/pg_test.h or such? Greetings, Andres Freund