Skip to contentSkip to conversation

cgroup_regression_test.sh ported to newlib

PATCH Superseded Cristian Marussi 2 participants 5 messages Dec 21, 2018 – Jan 4, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 cgroup_regression_test.sh ported to newlib

Ported to newlib and cleaned up.

- removed absolute/relative commands invocations
- avoid bashism
+ removed bash shebang
+ giving up 'kill' bash-builtin: this needs redefining used sigspec strings
- A common function 'get_cgroup_mountpoint' is added to help parse /proc/mounts in search of specific cgroup subsystems mountpoints. It is added as part of a common cgroup_lib.sh.
- converted Copyright headers to SPDX
- renamed each helper to include a tag prefix (cgroup_regress_) in order to avoid possible name clashes once installed all together into testcases/bin

---
 .../kernel/controllers/cgroup/.gitignore      |   2 +-
 testcases/kernel/controllers/cgroup/Makefile  |  22 +-
 .../cgroup/cgroup_regress_test_10_1.sh        |  14 +
 .../cgroup/cgroup_regress_test_10_2.sh        |  12 +
 .../cgroup/cgroup_regress_test_3_1.sh         |  14 +
 .../cgroup/cgroup_regress_test_3_2.sh         |  11 +
 .../cgroup/cgroup_regress_test_6_1.sh         |  13 +
 .../cgroup/cgroup_regress_test_6_2.c          |  39 ++
 .../cgroup/cgroup_regress_test_9_1.sh         |  14 +
 .../cgroup/cgroup_regress_test_9_2.sh         |  13 +
 .../cgroup/cgroup_regression_test.sh          | 341 +++++++++---------
 .../controllers/cgroup/fork_processes.c       |  27 +-
 .../kernel/controllers/cgroup/getdelays.c     |  14 +-
 .../kernel/controllers/cgroup/test_10_1.sh    |  33 --
 .../kernel/controllers/cgroup/test_10_2.sh    |  31 --
 .../kernel/controllers/cgroup/test_3_1.sh     |  33 --
 .../kernel/controllers/cgroup/test_3_2.sh     |  30 --
 .../kernel/controllers/cgroup/test_6_1.sh     |  32 --
 .../kernel/controllers/cgroup/test_6_2.c      |  52 ---
 .../kernel/controllers/cgroup/test_9_1.sh     |  33 --
 .../kernel/controllers/cgroup/test_9_2.sh     |  32 --
 testcases/kernel/controllers/cgroup_lib.sh    |  33 ++
 22 files changed, 341 insertions(+), 504 deletions(-)
 create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_10_1.sh
 create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_10_2.sh
 create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_3_1.sh
 create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_3_2.sh
 create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_6_1.sh
 create mode 100644 testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c
 create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_9_1.sh
 create mode 100755 testcases/kernel/controllers/cgroup/cgroup_regress_test_9_2.sh
 delete mode 100755 testcases/kernel/controllers/cgroup/test_10_1.sh
 delete mode 100755 testcases/kernel/controllers/cgroup/test_10_2.sh
 delete mode 100755 testcases/kernel/controllers/cgroup/test_3_1.sh
 delete mode 100755 testcases/kernel/controllers/cgroup/test_3_2.sh
 delete mode 100755 testcases/kernel/controllers/cgroup/test_6_1.sh
 delete mode 100644 testcases/kernel/controllers/cgroup/test_6_2.c
 delete mode 100755 testcases/kernel/controllers/cgroup/test_9_1.sh
 delete mode 100755 testcases/kernel/controllers/cgroup/test_9_2.sh
 create mode 100644 testcases/kernel/controllers/cgroup_lib.sh
testcases/kernel/controllers/cgroup/.gitignore +1 -1
index a7f8569a8..1b6e05477 100644
@@ -1,3 +1,3 @@
 /fork_processes
 /getdelays
