From patchwork Tue Aug 29 18:11:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Pluzhnikov X-Patchwork-Id: 807215 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-83840-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="tEUEM5KS"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xhcDt5qs8z9sD9 for ; Wed, 30 Aug 2017 04:12:46 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=DfSrEUPGAPBVOSLGFSEL5qe5eAqnl yx9l0dIj+2SiiY4DjsTwf0S7Q/UCp/P1w2yCPwmKsKSW40fqoyMYFFCc8yHQaqiW BiTqtYSwnuSYx+zz7uSm/SjCIWvzMzLAhnO3WaBw8y7ym5dZt7BqUkrLvA1HwL2N rLVDWcmYCCis3o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=EaFqDXL7S700dFYXH3DpkJfRGMU=; b=tEU EM5KS0pYbqJh73WPlLkpPuffaTuU/Oq1sgA+r4R/YYjrQgSrbKhOzC/xRnem35Nu ltHxN38nSAhlKeWoqYySgHtAJBkkq+QxtA3DEMQuaEXBE3P4de7VrGvrjVqlJTMV sYisjSj/gNtBVwZEGnDGytL2+nyK14V85EvUq8mA= Received: (qmail 44774 invoked by alias); 29 Aug 2017 18:12:38 -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 44073 invoked by uid 89); 29 Aug 2017 18:12:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-vk0-f43.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Jjfl8jVdiLhSuMYbaPqi5pHNOlptOWDoYtgVdXn1en4=; b=ueJ5zf7O5N7dQN/WvI/l1Ga7t4Zec6DYKp56OWMAm+EAPSfaZk4fKQ0b9CvcNyqtf2 AIOYCuUrrdavFUu1yMGV0ZWGEv+Ff6OHxFucMR8QBEjrM86mKeCXp1QhexsQhXIv2pz3 4U/gNFi7NpHQZhUuqBniFl2BURP6P4k2X1qm79Zhn1+T/EIj3JhtfmDCwHczQurnJdA2 jLKPyNV1MLZph5+ZoHpkcP8XC6mtL8yn7oxqxnQv72OPQTo2833cR7wmYOCdfBzgqkM+ MgIiap37J4H7jxKeCRtO/nEzKWCk353ZmFEIEL2++QFJLD//kk9zK6a8dJtvM0pIlJoC njsg== X-Gm-Message-State: AHYfb5gyce77jYnCKKtzHWwSefrGcB8GVJU4yuU32wi5JK0jEv7KilfC V2NVz8PkgSUrHcX9aqRxYnAvbxGssYFrRb5xGA== X-Google-Smtp-Source: ADKCNb5KLPYRXADJJcj6SeZpEc4/A3gJPr7BmF1bkWWTRu5NrTg52lseLLLxmAZZzmr2xJfCR1olvKEqyjlnD9gBwF4= X-Received: by 10.31.49.200 with SMTP id x191mr649813vkx.127.1504030345315; Tue, 29 Aug 2017 11:12:25 -0700 (PDT) MIME-Version: 1.0 From: Paul Pluzhnikov Date: Tue, 29 Aug 2017 11:11:54 -0700 Message-ID: Subject: [PATCH] Extend tst-{atexit, at_quick_exit, cxa_atexit, onexit} to verify minimum number of supported handlers To: GLIBC Devel Greetings, This patch implements the other TODO in stdlib/tst-atexit-common.c 2017-08-29 Paul Pluzhnikov * stdlib/tst-atexit-common.c (do_test): Test support for at least 32 atexit handlers. diff --git a/stdlib/tst-atexit-common.c b/stdlib/tst-atexit-common.c index 99b00bf3aa..d6dcf08cdd 100644 --- a/stdlib/tst-atexit-common.c +++ b/stdlib/tst-atexit-common.c @@ -23,7 +23,13 @@ #include #include -#define MAX_ATEXIT 20 /* Large enough for current set of invocations. */ +/* http://pubs.opengroup.org/onlinepubs/000095399/functions/atexit.html + requires that we support at least 32 atexit handlers. + + The number we actually support is limited by memory. Here we simply + check that we support at least the minimum required. */ +#define MAX_ATEXIT 32 + static char crumbs[MAX_ATEXIT]; static int next_slot = 0; @@ -66,7 +72,7 @@ static void fn_final (void) { /* Arbitrary sequence matching current registrations. */ - const char expected[] = "3021121130211"; + const char expected[] = "00000000000000000000000003021121130211"; if (strcmp (crumbs, expected) == 0) _exit_with_flush (0); @@ -76,25 +82,26 @@ fn_final (void) _exit_with_flush (1); } -/* This is currently just a basic test to verify that exit handlers execute - in LIFO order, even when the handlers register additional new handlers. - - TODO: Additional tests that we should do: - 1. POSIX says we need to support at least ATEXIT_MAX - 2. ... */ - static int do_test (void) { + int slots_remaining = MAX_ATEXIT; + /* Register this first so it can verify expected order of the rest. */ - ATEXIT (fn_final); + ATEXIT (fn_final); --slots_remaining; - ATEXIT (fn1); - ATEXIT (fn3); - ATEXIT (fn1); - ATEXIT (fn2); - ATEXIT (fn1); - ATEXIT (fn3); + ATEXIT (fn1); --slots_remaining; + ATEXIT (fn3); --slots_remaining; + ATEXIT (fn1); --slots_remaining; + ATEXIT (fn2); --slots_remaining; + ATEXIT (fn1); --slots_remaining; + ATEXIT (fn3); --slots_remaining; + + /* Fill the rest of available slots with fn0. */ + while (slots_remaining > 0) + { + ATEXIT (fn0); --slots_remaining; + } /* Verify that handlers registered above are inherited across fork. */ const pid_t child = fork ();