From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 1D5A53857C6F for ; Sat, 22 May 2021 01:55:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1D5A53857C6F Received: by mail-ot1-x330.google.com with SMTP id u25-20020a0568302319b02902ac3d54c25eso19777873ote.1 for ; Fri, 21 May 2021 18:55:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LMQhsSDJ3l/4Y1QHpe7kNRb69sINkiBajbNT1HELP2o=; b=KWtisho18zJdrtUkvbWTYOubVgqkydEtTH41P6WLg4PC26pOc53E3uxvRjaN5Oy9ob 2CfAQ+6VVZgiOLtDtSfay349hjK29frpiwjnPERkdsLSTLmiVGFJKnIfyUz+P/Dcb4iS kkznbGx7Kth0ampjiyzWlcsF9QsPX9RHswdHqQLmCVUYRXTuKKC2w6ckQOPwvKAMTtX/ UKYudq2QkGOKKg6VqdzyNhR3as59sJrfmcanfVAKXc9rdRVQdubtF8sZCt7pvFuCeIGM Uq8bsCFIsrjSyNwIeR1kyhSu8VEkJA8c0fhvNNPO/91Pk8vMXn3x68CZ8SrKH4qThDmL s89Q== X-Gm-Message-State: AOAM530zzDDz0GMY0C4tRC2sO2iZUQay/qU20pMVa90OcbM0ijsBIoOA NRVouf6CpKbO6DYcBPaI7FGkrwgdSQs8PKjXSck= X-Google-Smtp-Source: ABdhPJyRm/zE4nZ3XOk8GCgDjHBLzOzPVQRdHf27h6MlxgOJ9j+XAlqCGLUu8ZwlAgR4CRY1dBXwoF9WOtbTmeJl6KM= X-Received: by 2002:a9d:67cf:: with SMTP id c15mr10552191otn.285.1621648519542; Fri, 21 May 2021 18:55:19 -0700 (PDT) MIME-Version: 1.0 References: <20210515123442.1432385-1-hjl.tools@gmail.com> <20210515123442.1432385-6-hjl.tools@gmail.com> <87tumxmoj3.fsf@oldenburg.str.redhat.com> In-Reply-To: <87tumxmoj3.fsf@oldenburg.str.redhat.com> From: "H.J. Lu" Date: Fri, 21 May 2021 18:54:43 -0700 Message-ID: Subject: Re: [PATCH v5 5/5] Add tests for __clone_internal To: Florian Weimer Cc: GNU C Library , Adhemerval Zanella Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3034.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 01:55:21 -0000 On Thu, May 20, 2021 at 8:08 AM Florian Weimer wrote: > > * H. J. Lu: > > > diff --git a/sysdeps/unix/sysv/linux/tst-align-clone-internal.c b/sysdeps/unix/sysv/linux/tst-align-clone-internal.c > > new file mode 100644 > > index 0000000000..eccc39e255 > > --- /dev/null > > +++ b/sysdeps/unix/sysv/linux/tst-align-clone-internal.c > > > + int e; > > + if (waitpid (p, &e, __WCLONE) != p) > > + { > > + puts ("waitpid failed"); > > + kill (p, SIGKILL); > > + return 1; > > + } > > This could use xwaitpid. The same comment applies to other tests. Fixed. > > diff --git a/sysdeps/unix/sysv/linux/tst-clone-internal.c b/sysdeps/unix/sysv/linux/tst-clone-internal.c > > new file mode 100644 > > index 0000000000..587d519bf2 > > --- /dev/null > > +++ b/sysdeps/unix/sysv/linux/tst-clone-internal.c > > > +static int > > +do_test (void) > > +{ > > + int result; > > + > > + result = __clone_internal (NULL, child_fn, NULL); > > + > > + if (errno != EINVAL || result != -1) > > + { > > + printf ("FAIL: clone()=%d (wanted -1) errno=%d (wanted %d)\n", > > + result, errno, EINVAL); > > + return 1; > > + } > > + > > + puts ("All OK"); > > + return 0; > > +} > > I think this test is invalid for the internal function (the comment > about not checking arguments). Removed. > > diff --git a/sysdeps/unix/sysv/linux/tst-clone2-internal.c b/sysdeps/unix/sysv/linux/tst-clone2-internal.c > > new file mode 100644 > > index 0000000000..dd8f32c24b > > --- /dev/null > > +++ b/sysdeps/unix/sysv/linux/tst-clone2-internal.c > > @@ -0,0 +1,142 @@ > > > + > > +static int > > +f (void *a) > > +{ > > + close (pipefd[0]); > > + > > + pid_t ppid = getppid (); > > + pid_t pid = getpid (); > > + pid_t tid = syscall (__NR_gettid); > > + > > + if (write (pipefd[1], &ppid, sizeof ppid) != sizeof (ppid)) > > + FAIL_EXIT1 ("write ppid failed\n"); > > + if (write (pipefd[1], &pid, sizeof pid) != sizeof (pid)) > > + FAIL_EXIT1 ("write pid failed\n"); > > + if (write (pipefd[1], &tid, sizeof tid) != sizeof (tid)) > > + FAIL_EXIT1 ("write tid failed\n"); > > + > > + return 0; > > +} > > You could use support_shared_allocate for the parent/child communication > instead of a pipe. The MAP_SHARED mapping overrides the lack of > CLONE_VM. > > > +static int > > +do_test (void) > > +{ > > + sig = SIGRTMIN; > > + sigset_t ss; > > + sigemptyset (&ss); > > + sigaddset (&ss, sig); > > + if (sigprocmask (SIG_BLOCK, &ss, NULL) != 0) > > + FAIL_EXIT1 ("sigprocmask failed: %m"); > > You could use xpthread_sigmask. (Applies to tst-getpid1-internal.c as > well.) Since this test is copied from the previous test and doesn't use thread, I'd like to keep it this way. > > > + pid_t own_pid = getpid (); > > + pid_t own_tid = syscall (__NR_gettid); > > We have gettid nowadays. Fixed. > > +#include > > diff --git a/sysdeps/unix/sysv/linux/tst-clone3-internal.c b/sysdeps/unix/sysv/linux/tst-clone3-internal.c > > new file mode 100644 > > index 0000000000..61863e1504 > > --- /dev/null > > +++ b/sysdeps/unix/sysv/linux/tst-clone3-internal.c > > +#include /* For _STACK_GROWS_{UP,DOWN}. */ > > No longer needed! 8-) Fixed. > > +#include > > +#include > > +#include > > + > > +/* Test if clone call with CLONE_THREAD does not call exit_group. The 'f' > > + function returns '1', which will be used by clone thread to call the > > + 'exit' syscall directly. If _exit is used instead, exit_group will be > > + used and thus the thread group will finish with return value of '1' > > + (where '2' from main thread is expected. */ > > Missing ). Fixed. > The rest looks okay as far as I can tell. > > Thanks, > Florian > Thanks. -- H.J.