-/test_6_2
+/cgroup_regress_test_6_2
testcases/kernel/controllers/cgroup/Makefile +3 -19
index 0cd60adae..8075ae80d 100644
@@ -1,24 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2009, Cisco Systems Inc.
+# Author: Ngie Cooper, July 2009
 #
 #    kernel/controllers/cgroup test suite Makefile.
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
-#
-#    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.
-#
-#    You should have received a copy of the GNU General Public License along
-#    with this program; if not, write to the Free Software Foundation, Inc.,
-#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Ngie Cooper, July 2009
-#
 
 top_srcdir		?= ../../../..
 
testcases/kernel/controllers/cgroup/cgroup_regress_test_10_1.sh new file +14 -0
new file mode 100755
index 000000000..d7bc5feb2
@@ -0,0 +1,14 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2009 FUJITSU LIMITED
+# Author: Li Zefan <[email protected]>
+
+trap exit USR1
+while true
+do
+	mount -t cgroup xxx cgroup/ > /dev/null 2>&1
+	mkdir cgroup/0 > /dev/null 2>&1
+	rmdir cgroup/0 > /dev/null 2>&1
+	umount cgroup/ > /dev/null 2>&1
+done
+
testcases/kernel/controllers/cgroup/cgroup_regress_test_10_2.sh new file +12 -0
new file mode 100755
index 000000000..b1222422d
@@ -0,0 +1,12 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2009 FUJITSU LIMITED
+# Author: Li Zefan <[email protected]>
+
+trap exit USR1
+while true
+do
+	mount -t cgroup xxx cgroup/ > /dev/null 2>&1
+	umount cgroup/ > /dev/null 2>&1
+done
+
testcases/kernel/controllers/cgroup/cgroup_regress_test_3_1.sh new file +14 -0
new file mode 100755
index 000000000..a23afab4c
@@ -0,0 +1,14 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2009 FUJITSU LIMITED
+# Author: Li Zefan <[email protected]>
+
+trap exit USR1
+
+path=$1
+
+while true
+do
+	mkdir $path/0
+	rmdir $path/0
+done
testcases/kernel/controllers/cgroup/cgroup_regress_test_3_2.sh new file +11 -0
new file mode 100755
index 000000000..e1836a3e2
@@ -0,0 +1,11 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2009 FUJITSU LIMITED
+# Author: Li Zefan <[email protected]>
+
+trap exit USR1
+while true
+do
+	cat /proc/sched_debug > /dev/null
+done
+
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_1.sh new file +13 -0
new file mode 100755
index 000000000..3ca5e3154
@@ -0,0 +1,13 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2009 FUJITSU LIMITED
+# Author: Li Zefan <[email protected]>
+
+trap exit USR1
+while true
+do
+	mount -t cgroup -o ns xxx cgroup/ > /dev/null 2>&1
+	rmdir cgroup/[1-9]* > /dev/null 2>&1
+	umount cgroup/ > /dev/null 2>&1
+done
+
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +39 -0
new file mode 100644
index 000000000..e85d14636
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2009 FUJITSU LIMITED
+ *
+ * Author: Li Zefan <[email protected]>
+ */
+
+#define _GNU_SOURCE
+
+#include <sched.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+
+#define DEFAULT_USEC	30000
+
+int foo(void __attribute__ ((unused)) * arg)
+{
+	return 0;
+}
+
+int main(int argc, char **argv)
+{
+	int usec;
+
+	if (argc == 2)
+		usec = atoi(argv[1]);
+	else
+		usec = DEFAULT_USEC;
+
+	while (1) {
+		usleep(usec);
+		ltp_clone_quick(CLONE_NEWNS, foo, NULL);
+	}
+
+	return 0;
+}
testcases/kernel/controllers/cgroup/cgroup_regress_test_9_1.sh new file +14 -0
new file mode 100755
index 000000000..4b6741a91
@@ -0,0 +1,14 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2009 FUJITSU LIMITED
+# Author: Li Zefan <[email protected]>
+
+trap exit USR1
+while true
+do
+#	mount -t cgroup -o debug xxx cgroup/ > /dev/null 2>&1
+	mount -t cgroup xxx cgroup/ > /dev/null 2>&1
+	cat cgroup/release_agent > /dev/null 2>&1
+	umount cgroup/ > /dev/null 2>&1
+done
+
testcases/kernel/controllers/cgroup/cgroup_regress_test_9_2.sh new file +13 -0
new file mode 100755
index 000000000..b9c05d032
@@ -0,0 +1,13 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2009 FUJITSU LIMITED
+# Author: Li Zefan <[email protected]>
+
+trap exit USR1
+while true
+do
+#	mount -t cgroup -o debug xxx cgroup/ > /dev/null 2>&1
+	mount -t cgroup xxx cgroup/ > /dev/null 2>&1
+	umount cgroup/ > /dev/null 2>&1
+done
+
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +163 -178

