From patchwork Fri Jun 8 12:32:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 926767 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=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="M1W6/0jf"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 412NHC5T7Pz9s1R for ; Fri, 8 Jun 2018 23:17:11 +1000 (AEST) Received: from localhost ([::1]:35599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRHGP-0003hs-8N for incoming@patchwork.ozlabs.org; Fri, 08 Jun 2018 09:17:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRGZz-0001Bn-Ol for qemu-devel@nongnu.org; Fri, 08 Jun 2018 08:33:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRGZy-0006Ej-EC for qemu-devel@nongnu.org; Fri, 08 Jun 2018 08:33:19 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:44903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRGZy-0006E1-4s for qemu-devel@nongnu.org; Fri, 08 Jun 2018 08:33:18 -0400 Received: by mail-wr0-x22b.google.com with SMTP id x4-v6so5088311wro.11 for ; Fri, 08 Jun 2018 05:33:18 -0700 (PDT) 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=M1W6/0jff+YLe6r6UD7jwdWNdKKSalp20EcFKsdj5UfaYqqv4Q6BZGUBIjjSGxlpPl J5OtJ+iu9vRg9jx5aL3wd7OUlggdBVRAUY5iYINmCIuwE1PpjlnOqsR3lqV8N6R8l8JW +II5sGYG4o5XTkeukYduAJvTGZ8QHJy+nmd0Q= 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=pJZLIVpCCc6D43D5D5ijrsomFQwBfMiysB/dud4C1MKIsQQb+dZ/GNTlxXtYiRCwPv Pnj2OrL+enwO6xnWUNYpjXpBQOmkpkZqY3JDopTADl4W4MtVWvFVE0OZQUcm6eBkVCHU 56uius8MDJKZ3WvgCxggASe/N+iXtFUoQbiQRkfCL28FUAE+zZXiMGbeTobPJ0D6yTFU Mpvhf+jLRLgO2Dyxu58IR9kLFKS2zdS1DjfKJ4R8NURIgXTImXst+oMsGJKJQeQfBJok T07853LZNPuB3rDwGh52ez+DtuuXgIDhIVTMu+8dHWGp3GP8jUe44SdTa0RyWDEZp5ei Bepg== X-Gm-Message-State: APt69E2zzOSn1o1g7pgtCUPj7K8p5o12jkRCkqXQhIYh8Hq/kN24YCGu 11LoDDFEHrrlA7PJcNsh3sSSdg== X-Google-Smtp-Source: ADUXVKKDmhUG+umZPbktHoqxizFzqqrwWyTa8efKUGqKGue/OxGWiaZtCFSPykgoGDLIP5VB62rBhQ== X-Received: by 2002:adf:f811:: with SMTP id s17-v6mr4625032wrp.172.1528461197122; Fri, 08 Jun 2018 05:33:17 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id r5-v6sm38533059wrp.59.2018.06.08.05.33.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jun 2018 05:33:13 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id F3E533E04C9; Fri, 8 Jun 2018 13:33:07 +0100 (BST) From: =?utf-8?q?Alex_Benn=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, pbonzini@redhat.com, stefanha@redhat.com, stefanb@linux.vnet.ibm.com, marcandre.lureau@redhat.com Date: Fri, 8 Jun 2018 13:32:29 +0100 Message-Id: <20180608123307.24773-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180608123307.24773-1-alex.bennee@linaro.org> References: <20180608123307.24773-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22b Subject: [Qemu-devel] [PATCH v6 11/49] 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_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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ée Tested-by: Philippe Mathieu-Daudé 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-test.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=%d, errno=%d)", - ret, errno); + error1(filename, line, "%m (ret=%d, errno=%d/%s)", + ret, errno, strerror(errno)); } return ret; } @@ -216,6 +217,7 @@ static void test_fork(void) pid = chk_error(fork()); if (pid == 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)); } -#if 0 #define WCOUNT_MAX 512 static void test_pipe(void) @@ -355,7 +356,7 @@ static void test_pipe(void) } if (FD_ISSET(fds[1], &wfds)) { ch = '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; } -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; stack1 = malloc(STACK_SIZE); pid1 = chk_error(clone(thread1_func, stack1 + STACK_SIZE, - CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello1")); + CLONE_VM | CLONE_FS | CLONE_FILES | + CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM, + "hello1")); stack2 = malloc(STACK_SIZE); pid2 = chk_error(clone(thread2_func, stack2 + STACK_SIZE, - CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello2")); + CLONE_VM | CLONE_FS | CLONE_FILES | + CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM, + "hello2")); - while (waitpid(pid1, &status1, 0) != pid1); + wait_for_child(pid1); free(stack1); - while (waitpid(pid2, &status2, 0) != pid2); + wait_for_child(pid2); free(stack2); + if (thread1_res != 5 || thread2_res != 6) error("clone"); } -#endif /***********************************/ @@ -449,12 +463,10 @@ static void test_signal(void) it.it_value.tv_usec = 10 * 1000; chk_error(setitimer(ITIMER_REAL, &it, NULL)); chk_error(getitimer(ITIMER_REAL, &oit)); - if (oit.it_value.tv_sec != it.it_value.tv_sec || - oit.it_value.tv_usec != it.it_value.tv_usec) - error("itimer"); while (alarm_count < 5) { usleep(10 * 1000); + getitimer(ITIMER_REAL, &oit); } it.it_interval.tv_sec = 0; @@ -463,9 +475,6 @@ static void test_signal(void) it.it_value.tv_usec = 0; memset(&oit, 0xff, sizeof(oit)); chk_error(setitimer(ITIMER_REAL, &it, &oit)); - if (oit.it_value.tv_sec != 0 || - oit.it_value.tv_usec != 10 * 1000) - error("setitimer"); /* SIGSEGV test */ act.sa_sigaction = 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;