From patchwork Thu Aug 24 22:55:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 22351 Received: (qmail 17812 invoked by alias); 24 Aug 2017 22:55:42 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 17796 invoked by uid 89); 24 Aug 2017 22:55:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*M:106, H*MI:106 X-HELO: NAM02-SN1-obe.outbound.protection.outlook.com Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Steve.Ellcey@cavium.com; Message-ID: <1503615332.28672.106.camel@cavium.com> Subject: [PATCH] Fix tests that are testing obsoleted functionality From: Steve Ellcey Reply-To: sellcey@cavium.com To: libc-alpha Cc: Florian Weimer , Joseph Myers , nd , Szabolcs Nagy Date: Thu, 24 Aug 2017 15:55:32 -0700 Mime-Version: 1.0 X-ClientProxiedBy: MWHPR12CA0047.namprd12.prod.outlook.com (10.172.49.33) To DM5PR07MB3545.namprd07.prod.outlook.com (10.164.153.143) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e601e81e-60dc-47ca-548a-08d4eb433baa X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(49563074)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR07MB3545; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3545; 3:CwK/uGMF95RmF/suJj8YbHhcjUc8p94yZWw+ac4YZE4DTYioYYpKdPLQBsQDc4cCrnT16KM7inJJECd9UA0FepkTN2cJ8Tr+5khvJ9ttZjaBqy48mcc6psb/81qwhO4I8+ZC9HWtLBBhK40Je7niuGIxYYWvZ3g0R78BBsMUaSYjF9nNJsAzJqKwnpJD+Fj/9UrOgGUdsPCZxu+K8q4DuarzCChVWLcbJA+VgCvkQyHonw0b1kWJjQGg86jlG/jk; 25:2cefOxdsgigmywhEhiBA38MjBz3/VSh1EsTBJUA361DGBitYIInuvLrZUULhEylN3Jv+uwgJ0EOiYKoHI76bwUvhG+0gLtBPeD0CXnWNQQULOiEg04F7ix4WmQoLjcoJUYzqXaO3FX6XtFBpb8yrEN3BeyThka54i30g1p58Ob7KVE1Ba3EuaZjqjarXeADDiy6Gcyr6SYxRMQwxDBv83IcfKTZH4HplfFEW9jyUTU/Db/4hMoukEdl7t0yfa5B/af4/irfBRW9Wr12CLcd7t6YJCOk5+SR6YznSFR1B8y/pfi2AdV3xZQKrv0JCN/HaKe/gUqsWhrTd0u/x1CcQ0w==; 31:l4FsVaRqx+HgnZjTC04Ds2sHMXmZNZzdf/TZEc1tNe1CSkWmCLcyKhXYbk0srpytPlAWSqf557vUGBxI5JvyYPP5H5+mhcURDlkmHERahi2FN798aPXmZ9fPaM2pjB7iOrgkHC9TvLIN+L+sJF6ZfQCKJYE8TTKNexU3rV9LjmweqaNoNtj1whi4K2x548MH2g7WDmCjPfZBr219W3EW+l8I4mo+G14zuoYUf58HvOI= X-MS-TrafficTypeDiagnostic: DM5PR07MB3545: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3545; 20:KLf5u3/FSwLE6qW4zxoY9r7Q0Ql2506XFrdYE+lkFXDp+KtPtKQvV3XaBP7PYaHgXmuYTzZAk5pTMHPc7NBOL9DlGNgVud5TaEMaZrHfVCsWZARgdT9B/K1EqUAVPO2htua87we/Ma3xq6En5fa8WQFlqNefh0YjedK9iDynfGH77dYt14MLduyf0NwPEqPigkXNqpADIXtHyXsDMae5XUpATwzaeP95X/cvrimX5CuDoILhYp98Bi2QUjCfbHI2tauP0a3weFu+/+743VT/Q9Q51tBmH8Op8u6b+8W3f8QJI4cf1sXEdDrA7OCHKT3bkDLUou8qqEyxVsXfUvLzzBJd8k4+s/lzVZBvUgxgJS6w6c3lWqvTfTR81vtkjoVfBXcnzCuBycRBdWljSgc8HcxEZkmYBjpG09Y8V3l4+d37lsZ9pX1grVtXEP9Rql4zAXw3LQimkuJbls7d8OhWp3EPTxwj1OuSOYTubOIogZOWc7xTh3+esRmmGdeI4MMX; 4:9KxiqNsgiP+owPB6Owzo00EXLyiv8iILMTGtu6kql43QwmA1bqXhkjQdKQvcy7ozPWdnY8/599jIWj7PEBx136lDvnZTeRbsnuN1DQKZdlj49LykeCg6k2kWxHdA2edisEpIU63TWZSQhtZ8uEbi0f0SM8CAn4aVAZLV0Fiw2cdclsS3NRx5s6gWMnywx9G1TIrSXS/hNrVL12SccMgdq7H4wqNa2zwZvTnuaqnC7/H49mjVr3BW/1Tmb7ONmW0X X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(102415395)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(6041248)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR07MB3545; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR07MB3545; X-Forefront-PRVS: 04097B7F7F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(377424004)(189002)(199003)(6306002)(4326008)(8676002)(6506006)(6916009)(189998001)(966005)(50986999)(97736004)(103116003)(69596002)(42186005)(4610100001)(6486002)(72206003)(53416004)(101416001)(5890100001)(568964002)(2476003)(50226002)(2906002)(81156014)(7350300001)(81166006)(43066003)(6116002)(6666003)(5660300001)(36756003)(110136004)(106356001)(3450700001)(66066001)(68736007)(53936002)(33646002)(105586002)(6512007)(25786009)(305945005)(3846002)(478600001)(84326002)(7736002)(512874002)(54906002)(99106002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3545; H:sellcey-dt.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR07MB3545; 23:745d45X6tr+aokN5LsKEYLZhI207DXiwh8ZBf24Th?= =?us-ascii?Q?lK56EFHYb0ndvOouvM97rr1sHITaaSScanhxwWvuzFTrzyL2Ivn71nqoMu9a?= =?us-ascii?Q?rKia3yzHBmwcK8lnIHEYorKYOZcuKF6Q9q869fUYz7we8AcIHhyu2tlt4kXs?= =?us-ascii?Q?M25hVXuMpr1FnsnEbCXIcJwc4b0Wi8lMsLWHgOGYaQLJkOncXpGKWawYqiGy?= =?us-ascii?Q?Qv3/yf5Sxcr5NUYkhQhqoHvY5BmQf2VVinb0qZmQNdcg5ahqfnXyWE4MUJ9x?= =?us-ascii?Q?uIHgp762b6tdszPnXuBbTlQiQI/YtuNH5Uyco/SD8WaDrHVKw+S4BX0AogkZ?= =?us-ascii?Q?XUWVbqiyBCWmMFn5uiHFjxInVpngAEcEJ868WZ2K3qeZAYMdnKzWveISjhca?= =?us-ascii?Q?KsZCxaKp45Dgya+9w+FJDra63VtxtJHtmZjdhp3USWStIX8AapGrSX1fziDN?= =?us-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3545; 6:Xs5m9t6s/qFzlCOmsrqbH+w/WSvSCf2GjYkSqwN5cNtImPKTKexEbM5pRzm/ZHlHzXYAK+1YUa77JJ+H+rPgoWRXLS80k3nOjBIhz3/XFB0MtQ3vJpYg1xfzlX+JGLaETaVa42mlH1XYeftw7v9zYCu0abTUW4aHaSTEv7P68sVezYsi27yx/6hRvS217mGPt3voBCvbO3RcPpRR9F/ISyfIkZLUCpGS9dLJg53aMVKX7OzFDs2Sbq/UKhIKP3/ke6SvhhmMaUV4aeF+g3ROgdQp/9UTNP29+hHY09X8eDPreSR55mYwI3pixU44mrSxbbcNTNRoS4c5BZizxPB/aA==; 5:0TPwsrH3H5+FCuv5RRj7wuGhpYy/ZN3xJ64hGX8pnG4m2BVnN22uTjQ9+f5QCX1m0zX5PC13hWA9ISSYYVlUY20NGEdmGiUaPSOGRzoAaGLuo4hOsDTCrRNhbxUSlHnmUOYMz5QykYmuHPKHePvTXw==; 24:cSkU0XLSllio3dNJ3lkBXRZukFrkMDtjurII1yguHRVHYF1IktN/tmP4z9Ij895Xyi2DcNik8sv1GkM55GTWXIrTb/L3x77sn8T2qXeB2/0=; 7:9E1inN5m7jtMWCz8b6LTw6SwU7lVPoF+xcHw+LXY1UuzMrFo/oG0SwTjpbf8sHijHUgu7vv2edJbzwZ+5QH9m4mm7eBvk1NwMBzkol0mo5SG6PHZZXF3JfJ9f2JOsBcnSFDeOk/YQ46aH20KtkttHY/YVvsZgUnKzedPbjopQwX0vewnCz2VolGnmGLvkcQ4VR14Wfy33brLzHMmZfVeADGZrYF0QcyYtSTwQgQp7c4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2017 22:55:35.7593 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3545 Here is a patch to fix three tests; malloc/tst-mallocstate.c, math/test-matherr.c, and math/test-matherr-2.c.  These tests test functionality that is no longer in the latest GLIBC but should still exist for programs linked with an older GLIBC. If you have a new ABI (like ILP32 aarch64) which never existed in the older form, these tests will fail. tst-mallocstate.c and test-matherr.c give link errors and test-matherr-2.c compiles and links but exits with status 1. See https://sourceware.org/ml/libc-alpha/2017-08/msg01127.html and https://sourceware.org/ml/libc-alpha/2016-12/msg00527.html for some more discussions on this problem. This patch fixes the tests so that they will compile and link and, if on a platform that does not support the functionality being tested return an UNSUPPORTED return code.  They continue to run and pass as before on other platforms.  To do this I created a new macro TEST_COMPAT, similar to SHLIB_COMPAT that can be used to check for the abi versions available when building the test. Tested on aarch64 with LP64 (where they run) and ILP32 (where they return unsupported).  While I tested this with the aarch64 ILP32 ABI, they changes are not specific to any ABI so I would like to check them in now and not wait for aarch64 ILP32 or some other new ABI get checked in first. Steve Ellcey sellcey@cavium.com 2017-08-24  Steve Ellcey   * include/shlib-compat.h (TEST_COMPAT): New Macro. * malloc/tst-mallocstate.c: Convert from test-skeleton to test-driver.  Ifdef code using TEST_COMPAT macro. * math/test-matherr-2.c: Ifdef test using TEST_COMPAT macro. * math/test-matherr.c: Likewise. diff --git a/include/shlib-compat.h b/include/shlib-compat.h index 41eb362..d872afc 100644 --- a/include/shlib-compat.h +++ b/include/shlib-compat.h @@ -97,4 +97,14 @@ compat_symbol (libc, name, aliasname, version); # endif +/* The TEST_COMPAT macro acts just like the SHLIB_COMPAT macro except + that it does not check IS_IN. It is used by tests that are testing + functionality that is only available in specific GLIBC versions. */ + +# define TEST_COMPAT(lib, introduced, obsoleted) \ + _TEST_COMPAT (lib, introduced, obsoleted) +# define _TEST_COMPAT(lib, introduced, obsoleted) \ + (!(ABI_##lib##_##obsoleted - 0) \ + || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))) + #endif /* shlib-compat.h */ diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c index 5cb39c0..53154ae 100644 --- a/malloc/tst-mallocstate.c +++ b/malloc/tst-mallocstate.c @@ -23,19 +23,20 @@ #include #include #include +#include +#include +#include #include "malloc.h" +#if TEST_COMPAT (libc, GLIBC_2_0, GLIBC_2_25) + /* Make the compatibility symbols availabile to this test case. */ void *malloc_get_state (void); compat_symbol_reference (libc, malloc_get_state, malloc_get_state, GLIBC_2_0); int malloc_set_state (void *); compat_symbol_reference (libc, malloc_set_state, malloc_set_state, GLIBC_2_0); -static int do_test (void); -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" - /* Maximum object size in the fake heap. */ enum { max_size = 64 }; @@ -63,9 +64,9 @@ static size_t *next_heap_chunk; /* Copied from malloc.c and hooks.c. The version is deliberately lower than the final version of malloc_set_state. */ -#define NBINS 128 -#define MALLOC_STATE_MAGIC 0x444c4541l -#define MALLOC_STATE_VERSION (0 * 0x100l + 4l) +# define NBINS 128 +# define MALLOC_STATE_MAGIC 0x444c4541l +# define MALLOC_STATE_VERSION (0 * 0x100l + 4l) static struct { long magic; @@ -117,12 +118,7 @@ dumped_heap_alloc (size_t length) /* Round up the allocation size to the heap alignment. */ chunk_size += heap_alignment_mask; chunk_size &= ~heap_alignment_mask; - if ((chunk_size & 3) != 0) - { - /* The lower three bits in the chunk size have to be 0. */ - write_message ("error: dumped_heap_alloc computed invalid chunk size\n"); - _exit (1); - } + TEST_VERIFY_EXIT ((chunk_size & 3) == 0); if (next_heap_chunk == NULL) /* Initialize the top of the heap. Add one word of zero padding, to match existing practice. */ @@ -244,11 +240,7 @@ shuffle_allocation_tasks (void) /* Pick pair in the tail of the array. */ int j = i + (rand_next (&global_seed) % ((unsigned) (allocation_task_count - i))); - if (j < 0 || j >= allocation_task_count) - { - write_message ("error: test bug in shuffle\n"); - _exit (1); - } + TEST_VERIFY_EXIT (j >= 0 && j < allocation_task_count); /* Exchange. */ struct allocation_task tmp = allocation_tasks[i]; allocation_tasks[i] = allocation_tasks[j]; @@ -298,7 +290,8 @@ static volatile bool heap_initialized; static void init_heap (void) { - write_message ("info: performing heap initialization\n"); + if (test_verbose) + printf ("info: performing heap initialization\n"); heap_initialized = true; /* Populate the dumped heap. */ @@ -312,11 +305,7 @@ init_heap (void) save_state.av[2] = (void *) (next_heap_chunk - 1); /* Integrate the dumped heap into the process heap. */ - if (malloc_set_state (&save_state) != 0) - { - write_message ("error: malloc_set_state failed\n"); - _exit (1); - } + TEST_VERIFY_EXIT (malloc_set_state (&save_state) == 0); } /* Interpose the initialization callback. */ @@ -389,15 +378,12 @@ static int do_test (void) { my_free (malloc (1)); - if (!heap_initialized) - { - printf ("error: heap was not initialized by malloc\n"); - return 1; - } + TEST_VERIFY_EXIT (heap_initialized); /* The first pass performs the randomly generated allocation tasks. */ - write_message ("info: first pass through allocation tasks\n"); + if (test_verbose) + printf ("info: first pass through allocation tasks\n"); full_heap_check (); /* Execute the post-undump tasks in a random order. */ @@ -451,14 +437,15 @@ do_test (void) break; case action_count: - abort (); + FAIL_EXIT1 ("task->action should never be action_count"); } full_heap_check (); } /* The second pass frees the objects which were allocated during the first pass. */ - write_message ("info: second pass through allocation tasks\n"); + if (test_verbose) + printf ("info: second pass through allocation tasks\n"); shuffle_allocation_tasks (); for (int i = 0; i < allocation_task_count; ++i) @@ -480,7 +467,7 @@ do_test (void) break; case action_count: - abort (); + FAIL_EXIT1 ("task->action should never be action_count"); } full_heap_check (); } @@ -503,3 +490,12 @@ do_test (void) return errors; } +#else +static int +do_test (void) +{ + return 77; +} +#endif + +#include diff --git a/math/test-matherr-2.c b/math/test-matherr-2.c index c2fc5e6..7b5f49c 100644 --- a/math/test-matherr-2.c +++ b/math/test-matherr-2.c @@ -22,8 +22,11 @@ #include #include -#undef matherr -#undef _LIB_VERSION + +#if TEST_COMPAT (libm, GLIBC_2_0, GLIBC_2_27) + +# undef matherr +# undef _LIB_VERSION compat_symbol_reference (libm, matherr, matherr, GLIBC_2_0); compat_symbol_reference (libm, _LIB_VERSION, _LIB_VERSION, GLIBC_2_0); @@ -45,5 +48,12 @@ do_test (void) acos (2.0); return fail; } +#else +static int +do_test (void) +{ + return 77; +} +#endif #include diff --git a/math/test-matherr.c b/math/test-matherr.c index 34856f1..23521c0 100644 --- a/math/test-matherr.c +++ b/math/test-matherr.c @@ -22,8 +22,11 @@ #include #include -#undef matherr -#undef _LIB_VERSION + +#if TEST_COMPAT (libm, GLIBC_2_0, GLIBC_2_27) + +# undef matherr +# undef _LIB_VERSION compat_symbol_reference (libm, matherr, matherr, GLIBC_2_0); compat_symbol_reference (libm, _LIB_VERSION, _LIB_VERSION, GLIBC_2_0); @@ -44,5 +47,12 @@ do_test (void) acos (2.0); return fail; } +#else +static int +do_test (void) +{ + return 77; +} +#endif #include