627 lines not on this page · raw message

testcases/kernel/controllers/cgroup/fork_processes.c +6 -21
index b4bb77101..6f2498bb8 100644
@@ -1,24 +1,9 @@
-/******************************************************************************/
-/*                                                                            */
-/* Copyright (c) 2009 FUJITSU LIMITED                                         */
-/*                                                                            */
-/* 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.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/* Author: Li Zefan <[email protected]>                                     */
-/*                                                                            */
-/******************************************************************************/
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2009 FUJITSU LIMITED
+ *
+ * Author: Li Zefan <[email protected]>
+ */
 
 #include <sys/types.h>
 #include <sys/wait.h>
testcases/kernel/controllers/cgroup/getdelays.c +5 -9
index 4e87a13ca..7a01d16bd 100644
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* getdelays.c
  *
  * Utility to get per-pid and per-tgid delay accounting statistics
@@ -7,8 +8,6 @@
  * Copyright (C) Balbir Singh, IBM Corp. 2006
  * Copyright (c) Jay Lan, SGI. 2006
  *
- * Compile with
- *	gcc -I/usr/src/linux/include getdelays.c -o getdelays
  */
 
 #include <stdio.h>
@@ -173,14 +172,14 @@ int get_family_id(int sd)
 		char buf[256];
 	} ans;
 
-	int id = 0, rc;
+	int id = 0;
 	struct nlattr *na;
 	int rep_len;
 
 	strcpy(name, TASKSTATS_GENL_NAME);
