From patchwork Mon Jun 3 04:44:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yihao Wu X-Patchwork-Id: 1110392 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=2001:1418:10:5::2; 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=linux.alibaba.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45JmRn2C9Qz9s3Z for ; Wed, 5 Jun 2019 21:15:30 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A46D13EA6C0 for ; Wed, 5 Jun 2019 13:15:19 +0200 (CEST) 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 [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id AC1C92D0139 for ; Mon, 3 Jun 2019 06:43:57 +0200 (CEST) Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 9FC4B600675 for ; Mon, 3 Jun 2019 06:43:56 +0200 (CEST) X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R411e4; CH=green; DM=||false|; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01f04391; MF=wuyihao@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0TTGLCVj_1559537026; Received: from ali-186590dcce93-2.local(mailfrom:wuyihao@linux.alibaba.com fp:SMTPD_---0TTGLCVj_1559537026) by smtp.aliyun-inc.com(127.0.0.1); Mon, 03 Jun 2019 12:43:46 +0800 From: Yihao Wu To: ltp@lists.linux.it, chrubis@suse.cz Message-ID: <3e2f5f1b-3fb8-8c16-5c04-383221c175ed@linux.alibaba.com> Date: Mon, 3 Jun 2019 12:44:01 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 Content-Language: en-US X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-7.5 required=7.0 tests=ENV_AND_HDR_SPF_MATCH, SPF_HELO_NONE, SPF_PASS, USER_IN_DEF_SPF_WL autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it X-Mailman-Approved-At: Wed, 05 Jun 2019 13:15:18 +0200 Cc: shanpeic@linux.alibaba.com, =?utf-8?b?6KeJ5bCP?= , caspar@linux.alibaba.com Subject: [LTP] [PATCH] commands: add test for chrt 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" This test checks check whether chrt works properly Signed-off-by: Yihao Wu --- runtest/commands | 1 + testcases/commands/chrt/Makefile | 21 ++++++++++++++++ testcases/commands/chrt/chrt01.sh | 52 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 testcases/commands/chrt/Makefile create mode 100755 testcases/commands/chrt/chrt01.sh diff --git a/runtest/commands b/runtest/commands index ac15e8b..74bd860 100644 --- a/runtest/commands +++ b/runtest/commands @@ -40,3 +40,4 @@ keyctl01_sh keyctl01.sh gdb01_sh gdb01.sh unshare01_sh unshare01.sh sysctl01_sh sysctl01.sh +chrt01_sh chrt01.sh diff --git a/testcases/commands/chrt/Makefile b/testcases/commands/chrt/Makefile new file mode 100644 index 0000000..c6f931b --- /dev/null +++ b/testcases/commands/chrt/Makefile @@ -0,0 +1,21 @@ +# +# Copyright (c) 2019 Alibaba Inc +# Author: Yihao Wu +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. + +top_srcdir ?= ../../.. + +include $(top_srcdir)/include/mk/env_pre.mk + +INSTALL_TARGETS := chrt01.sh + +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/commands/chrt/chrt01.sh b/testcases/commands/chrt/chrt01.sh new file mode 100755 index 0000000..633b3c0 --- /dev/null +++ b/testcases/commands/chrt/chrt01.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Copyright (c) 2019 Alibaba Inc +# Author: Yihao Wu +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. +# +# Test the basic functionality of chrt command. +# +TST_TESTFUNC=chrt_test +TST_SETUP=setup +TST_CLEANUP=cleanup +TST_NEEDS_CMDS="chrt cgexec cgset cgget" +TST_NEEDS_ROOT=1 +. tst_test.sh + +setup() +{ + old_rt_runtime_us=$(cgget -r cpu.rt_runtime_us / -vn) + old_rt_period_us=$(cgget -r cpu.rt_period_us / -vn) + + cgset -r cpu.rt_runtime_us=10000 / + cgset -r cpu.rt_period_us=1000000 / +} + +chrt_test() +{ + cgexec -g cpu:/ -g cpuset:/ sleep 4 & + PID=$! + cgexec -g cpu:/ -g cpuset:/ chrt -arp 50 ${PID} + SCHEDULER=$(chrt -p ${PID} | awk 'NR==1{print $6}') + if [ x"${SCHEDULER}" == x"SCHED_RR" ]; then + tst_res TPASS "'chrt' passed." + else + tst_res TFAIL "'chrt' failed to set scheduling policy." + fi +} + +cleanup() +{ + cgset -r cpu.rt_runtime_us=${old_rt_runtime_us} / + cgset -r cpu.rt_period_us=${old_rt_period_us} / +} + +tst_run