From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 9385D3851C36 for ; Thu, 20 May 2021 15:08:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9385D3851C36 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-IIEnKqH1MXWoByXOaeMbeA-1; Thu, 20 May 2021 11:08:04 -0400 X-MC-Unique: IIEnKqH1MXWoByXOaeMbeA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B6B41922963; Thu, 20 May 2021 15:08:03 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-137.ams2.redhat.com [10.36.112.137]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6036560CCC; Thu, 20 May 2021 15:08:02 +0000 (UTC) From: Florian Weimer To: "H.J. Lu" Cc: libc-alpha@sourceware.org, Adhemerval Zanella Subject: Re: [PATCH v5 5/5] Add tests for __clone_internal References: <20210515123442.1432385-1-hjl.tools@gmail.com> <20210515123442.1432385-6-hjl.tools@gmail.com> Date: Thu, 20 May 2021 17:08:00 +0200 In-Reply-To: <20210515123442.1432385-6-hjl.tools@gmail.com> (H. J. Lu's message of "Sat, 15 May 2021 05:34:42 -0700") Message-ID: <87tumxmoj3.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: Thu, 20 May 2021 15:08:10 -0000 * 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. > 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). > 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.) > + pid_t own_pid = getpid (); > + pid_t own_tid = syscall (__NR_gettid); We have gettid nowadays. > +#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-) > +#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 ). The rest looks okay as far as I can tell. Thanks, Florian