From patchwork Fri Jan 4 12:13:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1020712 X-Patchwork-Delegate: petr.vorel@gmail.com 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=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43WNz36kG2z9s3l for ; Fri, 4 Jan 2019 23:15:26 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 668843E65EC for ; Fri, 4 Jan 2019 13:15:23 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id D3CB93E65EC for ; Fri, 4 Jan 2019 13:15:21 +0100 (CET) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 6229C600986 for ; Fri, 4 Jan 2019 13:15:19 +0100 (CET) Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6683CAC38; Fri, 4 Jan 2019 12:15:19 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 4 Jan 2019 13:13:39 +0100 Message-Id: <20190104121339.32147-1-pvorel@suse.cz> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH 1/1] cgroup: Rewrite some C parts into new API X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Petr Vorel --- .../cgroup/cgroup_regression_6_2.c | 29 +++++++++++++------ .../cgroup/cgroup_regression_fork_processes.c | 28 +++++++++--------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/testcases/kernel/controllers/cgroup/cgroup_regression_6_2.c b/testcases/kernel/controllers/cgroup/cgroup_regression_6_2.c index b79b93730..226a12d61 100644 --- a/testcases/kernel/controllers/cgroup/cgroup_regression_6_2.c +++ b/testcases/kernel/controllers/cgroup/cgroup_regression_6_2.c @@ -1,30 +1,31 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* + * Copyright (c) 2019 Petr Vorel * Copyright (c) 2009 FUJITSU LIMITED * Author: Li Zefan */ #define _GNU_SOURCE +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) + #include -#include -#include -#include "test.h" +#include "tst_test.h" #define DEFAULT_USEC 30000 +static char *str_usec; + int foo(void __attribute__ ((unused)) * arg) { return 0; } -int main(int argc, char **argv) +static void do_test(void) { int usec; - - if (argc == 2) - usec = atoi(argv[1]); - else + if (tst_parse_int(str_usec, &usec, 1, INT_MAX)) usec = DEFAULT_USEC; while (1) { @@ -32,5 +33,15 @@ int main(int argc, char **argv) ltp_clone_quick(CLONE_NEWNS, foo, NULL); } - tst_exit(); + tst_res(TINFO, "exit"); } + +static struct tst_option options[] = { + {"u", &str_usec, "-u usec (default " STR(DEFAULT_USEC) ")"}, + {NULL, NULL, NULL} +}; + +static struct tst_test test = { + .test_all = do_test, + .options = options, +}; diff --git a/testcases/kernel/controllers/cgroup/cgroup_regression_fork_processes.c b/testcases/kernel/controllers/cgroup/cgroup_regression_fork_processes.c index 6f2498bb8..b31e79bcc 100644 --- a/testcases/kernel/controllers/cgroup/cgroup_regression_fork_processes.c +++ b/testcases/kernel/controllers/cgroup/cgroup_regression_fork_processes.c @@ -1,34 +1,36 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* + * Copyright (c) 2019 Petr Vorel * Copyright (c) 2009 FUJITSU LIMITED - * * Author: Li Zefan */ #include #include #include -#include +#include "tst_test.h" -int main(void) +#define NUM_LOOPS 200 + +static void do_test(void) { int i; - pid_t pid; while (1) { - for (i = 0; i < 200; i++) { - pid = fork(); - if (pid == 0) { + for (i = 0; i < NUM_LOOPS; i++) { + if (!SAFE_FORK()) { exit(0); - } else if (pid == -1) { - continue; } } - for (i = 0; i < 200; i++) - if (wait(NULL) < 0) - break; + for (i = 0; i < NUM_LOOPS; i++) + SAFE_WAIT(NULL); } - return 0; + tst_res(TINFO, "exit"); } + +static struct tst_test test = { + .test_all = do_test, + .forks_child = 1, +};