From nobody Tue Feb 10 20:48:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529093518299815.1386444538522; Fri, 15 Jun 2018 13:11:58 -0700 (PDT) Received: from localhost ([::1]:49102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTv4f-0005Pa-9Q for importer@patchew.org; Fri, 15 Jun 2018 16:11:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTugo-0002ZQ-GH for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:47:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTugn-0005Qm-5C for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:47:18 -0400 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:37619) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTugm-0005OT-RS for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:47:17 -0400 Received: by mail-wr0-x22c.google.com with SMTP id d8-v6so10979112wro.4 for ; Fri, 15 Jun 2018 12:47:16 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t9-v6sm1730799wmh.41.2018.06.15.12.47.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jun 2018 12:47:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 587B53E0A3C; Fri, 15 Jun 2018 20:47:06 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pFqZ3Ki5slbt+qpd8Wjw7NOrFbx4l4FwHd3TDT0Axy0=; b=FMI60ZKRew2hIc400qug3LVN+rAwn0P7d4XOMg3Q1Vw3gbJ5lpH649ARCPWf79hCJ6 ROoeF5c9ZuSlfK31d8TU1XMW5k6QdUBeqdINeVVYk+hWvgN5R2QEsV4FAu4X9QUK5sLe Jj+PFkWG7FJ75Zf2eYcNyXVHSq/lWdQnY9BCk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pFqZ3Ki5slbt+qpd8Wjw7NOrFbx4l4FwHd3TDT0Axy0=; b=t4CZ6/hM0xNxshOfwF/z/1TUM8RJTtIVyFqDn6wZ6jGGrE1W+3sMEipE866giOLjeW 8suFASSilDWQILjtjJRRpI/j+lTPPpuTZpLMcBDYApqpu6sCMKPrjLIJGWxLsRfiXdRl MkFslnpSg20PYYKf61x3mgytAwd7ylDRePrsVGVqXqlUD/YKtj9TJDEKfkFa/jUe4mEh n6mKulX/Yw2WNjlEXc+fxtNjNBM+IxSJGLTv4UKVUaWP8WQEHcxSUR1nR1o/+3ZAQbOz yuM5JL6dkJ1nd1RS6WdK1pftWVujJBprWgzNC2bfXB8EXYw106BlGlmNgtay641j+6qS 1utA== X-Gm-Message-State: APt69E0DvRLMqXlGlkFZ3tlxdujBn9eIuZUjyPwQ1AUOA1LqQbWsB5XP EmgCvgAGIq5BjLQ+wVmbmcTfCHGOVWY= X-Google-Smtp-Source: ADUXVKJ5tGC144rKq9sh4mvPXKwVToaDM0hnHssj+JoC+cHGzr3UcHlstDQcCHGCTBVL4zCqEFB+yg== X-Received: by 2002:adf:b710:: with SMTP id l16-v6mr2831454wre.115.1529092035637; Fri, 15 Jun 2018 12:47:15 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: cota@braap.org, famz@redhat.com, berrange@redhat.com, f4bug@amsat.org, richard.henderson@linaro.org, balrogg@gmail.com, aurelien@aurel32.net, agraf@suse.de, peter.maydell@linaro.org Date: Fri, 15 Jun 2018 20:46:22 +0100 Message-Id: <20180615194705.28019-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615194705.28019-1-alex.bennee@linaro.org> References: <20180615194705.28019-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22c Subject: [Qemu-devel] [PATCH v7 11/54] tests/tcg/multiarch: enable additional linux-test tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Un-comment the remaining tests. I removed the itimer value tests because I'm fairly sure a re-arming timer will always have a different value in it when you grab it. I've also fixed up the clone thread flags as QEMU will only allow a clone to use flags which match glibc. However the test is still racey so it remains disabled by default - it can be run by passing any additional parameters on the command line. Signed-off-by: Alex Benn=C3=A9e Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v3 - make clone flags match CLONE_THREAD_FLAGS v4 - disable test_clone for default case --- tests/tcg/multiarch/linux-test.c | 51 +++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-t= est.c index 4457bd04ba..6f2c531474 100644 --- a/tests/tcg/multiarch/linux-test.c +++ b/tests/tcg/multiarch/linux-test.c @@ -16,6 +16,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ +#define _GNU_SOURCE #include #include #include @@ -58,8 +59,8 @@ static void error1(const char *filename, int line, const = char *fmt, ...) static int __chk_error(const char *filename, int line, int ret) { if (ret < 0) { - error1(filename, line, "%m (ret=3D%d, errno=3D%d)", - ret, errno); + error1(filename, line, "%m (ret=3D%d, errno=3D%d/%s)", + ret, errno, strerror(errno)); } return ret; } @@ -216,6 +217,7 @@ static void test_fork(void) pid =3D chk_error(fork()); if (pid =3D=3D 0) { /* child */ + sleep(2); exit(2); } chk_error(waitpid(pid, &status, 0)); @@ -320,7 +322,6 @@ static void test_socket(void) chk_error(close(server_fd)); } =20 -#if 0 #define WCOUNT_MAX 512 =20 static void test_pipe(void) @@ -355,7 +356,7 @@ static void test_pipe(void) } if (FD_ISSET(fds[1], &wfds)) { ch =3D 'a'; - chk_error(write(fds[0], &ch, 1)); + chk_error(write(fds[1], &ch, 1)); wcount++; } } @@ -387,28 +388,41 @@ static int thread2_func(void *arg) return 0; } =20 -void test_clone(void) +static void wait_for_child(pid_t pid) +{ + int status; + chk_error(waitpid(pid, &status, 0)); +} + +/* For test_clone we must match the clone flags used by glibc, see + * CLONE_THREAD_FLAGS in the QEMU source code. + */ +static void test_clone(void) { uint8_t *stack1, *stack2; - int pid1, pid2, status1, status2; + pid_t pid1, pid2; =20 stack1 =3D malloc(STACK_SIZE); pid1 =3D chk_error(clone(thread1_func, stack1 + STACK_SIZE, - CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "h= ello1")); + CLONE_VM | CLONE_FS | CLONE_FILES | + CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM, + "hello1")); =20 stack2 =3D malloc(STACK_SIZE); pid2 =3D chk_error(clone(thread2_func, stack2 + STACK_SIZE, - CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "h= ello2")); + CLONE_VM | CLONE_FS | CLONE_FILES | + CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM, + "hello2")); =20 - while (waitpid(pid1, &status1, 0) !=3D pid1); + wait_for_child(pid1); free(stack1); - while (waitpid(pid2, &status2, 0) !=3D pid2); + wait_for_child(pid2); free(stack2); + if (thread1_res !=3D 5 || thread2_res !=3D 6) error("clone"); } -#endif =20 /***********************************/ =20 @@ -449,12 +463,10 @@ static void test_signal(void) it.it_value.tv_usec =3D 10 * 1000; chk_error(setitimer(ITIMER_REAL, &it, NULL)); chk_error(getitimer(ITIMER_REAL, &oit)); - if (oit.it_value.tv_sec !=3D it.it_value.tv_sec || - oit.it_value.tv_usec !=3D it.it_value.tv_usec) - error("itimer"); =20 while (alarm_count < 5) { usleep(10 * 1000); + getitimer(ITIMER_REAL, &oit); } =20 it.it_interval.tv_sec =3D 0; @@ -463,9 +475,6 @@ static void test_signal(void) it.it_value.tv_usec =3D 0; memset(&oit, 0xff, sizeof(oit)); chk_error(setitimer(ITIMER_REAL, &it, &oit)); - if (oit.it_value.tv_sec !=3D 0 || - oit.it_value.tv_usec !=3D 10 * 1000) - error("setitimer"); =20 /* SIGSEGV test */ act.sa_sigaction =3D sig_segv; @@ -503,10 +512,16 @@ static void test_shm(void) int main(int argc, char **argv) { test_file(); + test_pipe(); test_fork(); test_time(); test_socket(); - // test_clone(); + + if (argc > 1) { + printf("test_clone still considered buggy\n"); + test_clone(); + } + test_signal(); test_shm(); return 0; --=20 2.17.1