-	rc = send_cmd(sd, GENL_ID_CTRL, getpid(), CTRL_CMD_GETFAMILY,
-		      CTRL_ATTR_FAMILY_NAME, (void *)name,
-		      strlen(TASKSTATS_GENL_NAME) + 1);
+	send_cmd(sd, GENL_ID_CTRL, getpid(), CTRL_CMD_GETFAMILY,
+		 CTRL_ATTR_FAMILY_NAME, (void *)name,
+		 strlen(TASKSTATS_GENL_NAME) + 1);
 
 	rep_len = recv(sd, &ans, sizeof(ans), 0);
 	if (ans.n.nlmsg_type == NLMSG_ERROR ||
@@ -414,8 +413,6 @@ int main(int argc, char *argv[])
 	}
 
 	do {
-		int i;
-
 		rep_len = recv(nl_sd, &msg, sizeof(msg), 0);
 		PRINTF("received %d bytes\n", rep_len);
 
@@ -439,7 +436,6 @@ int main(int argc, char *argv[])
 
 		na = (struct nlattr *)GENLMSG_DATA(&msg);
 		len = 0;
-		i = 0;
 		while (len < rep_len) {
 			len += NLA_ALIGN(na->nla_len);
 			switch (na->nla_type) {
testcases/kernel/controllers/cgroup/test_10_1.sh deleted +0 -33
deleted file mode 100755
index 2a7763b09..000000000
@@ -1,33 +0,0 @@
-#! /bin/bash
-
-################################################################################
-##                                                                            ##
-## Copyright (c) 2009 FUJITSU LIMITED                                         ##
-##                                                                            ##
-## 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.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-## Author: Li Zefan <[email protected]>                                     ##
-##                                                                            ##
-################################################################################
-
-trap exit SIGUSR1
-for ((; ;))
-{
-	mount -t cgroup xxx cgroup/ > /dev/null 2>&1
-	mkdir cgroup/0 > /dev/null 2>&1
-	rmdir cgroup/0 > /dev/null 2>&1
-	umount cgroup/ > /dev/null 2>&1
-}
-
testcases/kernel/controllers/cgroup/test_10_2.sh deleted +0 -31
deleted file mode 100755
index a6e50d883..000000000
@@ -1,31 +0,0 @@
-#! /bin/bash
-
-################################################################################
-##                                                                            ##
-## Copyright (c) 2009 FUJITSU LIMITED                                         ##
-##                                                                            ##
-## 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.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-## Author: Li Zefan <[email protected]>                                     ##
-##                                                                            ##
-################################################################################
-
-trap exit SIGUSR1
-for ((; ;))
-{
-	mount -t cgroup xxx cgroup/ > /dev/null 2>&1
-	umount cgroup/ > /dev/null 2>&1
-}
-
testcases/kernel/controllers/cgroup/test_3_1.sh deleted +0 -33
deleted file mode 100755
index dcc78a6b1..000000000
@@ -1,33 +0,0 @@
-#! /bin/bash
-
-################################################################################
-##                                                                            ##
-## Copyright (c) 2009 FUJITSU LIMITED                                         ##
-##                                                                            ##
-## 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.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-## Author: Li Zefan <[email protected]>                                     ##
-##                                                                            ##
-################################################################################
-
-trap exit SIGUSR1
-
-path=$1
-
-for ((; ;))
-{
-	mkdir $path/0
-	rmdir $path/0
-}
testcases/kernel/controllers/cgroup/test_3_2.sh deleted +0 -30
deleted file mode 100755
index 63bafaa46..000000000
@@ -1,30 +0,0 @@
-#! /bin/bash
-
-################################################################################
-##                                                                            ##
-## Copyright (c) 2009 FUJITSU LIMITED                                         ##
-##                                                                            ##
-## 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.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-## Author: Li Zefan <[email protected]>                                     ##
-##                                                                            ##
-################################################################################
-
-trap exit SIGUSR1
-for ((; ;))
-{
-	cat /proc/sched_debug > /dev/null
-}
-
testcases/kernel/controllers/cgroup/test_6_1.sh deleted +0 -32
deleted file mode 100755
index 4eb6b3293..000000000
@@ -1,32 +0,0 @@
-#! /bin/bash
-
-################################################################################
-##                                                                            ##
-## Copyright (c) 2009 FUJITSU LIMITED                                         ##
-##                                                                            ##
-## 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.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-## Author: Li Zefan <[email protected]>                                     ##
-##                                                                            ##
-################################################################################
-
-trap exit SIGUSR1
-for ((; ;))
-{
-	mount -t cgroup -o ns xxx cgroup/ > /dev/null 2>&1
-	rmdir cgroup/[1-9]* > /dev/null 2>&1
-	umount cgroup/ > /dev/null 2>&1
-}
-
testcases/kernel/controllers/cgroup/test_6_2.c deleted +0 -52

52 lines not on this page · raw message

testcases/kernel/controllers/cgroup/test_9_1.sh deleted +0 -33
deleted file mode 100755
index b7c26a46c..000000000
@@ -1,33 +0,0 @@
-#! /bin/bash
-
-################################################################################
-##                                                                            ##
-## Copyright (c) 2009 FUJITSU LIMITED                                         ##
-##                                                                            ##
-## 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.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-## Author: Li Zefan <[email protected]>                                     ##
-##                                                                            ##
-################################################################################
-
-trap exit SIGUSR1
-for ((; ;))
-{
-#	mount -t cgroup -o debug xxx cgroup/ > /dev/null 2>&1
-	mount -t cgroup xxx cgroup/ > /dev/null 2>&1
-	cat cgroup/release_agent > /dev/null 2>&1
-	umount cgroup/ > /dev/null 2>&1
-}
-
testcases/kernel/controllers/cgroup/test_9_2.sh deleted +0 -32
deleted file mode 100755
index 2d7d38675..000000000
@@ -1,32 +0,0 @@
-#! /bin/bash
-
-################################################################################
-##                                                                            ##
-## Copyright (c) 2009 FUJITSU LIMITED                                         ##
-##                                                                            ##
-## 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.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-## Author: Li Zefan <[email protected]>                                     ##
-##                                                                            ##
-################################################################################
-
-trap exit SIGUSR1
-for ((; ;))
-{
-#	mount -t cgroup -o debug xxx cgroup/ > /dev/null 2>&1
-	mount -t cgroup xxx cgroup/ > /dev/null 2>&1
-	umount cgroup/ > /dev/null 2>&1
-}
-
testcases/kernel/controllers/cgroup_lib.sh new file +33 -0
new file mode 100644
index 000000000..5cdf55363
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2018-2019 ARM Ltd. All Rights Reserved.
+
+#
+# Helper to parse /proc/mounts to find the mountpoints (if any)
+# associated with the cgroup subsystem passed as param.
+#
+# It expects as single argument the cgroup subsytem for
+# which to search in /proc/mounts the mountpoint (if any).
+#
+# - returns true|false depending if any mountpoint has been found.
+# - echos back the mountpoint itself if any found
+#
+get_cgroup_mountpoint()
+{
+	local mntpoint
+	local line
+	local ret=1
+	local subsystem=$1
+
+	# fail straight away with no args
+	[ $# -eq 0 ] && return $ret
+
+	line=$(grep cgroup /proc/mounts | grep -w $subsystem)
+	ret=$?
+	# extract mountpoint if any exist
+	[ $ret = 0 ] && mntpoint=$(echo $line | awk '{ print $2 }') && echo $mntpoint
+
+	return $ret
+}
+
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/1 cgroup_regression_test.sh ported to newlib

Hi Cristian,

Quoted 15 lines

Ported to newlib and cleaned up.

- removed absolute/relative commands invocations
- avoid bashism
+ removed bash shebang
+ giving up 'kill' bash-builtin: this needs redefining used sigspec strings
- A common function 'get_cgroup_mountpoint' is added to help parse /proc/mounts in search of specific cgroup subsystems mountpoints. It is added as part of a common cgroup_lib.sh.
- converted Copyright headers to SPDX
- renamed each helper to include a tag prefix (cgroup_regress_) in order to avoid possible name clashes once installed all together into testcases/bin

Quoted 1 line

Thanks for your patch, merged with several code style changes:
- unify file names (cgroup_regress_* => cgroup_regression_)
- rename also getdelays.c and fork_processes.c
- redirect wait's stderr to /dev/null to keep it quiet
- remove mandatory commands from TST_NEEDS_CMDS
- move tst_test.sh loading into library
- cleanup get_cgroup_mountpoint()
- minor code style fixes

See diff bellow. I also added 4 commits related to this test, one of them is fixing regression I added while changing your code (I'm sorry).

Kind regards,
Petr

#2 lore raw

PATCH v3 1/1 cgroup_regression_test.sh ported to newlib

Hi Petr

Quoted 19 lines · Petr Vorel

Hi Cristian,

Quoted 15 lines

Ported to newlib and cleaned up.

- removed absolute/relative commands invocations
- avoid bashism
+ removed bash shebang
+ giving up 'kill' bash-builtin: this needs redefining used sigspec strings
- A common function 'get_cgroup_mountpoint' is added to help parse /proc/mounts in search of specific cgroup subsystems mountpoints. It is added as part of a common cgroup_lib.sh.
- converted Copyright headers to SPDX
- renamed each helper to include a tag prefix (cgroup_regress_) in order to avoid possible name clashes once installed all together into testcases/bin

Quoted 1 line
Quoted 9 lines

Thanks for your patch, merged with several code style changes:
- unify file names (cgroup_regress_* => cgroup_regression_)
- rename also getdelays.c and fork_processes.c
- redirect wait's stderr to /dev/null to keep it quiet
- remove mandatory commands from TST_NEEDS_CMDS
- move tst_test.sh loading into library
- cleanup get_cgroup_mountpoint()
- minor code style fixes

Thanks for your review and further fixes.

Quoted 3 lines

See diff bellow. I also added 4 commits related to this test, one of them is fixing regression I added while changing your code (I'm sorry).

Everything's fine but in cgroup_regress_test_6_2.c you reverted to old API, while you previously told me not to:

Quoted 2 lines

+++ b/testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c

(quoted diff) +0 -0
@@ -0,0 +1,37 @@

[snip]

testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c

Quoted 4 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +4 -0
+#include <sched.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "test.h"

Please don't use legacy API. <<<<<<

is that fine ?

Thanks

Regards

Cristian

#3 lore raw

PATCH v3 1/1 cgroup_regression_test.sh ported to newlib

Hi Cristian,

Quoted 11 lines
Quoted 3 lines

See diff bellow. I also added 4 commits related to this test, one of them is fixing regression I added while changing your code (I'm sorry).

Everything's fine but in cgroup_regress_test_6_2.c you reverted to old API, while you previously told me not to:

Quoted 2 lines

+++ b/testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c

(quoted diff) +0 -0
@@ -0,0 +1,37 @@

[snip]

Quoted 7 lines

testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c

Quoted 4 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +4 -0
+#include <sched.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "test.h"

Please don't use legacy API. <<<<<<

is that fine ?

I'm sorry I forget to tell you I reverted this, it was deliberate change. Using TST_NO_DEFAULT_MAIN was wrong (it's usually used in LTP library only. Also it's recommended to use SAFE_*() if possible.

I've sent patch to implement this for some C code [1], but it's failing (endless clone).

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/patch/1020712/

#4 lore raw

PATCH v3 1/1 cgroup_regression_test.sh ported to newlib

Hi

Quoted 19 lines · Petr Vorel

Hi Cristian,

Quoted 16 lines
Quoted 3 lines

See diff bellow. I also added 4 commits related to this test, one of them is fixing regression I added while changing your code (I'm sorry).

Everything's fine but in cgroup_regress_test_6_2.c you reverted to old API, while you previously told me not to:

Quoted 2 lines

+++ b/testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c

(quoted diff) +0 -0
@@ -0,0 +1,37 @@

[snip]

testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c

Quoted 4 lines
testcases/kernel/controllers/cgroup/cgroup_regress_test_6_2.c new file +4 -0
+#include <sched.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "test.h"

Please don't use legacy API. <<<<<<

Quoted 5 lines
Quoted 1 line

is that fine ?

I'm sorry I forget to tell you I reverted this, it was deliberate change. Using TST_NO_DEFAULT_MAIN was wrong (it's usually used in LTP library only. Also it's recommended to use SAFE_*() if possible.

Oh..ok..fine I didn't know that.

Quoted 3 lines

I've sent patch to implement this for some C code [1], but it's failing (endless clone).

I saw the patch, I'll try locally later.

Quoted 2 lines

Kind regards,
Petr

Thanks

Regards

Cristian

Quoted 3 lines

[1] https://patchwork.ozlabs.org/patch/1020712/