From patchwork Thu Jun 21 06:25:20 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: 139465 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1683278lji; Wed, 20 Jun 2018 23:42:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIfAph/ump6fsDRhBlq4vAjwJtJ4JtdG4qgI1LHbRy7jTdnY0pNZvzCTjMhrFJ542EY6E8B X-Received: by 2002:ac8:3fc4:: with SMTP id v4-v6mr22366486qtk.421.1529563321618; Wed, 20 Jun 2018 23:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529563321; cv=none; d=google.com; s=arc-20160816; b=o/pw2DU5Hy7rIHNjzWemy34sCi3h5nuwatZGiiW21T4D4Gt1ZcSOU8Fy/FXpgBg0fs 5gv9zaJJEMZqOExNSmEjz9z7A66vtK/urMK6lUWOXO3UnRdLPd7Tbub36FizaXTAa1A6 62w/HQp5pqfWjt4fgJeGt78QLjbKbaDjs+zwTeMKp6LBw+jkDggEG1cbpV8byYQYYLca 3smTCedvTVH/gpYQ0upzLzxVhPI7GbwERIu/BDhx7RYXYJDPIrPbWXeYLy21vyawOihN 0ARZwE85GL4pnssWxLtmcPhEIutcR9rKvedHAo5lDMbpIjwAfc2crsTAjiJxFM/Con4n H2yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=q//ToYCxZtmH4wAaC9qouXZ7CXwLSJB53Ekr1QrXlEw=; b=Xs0HtMZnE5eNy618yGKr9SKdnnvvOn3G7NdzdvNPdMh85zKeKKcB/MBHE5yCQb/OuX dxjGdJ4KViOUt5MXqxhhhoyjZZBr6LluBFTO85TvjbiG5ccMku0kmIWNLuw8Bgi17cDG rgD9nLupHb7/XJaPZasGP3SzU6q3jdkd4hOm5b8Ibqmc+VClmX+9DFgG4hQLWPo0zr64 6VB6C2SyyPakhVQHrV/gar89h2sXZKXtgEzOM3XiHcNj4f+VSN2zBw9qyiyC7qkgPtha Fex11kLhm14nbbg+CoQt2t8pldfEtMgf9OrfhXrjx3KMLLxwR0HvQd4HrS5Rn0+AWZcd lrCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=itgDDKE3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i65-v6si3982485qkf.384.2018.06.20.23.42.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Jun 2018 23:42:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=itgDDKE3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVtI9-0003n1-3E for patch@linaro.org; Thu, 21 Jun 2018 02:42:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVt2y-00011D-Mr for qemu-devel@nongnu.org; Thu, 21 Jun 2018 02:26:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVt2v-0000fS-GV for qemu-devel@nongnu.org; Thu, 21 Jun 2018 02:26:20 -0400 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:40730) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fVt2v-0000es-6x for qemu-devel@nongnu.org; Thu, 21 Jun 2018 02:26:17 -0400 Received: by mail-wr0-x233.google.com with SMTP id g18-v6so1817340wro.7 for ; Wed, 20 Jun 2018 23:26:17 -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=q//ToYCxZtmH4wAaC9qouXZ7CXwLSJB53Ekr1QrXlEw=; b=itgDDKE3yiTuR6zHJEwAoOufvToFSOx85Fgsatb4bwJBx/VrW0RtIl1KnhPmsxPk58 CptHudv9Ofg6MGfx440midvqrJXQ1Zmn0x3RLYJgikzwUUV0iGvZpum7kgEqLZevK3g5 PQSBRVlIKD3habRgORSThEBsDpX0E+g/aIRqc= 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=q//ToYCxZtmH4wAaC9qouXZ7CXwLSJB53Ekr1QrXlEw=; b=qdXc1DtirGS5A3FTvee9gS+xtGey93CqOEikr04O89hi+LK24bjOuv4H3MjCTk3i/K l24KNSZM+7sZBqp6lmgA7094OMFZeQdMElZD0p34alUF+5qD24cd3/95Ey3aBdY+SsOn GI9idAfKY+01xo7bgoL1ddCjyUuV4xv+/FaKMBHG4YZtRvEQax8otQoTStfEbIHpY/F/ q0JdqKVP/PaKIqNpCedPKhSKkVLBNttrh2H05oqD5W2dU6J4JDSpNg/QVqw+E/uFVft7 YJL5kiU+r87V/p2kduXheRTnDgnmx41yiXAJywqchzPt2qqwfHP+nqA7fMtdaQYhn8is Qd8g== X-Gm-Message-State: APt69E3/jbQAJ1X67iAob0R2yvcfBK2kBMIxk8hvM3+P6yzi4Ra2YyUy E5o2zJDTrqL1A75pVVOqW6ieag== X-Received: by 2002:adf:86ae:: with SMTP id 43-v6mr18669599wrx.281.1529562376141; Wed, 20 Jun 2018 23:26:16 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id f81-v6sm6988330wmh.32.2018.06.20.23.26.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Jun 2018 23:26:11 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 48ECD3E0AC0; Thu, 21 Jun 2018 07:26:06 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 21 Jun 2018 07:25:20 +0100 Message-Id: <20180621062605.941-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621062605.941-1-alex.bennee@linaro.org> References: <20180621062605.941-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::233 Subject: [Qemu-devel] [PULL v2 12/57] 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: agraf@suse.de, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, f4bug@amsat.org, cota@braap.org, famz@redhat.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.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 -- 2.17.1 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;