]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tests: Remove the tests folder from this git repo
authorTom Hromatka <tom.hromatka@oracle.com>
Mon, 6 Apr 2020 14:43:43 +0000 (08:43 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 6 Apr 2020 14:43:43 +0000 (08:43 -0600)
The test code has been moved to a separate git repo,
libcgroup-tests.  Before we can add that repo as a submodule,
we must first delete the tests directory.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
78 files changed:
tests/.gitignore [deleted file]
tests/Makefile.am [deleted file]
tests/ftests/.gitignore [deleted file]
tests/ftests/001-cgget-basic_cgget.py [deleted file]
tests/ftests/Makefile.am [deleted file]
tests/ftests/README.md [deleted file]
tests/ftests/__init__.py [deleted file]
tests/ftests/cgroup.py [deleted file]
tests/ftests/config.py [deleted file]
tests/ftests/consts.py [deleted file]
tests/ftests/container.py [deleted file]
tests/ftests/default.conf [deleted file]
tests/ftests/ftests.py [deleted file]
tests/ftests/log.py [deleted file]
tests/ftests/run.py [deleted file]
tests/get_all_controller.c [deleted file]
tests/get_controller.c [deleted file]
tests/get_mount_point.c [deleted file]
tests/get_procs.c [deleted file]
tests/get_variable_names.c [deleted file]
tests/gunit/.gitignore [deleted file]
tests/gunit/001-path.cpp [deleted file]
tests/gunit/002-cgroup_parse_rules_options.cpp [deleted file]
tests/gunit/003-cg_get_cgroups_from_proc_cgroups.cpp [deleted file]
tests/gunit/004-cgroup_compare_ignore_rule.cpp [deleted file]
tests/gunit/005-cgroup_compare_wildcard_procname.cpp [deleted file]
tests/gunit/Makefile.am [deleted file]
tests/gunit/gtest.cpp [deleted file]
tests/gunit/libcgroup_unittest.map [deleted file]
tests/libcg_ba.cpp [deleted file]
tests/libcgrouptest.h [deleted file]
tests/libcgrouptest01.c [deleted file]
tests/logger.c [deleted file]
tests/logger.sh [deleted file]
tests/proctest.c [deleted file]
tests/read_stats.c [deleted file]
tests/runlibcgrouptest.sh.in [deleted file]
tests/setuid.c [deleted file]
tests/test_functions.c [deleted file]
tests/test_named_hierarchy.c [deleted file]
tests/tools/Makefile.am [deleted file]
tests/tools/README [deleted file]
tests/tools/cgclassify/Makefile.am [deleted file]
tests/tools/cgclassify/cgclassify [deleted file]
tests/tools/cgclassify/cgclassify-rules [deleted file]
tests/tools/cgclassify/simple.conf [deleted file]
tests/tools/cgconfigparser/Makefile.am [deleted file]
tests/tools/cgconfigparser/cgclear/cgclear_config_multi_1.conf [deleted file]
tests/tools/cgconfigparser/cgclear/cgclear_config_multi_2.conf [deleted file]
tests/tools/cgconfigparser/cgclear/cgclear_config_multi_3.conf [deleted file]
tests/tools/cgconfigparser/cgclear/cgclear_config_one.conf [deleted file]
tests/tools/cgconfigparser/cgclear_config_multi [deleted file]
tests/tools/cgconfigparser/cgclear_config_one [deleted file]
tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex1 [deleted file]
tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex2 [deleted file]
tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex3 [deleted file]
tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex4 [deleted file]
tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions.conf [deleted file]
tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default1.conf [deleted file]
tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default2.conf [deleted file]
tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default3.conf [deleted file]
tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default4.conf [deleted file]
tests/tools/cgconfigparser/cgconfigparser_conf_files_tests [deleted file]
tests/tools/cgconfigparser/cgconfigparser_multiconfig [deleted file]
tests/tools/cgconfigparser/cgconfigparser_simple [deleted file]
tests/tools/cgconfigparser/multiconfig/1.conf [deleted file]
tests/tools/cgconfigparser/multiconfig/2.conf [deleted file]
tests/tools/cgconfigparser/multiconfig/3.conf [deleted file]
tests/tools/cgconfigparser/multiconfig/4.conf [deleted file]
tests/tools/cgconfigparser/multiconfig/5.conf [deleted file]
tests/tools/cgconfigparser/permissions [deleted file]
tests/tools/multimount/Makefile.am [deleted file]
tests/tools/multimount/many_mp [deleted file]
tests/tools/multimount/many_named [deleted file]
tests/tools/testenv.sh.in [deleted file]
tests/walk_task.c [deleted file]
tests/walk_test.c [deleted file]
tests/wrapper_test.c [deleted file]

diff --git a/tests/.gitignore b/tests/.gitignore
deleted file mode 100644 (file)
index 803c49a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-get_all_controller
-get_controller
-get_mount_point
-get_procs
-get_variable_names
-libcg_ba
-libcgrouptest01
-pathtest
-proctest
-read_stats
-setuid
-test_named_hierarchy
-walk_task
-walk_test
-wrapper_test
diff --git a/tests/Makefile.am b/tests/Makefile.am
deleted file mode 100644 (file)
index 1528af2..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-SUBDIRS = ftests gunit tools
-
-INCLUDES = -I$(top_srcdir)/include
-LDADD = $(top_builddir)/src/.libs/libcgroup.la
-
-# compile the tests, but do not install them
-noinst_PROGRAMS = libcgrouptest01 libcg_ba setuid walk_test read_stats walk_task get_controller get_mount_point proctest get_all_controller get_variable_names test_named_hierarchy get_procs wrapper_test logger
-
-libcgrouptest01_SOURCES=libcgrouptest01.c test_functions.c libcgrouptest.h
-libcg_ba_SOURCES=libcg_ba.cpp
-setuid_SOURCES=setuid.c
-walk_test_SOURCES=walk_test.c
-read_stats_SOURCES=read_stats.c
-walk_task_SOURCES=walk_task.c
-get_controller_SOURCES=get_controller.c
-get_mount_point_SOURCES=get_mount_point.c
-proctest_SOURCES=proctest.c
-get_all_controller_SOURCES=get_all_controller.c
-get_variable_names_SOURCES=get_variable_names.c
-test_named_hierarchy_SOURCES=test_named_hierarchy.c
-get_procs_SOURCES=get_procs.c
-wrapper_test_SOURCES=wrapper_test.c
-logger_SOURCES=logger.c
-
-EXTRA_DIST = runlibcgrouptest.sh logger.sh
-
-# The legacy tests have been disabled because they do not successfully run
-# on Travis CI.
-#TESTS = wrapper_test runlibcgrouptest.sh logger.sh
diff --git a/tests/ftests/.gitignore b/tests/ftests/.gitignore
deleted file mode 100644 (file)
index 9a54287..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-tmp.conf
-*.log
-*.pyc
-*.swp
-*.trs
diff --git a/tests/ftests/001-cgget-basic_cgget.py b/tests/ftests/001-cgget-basic_cgget.py
deleted file mode 100755 (executable)
index be58869..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python3
-#
-# Basic cgget functionality test
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-from cgroup import Cgroup
-import consts
-import ftests
-import os
-import sys
-
-CONTROLLER='cpu'
-CGNAME="001cgget"
-
-SETTING='cpu.shares'
-VALUE='512'
-
-def setup(config):
-    Cgroup.create(config, CONTROLLER, CGNAME)
-    Cgroup.set(config, CGNAME, SETTING, VALUE)
-
-def test(config):
-    result = consts.TEST_PASSED
-    cause = None
-
-    value = Cgroup.get(config, controller=None, cgname=CGNAME,
-                       setting=SETTING, print_headers=False,
-                       values_only=True)
-
-    if value != VALUE:
-        result = consts.TEST_FAILED
-        cause = "cgget expected {} but received {}".format(VALUE, value)
-
-    return result, cause
-
-def teardown(config):
-    Cgroup.delete(config, CONTROLLER, CGNAME)
-
-def main(config):
-    setup(config)
-    [result, cause] = test(config)
-    teardown(config)
-
-    return [result, cause]
-
-if __name__ == '__main__':
-    config = ftests.parse_args()
-    # this test was invoked directly.  run only it
-    config.test_num = int(os.path.basename(__file__).split('-')[0])
-    sys.exit(ftests.main(config))
diff --git a/tests/ftests/Makefile.am b/tests/ftests/Makefile.am
deleted file mode 100644 (file)
index 36264e5..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# libcgroup functional tests Makefile.am
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-TESTS = 001-cgget-basic_cgget.py
-
-EXTRA_DIST = *.py README.md default.conf
-
-clean-local: clean-local-check
-.PHONY: clean-local-check
-clean-local-check:
-       -rm -f *.pyc
diff --git a/tests/ftests/README.md b/tests/ftests/README.md
deleted file mode 100644 (file)
index ed3dcb6..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-## Functional Test Suite for libcgroup
-
-This folder contains the functional test suite for libcgroup.
-The functional test suite utilizes lxc containers to guarantee
-a non-destructive test environment.
-
-The tests can be invoked individually, as a group of related
-tests, or from automake via the standard 'make check'
-command.
-
-## Invocation
-
-Run a single test (first cd to tests/ftests):
-
-    ./001-cgget-basic_cgget.py
-    or
-    ./ftests.py -N 15      # Run test #015
-
-Run a suite of tests (first cd to tests/ftests):
-
-    ./ftests.py -s cgget   # Run all cgget tests
-
-Run all the tests by hand
-
-    ./ftests.py
-    # This may be advantageous over running make check
-    # because it will try to re-use the same lxc
-    # container for all of the tests.  This should
-    # provide a significant performance increase
-
-Run the tests from automake
-
-    make check
-    # Then examine the *.trs and *.log files for
-    # specifics regarding each test result
-
-## Results
-
-The test suite will generate test results upon completion of
-the test run.  An example result is below:
-
-```
-Test Results:
-        Run Date:                     Jun 03 13:41:35
-        Passed:                               1  test
-        Skipped:                              0 tests
-        Failed:                               0 tests
------------------------------------------------------------------
-Timing Results:
-        Test                               Time (sec)
-        ---------------------------------------------------------
-        setup                                    6.95
-        001-cgget-basic_cgget.py                 0.07
-        teardown                                 0.00
-        ---------------------------------------------------------
-        Total Run Time                           7.02
-```
-
-A log file can also be generated to help in debugging failed
-tests.  Run `ftests.py -h` to view the syntax.
-
-To generate a log file called foo.log at a debug level (8) run
-the following:
-
-        ./ftests.py -l 8 -L foo.log
diff --git a/tests/ftests/__init__.py b/tests/ftests/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/ftests/cgroup.py b/tests/ftests/cgroup.py
deleted file mode 100644 (file)
index c8bffa5..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-#
-# Cgroup class for the libcgroup functional tests
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-import consts
-import os
-from run import Run
-
-class Cgroup(object):
-    @staticmethod
-    def build_cmd_path(in_container, cmd):
-        if in_container:
-            return os.path.join(consts.LIBCG_MOUNT_POINT,
-                                'src/tools/{}'.format(cmd))
-        else:
-            return cmd
-
-    # TODO - add support for all of the cgcreate options
-    @staticmethod
-    def create(config, controller_list, cgname, in_container=True):
-        if isinstance(controller_list, str):
-            controller_list = [controller_list]
-
-        cmd = list()
-        cmd.append(Cgroup.build_cmd_path(in_container, 'cgcreate'))
-
-        controllers_and_path = '{}:{}'.format(
-            ','.join(controller_list), cgname)
-
-        cmd.append('-g')
-        cmd.append(controllers_and_path)
-
-        if in_container:
-            config.container.run(cmd)
-        else:
-            Run.run(cmd)
-
-    @staticmethod
-    def delete(config, controller_list, cgname, in_container=True, recursive=False):
-        if isinstance(controller_list, str):
-            controller_list = [controller_list]
-
-        cmd = list()
-        cmd.append(Cgroup.build_cmd_path(in_container, 'cgdelete'))
-
-        if recursive:
-            cmd.append('-r')
-
-        controllers_and_path = '{}:{}'.format(
-            ''.join(controller_list), cgname)
-
-        cmd.append('-g')
-        cmd.append(controllers_and_path)
-
-        if in_container:
-            config.container.run(cmd)
-        else:
-            Run.run(cmd)
-
-    @staticmethod
-    def set(config, cgname, setting, value, in_container=True):
-        cmd = list()
-        cmd.append(Cgroup.build_cmd_path(in_container, 'cgset'))
-
-        if isinstance(setting, str) and isinstance(value, str):
-            cmd.append('-r')
-            cmd.append('{}={}'.format(setting, value))
-        elif isinstance(setting, list) and isinstance(value, list):
-            if len(setting) != len(value):
-                raise ValueError('Settings list length must equal values list length')
-
-            for idx, stg in enumerate(setting):
-                cmd.append('-r')
-                cmd.append('{}={}'.format(stg, value[idx]))
-
-        cmd.append(cgname)
-
-        if in_container:
-            config.container.run(cmd)
-        else:
-            Run.run(cmd)
-
-    @staticmethod
-    # valid cpuset commands:
-    #     Read one setting:
-    #         cgget -r cpuset.cpus tomcpuset
-    #     Read two settings:
-    #         cgget -r cpuset.cpus -r cpuset.cpu_exclusive tomcpuset
-    #     Read one setting from two cgroups:
-    #         cgget -r cpuset.cpu_exclusive tomcgroup1 tomcgroup2
-    #     Read two settings from two cgroups:
-    #         cgget -r cpuset.cpu_exclusive -r cpuset.cpu_exclusive tomcgroup1 tomcgroup2
-    #
-    #     Read all of the settings in a cgroup
-    #         cgget -g cpuset tomcpuset
-    #     Read all of the settings in multiple controllers
-    #         cgget -g cpuset -g cpu -g memory tomcgroup
-    #     Read all of the settings from a cgroup at a specific path
-    #         cgget -g memory:tomcgroup/tomcgroup
-    def get(config, controller=None, cgname=None, setting=None,
-            in_container=True, print_headers=True, values_only=False,
-            all_controllers=False):
-        cmd = list()
-        cmd.append(Cgroup.build_cmd_path(in_container, 'cgget'))
-
-        if not print_headers:
-            cmd.append('-n')
-        if values_only:
-            cmd.append('-v')
-
-        if setting is not None:
-            if isinstance(setting, str):
-                # the user provided a simple string.  use it as is
-                cmd.append('-r')
-                cmd.append(setting)
-            elif isinstance(setting, list):
-                for sttng in setting:
-                    cmd.append('-r')
-                    cmd.append(sttng)
-            else:
-                raise ValueError('Unsupported setting value')
-
-        if controller is not None:
-            if isinstance(controller, str) and ':' in controller:
-                # the user provided a controller:cgroup.  use it as is
-                cmd.append('-g')
-                cmd.append(controller)
-            elif isinstance(controller, str):
-                # the user provided a controller only.  use it as is
-                cmd.append('-g')
-                cmd.append(controller)
-            elif isinstance(controller, list):
-                for ctrl in controller:
-                    cmd.append('-g')
-                    cmd.append(ctrl)
-            else:
-                raise ValueError('Unsupported controller value')
-
-        if all_controllers:
-            cmd.append('-a')
-
-        if cgname is not None:
-            if isinstance(cgname, str):
-                # use the string as is
-                cmd.append(cgname)
-            elif isinstance(cgname, list):
-                for cg in cgname:
-                    cmd.append(cg)
-
-        if in_container:
-            ret = config.container.run(cmd)
-        else:
-            ret = Run.run(cmd)
-
-        return ret
diff --git a/tests/ftests/config.py b/tests/ftests/config.py
deleted file mode 100644 (file)
index 5cdc21d..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Config class for the libcgroup functional tests
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-import consts
-from container import Container
-import os
-
-class Config(object):
-    def __init__(self, args, container=None):
-        self.args = args
-
-        if container:
-            self.container = container
-        else:
-            # Use the default container settings
-            self.container = Container(name=consts.DEFAULT_CONTAINER_NAME,
-                stop_timeout=args.timeout, arch=None,
-                distro=args.distro, release=args.release)
-
-        self.ftest_dir = os.path.dirname(os.path.abspath(__file__))
-        self.libcg_dir = os.path.dirname(self.ftest_dir)
-
-        self.test_suite = consts.TESTS_RUN_ALL_SUITES
-        self.test_num = consts.TESTS_RUN_ALL
-        self.verbose = False
-
-    def __str__(self):
-        out_str = "Configuration"
-        out_str += "\n\tcontainer = {}".format(self.container)
-
-        return out_str
-
-
-class ConfigError(Exception):
-    def __init__(self, message):
-        super(ConfigError, self).__init__(message)
-
-    def __str__(self):
-        out_str = "ConfigError:\n\tmessage = {}".format(self.message)
-        return out_str
diff --git a/tests/ftests/consts.py b/tests/ftests/consts.py
deleted file mode 100644 (file)
index f1621b4..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Constants for the libcgroup functional tests
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-import os
-
-DEFAULT_LOG_FILE = 'libcgroup-ftests.log'
-
-LOG_CRITICAL = 1
-LOG_WARNING = 5
-LOG_DEBUG = 8
-DEFAULT_LOG_LEVEL = 5
-
-ftest_dir = os.path.dirname(os.path.abspath(__file__))
-tests_dir = os.path.dirname(ftest_dir)
-LIBCG_MOUNT_POINT = os.path.dirname(tests_dir)
-
-DEFAULT_CONTAINER_NAME = 'TestLibcg'
-DEFAULT_CONTAINER_DISTRO = 'ubuntu'
-DEFAULT_CONTAINER_RELEASE = '18.04'
-DEFAULT_CONTAINER_ARCH = 'amd64'
-DEFAULT_CONTAINER_STOP_TIMEOUT = 5
-DEFAULT_CONTAINER_CFG_PATH=os.path.join(
-    os.path.dirname(os.path.abspath(__file__)),
-    'default.conf')
-TEMP_CONTAINER_CFG_FILE='tmp.conf'
-
-TESTS_RUN_ALL = -1
-TESTS_RUN_ALL_SUITES = "allsuites"
-TEST_PASSED = "passed"
-TEST_FAILED = "failed"
-TEST_SKIPPED = "skipped"
diff --git a/tests/ftests/container.py b/tests/ftests/container.py
deleted file mode 100644 (file)
index 948018e..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-#
-# Container class for the libcgroup functional tests
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-import consts
-import getpass
-from log import Log
-import os
-from run import Run
-
-class Container(object):
-    def __init__(self, name, stop_timeout=None, arch=None, cfg_path=None,
-                 distro=None, release=None):
-        self.name = name
-        self.privileged = True
-
-        if stop_timeout:
-            self.stop_timeout = stop_timeout
-        else:
-            self.stop_timeout = consts.DEFAULT_CONTAINER_STOP_TIMEOUT
-
-        if arch:
-            self.arch = arch
-        else:
-            self.arch = consts.DEFAULT_CONTAINER_ARCH
-
-        if distro:
-            self.distro = distro
-        else:
-            self.distro = consts.DEFAULT_CONTAINER_DISTRO
-
-        if release:
-            self.release = release
-        else:
-            self.release = consts.DEFAULT_CONTAINER_RELEASE
-
-        ftest_dir = os.path.dirname(os.path.abspath(__file__))
-        tests_dir = os.path.dirname(ftest_dir)
-        # save off the path to the libcgroup source code
-        self.libcg_dir = os.path.dirname(tests_dir)
-
-
-    def __str__(self):
-        out_str = "{}".format(self.name)
-        out_str += "\n\tdistro = {}".format(self.distro)
-        out_str += "\n\trelease = {}".format(self.release)
-        out_str += "\n\tarch = {}".format(self.arch)
-        out_str += "\n\tstop_timeout = {}".format(self.stop_timeout)
-
-        return out_str
-
-    # configure the container to meet our needs
-    def config(self):
-        ftest_dir = os.path.dirname(os.path.abspath(__file__))
-        tests_dir = os.path.dirname(ftest_dir)
-        libcg_dir = os.path.dirname(tests_dir)
-
-        # map our UID and GID to the same UID/GID in the container
-        cmd = 'printf "uid {} 1000\ngid {} 1000" | sudo lxc config set {} raw.idmap -'.format(
-              os.getuid(), os.getgid(), self.name)
-        Run.run(cmd, shell_bool=True)
-
-        # add the libcgroup root directory (where we did the build) into
-        # the container
-        cmd2 = list()
-        if self.privileged:
-            cmd2.append('sudo')
-        cmd2.append('lxc')
-        cmd2.append('config')
-        cmd2.append('device')
-        cmd2.append('add')
-        cmd2.append(self.name)
-        cmd2.append('libcgsrc') # arbitrary name of device
-        cmd2.append('disk')
-        # to appease gcov, mount the libcgroup source at the same path as we
-        # built it.  This can be worked around someday by using
-        # GCOV_PREFIX_STRIP, but that was more difficult to setup than just
-        # doing this initially
-        cmd2.append('source={}'.format(self.libcg_dir))
-        cmd2.append('path={}'.format(self.libcg_dir))
-
-        return Run.run(cmd2)
-
-    def create(self):
-        cmd = list()
-
-        if self.privileged:
-            cmd.append('sudo')
-
-        cmd.append('lxc')
-        cmd.append('init')
-
-        cmd.append('{}:{}'.format(self.distro, self.release))
-
-        cmd.append(self.name)
-
-        return Run.run(cmd)
-
-    def delete(self):
-        cmd = list()
-
-        if self.privileged:
-            cmd.append('sudo')
-
-        cmd.append('lxc')
-        cmd.append('delete')
-
-        cmd.append(self.name)
-
-        return Run.run(cmd)
-
-    def run(self, cntnr_cmd):
-        cmd = list()
-
-        if self.privileged:
-            cmd.append('sudo')
-
-        cmd.append('lxc')
-        cmd.append('exec')
-
-        cmd.append(self.name)
-
-        cmd.append('--')
-
-        # concatenate the lxc exec command with the command to be run
-        # inside the container
-        if isinstance(cntnr_cmd, str):
-            cmd.append(cntnr_cmd)
-        elif isinstance(cntnr_cmd, list):
-            cmd = cmd + cntnr_cmd
-        else:
-            raise ContainerError('Unsupported command type')
-
-        return Run.run(cmd).decode('ascii')
-
-    def start(self):
-        cmd = list()
-
-        if self.privileged:
-            cmd.append('sudo')
-
-        cmd.append('lxc')
-        cmd.append('start')
-
-        cmd.append(self.name)
-
-        return Run.run(cmd)
-
-    def stop(self, force=True):
-        cmd = list()
-
-        if self.privileged:
-            cmd.append('sudo')
-
-        cmd.append('lxc')
-        cmd.append('stop')
-
-        cmd.append(self.name)
-
-        if force:
-            cmd.append('-f')
-        else:
-            cmd.append('--timeout')
-            cmd.append(str(self.stop_timeout))
-
-        return Run.run(cmd)
-
-class ContainerError(Exception):
-    def __init__(self, message, ret):
-        super(RunError, self).__init__(message)
-
-    def __str__(self):
-        out_str = "ContainerError:\n\tmessage = {}".format(self.message)
-        return out_str
diff --git a/tests/ftests/default.conf b/tests/ftests/default.conf
deleted file mode 100644 (file)
index 12dd826..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# Template used to create this container: /usr/share/lxc/templates/lxc-download
-#
-# Default lxc configuration file for libcgroup functional tests
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-# Distribution configuration
-lxc.include = /usr/share/lxc/config/common.conf
-lxc.include = /usr/share/lxc/config/userns.conf
-
-# Container specific configuration
-lxc.include = /etc/lxc/default.conf
diff --git a/tests/ftests/ftests.py b/tests/ftests/ftests.py
deleted file mode 100755 (executable)
index 54eb658..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-#!/usr/bin/env python3
-#
-# Main entry point for the libcgroup functional tests
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-import argparse
-from cgroup import Cgroup
-from config import Config
-import consts
-import container
-import datetime
-import log
-from log import Log
-import os
-from run import Run
-import sys
-import time
-
-setup_time = 0.0
-teardown_time = 0.0
-
-def parse_args():
-    parser = argparse.ArgumentParser("Libcgroup Functional Tests")
-    parser.add_argument('-n', '--name',
-                        help='name of the container',
-                        required=False, type=str, default=None)
-    parser.add_argument('-d', '--distro',
-                        help='linux distribution to use as a template',
-                        required=False, type=str, default=None)
-    parser.add_argument('-r', '--release',
-                        help='distribution release, e.g.\'trusty\'',
-                        required=False, type=str, default=None)
-    parser.add_argument('-a', '--arch',
-                        help='processor architecture',
-                        required=False, type=str, default=None)
-    parser.add_argument('-t', '--timeout',
-                        help='wait timeout (sec) before stopping the container',
-                        required=False, type=int, default=None)
-
-    parser.add_argument('-l', '--loglevel',
-                        help='log level',
-                        required=False, type=int, default=None)
-    parser.add_argument('-L', '--logfile',
-                        help='log file',
-                        required=False, type=str, default=None)
-
-    parser.add_argument('-N', '--num',
-                        help='Test number to run.  If unspecified, all tests are run',
-                        required=False, default=consts.TESTS_RUN_ALL, type=int)
-    parser.add_argument('-s', '--suite',
-                        help='Test suite to run, e.g. cpuset', required=False,
-                        default=consts.TESTS_RUN_ALL_SUITES, type=str)
-    parser.add_argument('-v', '--verbose',
-                        help='Print all information about this test run',
-                        default=True, required=False, action="store_false")
-
-    config = Config(parser.parse_args())
-
-    if config.args.loglevel:
-        log.log_level = config.args.loglevel
-    if config.args.logfile:
-        log.log_file = config.args.logfile
-
-    return config
-
-# this function maps the container UID to the host UID.  By doing
-# this, we can write to a bind-mounted device - and thus generate
-# code coverage data in the LXD container
-def update_host_subuid():
-    subuid_line1 = 'lxd:{}:1'.format(os.getuid())
-    subuid_line2 = 'root:{}:1'.format(os.getuid())
-    found_line1 = False
-    found_line2 = False
-
-    with open('/etc/subuid') as ufile:
-        for line in ufile.readlines():
-            if line.strip() == subuid_line1:
-                found_line1 = True
-            elif line.strip() == subuid_line2:
-                found_line2 = True
-
-    if not found_line1:
-        Run.run('sudo sh -c "echo {} >> /etc/subuid"'.format(
-                subuid_line1), shell_bool=True)
-    if not found_line2:
-        Run.run('sudo sh -c "echo {} >> /etc/subuid"'.format(
-                subuid_line2), shell_bool=True)
-
-# this function maps the container GID to the host GID.  By doing
-# this, we can write to a bind-mounted device - and thus generate
-# code coverage data in the LXD container
-def update_host_subgid():
-    subgid_line1 = 'lxd:{}:1'.format(os.getgid())
-    subgid_line2 = 'root:{}:1'.format(os.getgid())
-    found_line1 = False
-    found_line2 = False
-
-    with open('/etc/subgid') as ufile:
-        for line in ufile.readlines():
-            if line.strip() == subgid_line1:
-                found_line1 = True
-            elif line.strip() == subgid_line2:
-                found_line2 = True
-
-    if not found_line1:
-        Run.run('sudo sh -c "echo {} >> /etc/subgid"'.format(
-                subgid_line1), shell_bool=True)
-    if not found_line2:
-        Run.run('sudo sh -c "echo {} >> /etc/subgid"'.format(
-                subgid_line2), shell_bool=True)
-
-def setup(config, do_teardown=True, record_time=False):
-    global setup_time
-    start_time = time.time()
-    if do_teardown:
-        # belt and suspenders here.  In case a previous run wasn't properly
-        # cleaned up, let's try and clean it up here
-        try:
-            teardown(config)
-        except Exception as e:
-            # log but ignore all exceptions
-            Log.log_debug(e)
-
-    # this command initializes the lxd storage, networking, etc.
-    Run.run(['sudo', 'lxd', 'init', '--auto'])
-    update_host_subuid()
-    update_host_subgid()
-
-    config.container.create()
-    config.container.config()
-    config.container.start()
-
-    # add the libcgroup library to the container's ld
-    echo_cmd = ['bash', '-c', 'echo {} >> /etc/ld.so.conf.d/libcgroup.conf'.format(
-               os.path.join(consts.LIBCG_MOUNT_POINT, 'src/.libs'))]
-    config.container.run(echo_cmd)
-    config.container.run('ldconfig')
-    if record_time:
-        setup_time = time.time() - start_time
-
-def run_tests(config):
-    passed_tests = []
-    failed_tests = []
-    skipped_tests = []
-
-    for root, dirs, filenames in os.walk(config.ftest_dir):
-        for filename in filenames:
-            if os.path.splitext(filename)[-1] != ".py":
-                # ignore non-python files
-                continue
-
-            filenum = filename.split('-')[0]
-
-            try:
-                filenum_int = int(filenum)
-            except ValueError:
-                # D'oh.  This file must not be a test.  Skip it
-                Log.log_debug('Skipping {}.  It doesn\'t start with an int'.format(
-                              filename))
-                continue
-
-            try:
-                filesuite = filename.split('-')[1]
-            except IndexError:
-                Log.log_error(
-                    'Skipping {}.  It doesn\'t conform to the filename format'.format(
-                    filename))
-                continue
-
-            if config.args.suite == consts.TESTS_RUN_ALL_SUITES or \
-               config.args.suite == filesuite:
-                if config.args.num == consts.TESTS_RUN_ALL or \
-                   config.args.num == filenum_int:
-                    test = __import__(os.path.splitext(filename)[0])
-
-                    failure_cause = None
-                    start_time = time.time()
-                    try:
-                        Log.log_debug('Running test {}.'.format(filename))
-                        [ret, failure_cause] = test.main(config)
-                    except Exception as e:
-                        # catch all exceptions.  you never know when there's
-                        # a crummy test
-                        failure_cause = e
-                        Log.log_debug(e)
-                        ret = consts.TEST_FAILED
-
-                        # if the test does cause an exception, it may not have
-                        # cleaned up after itself.  re-create the container
-                        teardown(config)
-                        setup(config, do_teardown=False)
-                    finally:
-                        run_time = time.time() - start_time
-                        if ret == consts.TEST_PASSED:
-                            passed_tests.append([filename, run_time])
-                        elif ret == consts.TEST_FAILED:
-                            failed_tests.append([filename, run_time])
-                        elif ret == consts.TEST_SKIPPED:
-                            skipped_tests.append([filename, run_time])
-                        else:
-                            raise ValueException('Unexpected ret: {}'.format(ret))
-
-    passed_cnt = len(passed_tests)
-    failed_cnt = len(failed_tests)
-    skipped_cnt = len(skipped_tests)
-
-    print("-----------------------------------------------------------------")
-    print("Test Results:")
-    date_str = datetime.datetime.now().strftime('%b %d %H:%M:%S')
-    print('\t{}{}'.format('{0: <30}'.format("Run Date:"), '{0: >15}'.format(date_str)))
-
-    test_str = "{} test(s)".format(passed_cnt)
-    print('\t{}{}'.format('{0: <30}'.format("Passed:"), '{0: >15}'.format(test_str)))
-
-    test_str = "{} test(s)".format(skipped_cnt)
-    print('\t{}{}'.format('{0: <30}'.format("Skipped:"), '{0: >15}'.format(test_str)))
-
-    test_str = "{} test(s)".format(failed_cnt)
-    print('\t{}{}'.format('{0: <30}'.format("Failed:"), '{0: >15}'.format(test_str)))
-
-    for test in failed_tests:
-        print("\t\tTest:\t\t\t\t{} - {}".format(test[0], str(failure_cause)))
-    print("-----------------------------------------------------------------")
-
-    global setup_time
-    global teardown_time
-    if config.args.verbose:
-        print("Timing Results:")
-        print('\t{}{}'.format('{0: <30}'.format("Test"), '{0: >15}'.format("Time (sec)")))
-        print("\t---------------------------------------------------------")
-        time_str = "{0: 2.2f}".format(setup_time)
-        print('\t{}{}'.format('{0: <30}'.format('setup'), '{0: >15}'.format(time_str)))
-        for test in passed_tests:
-            time_str = "{0: 2.2f}".format(test[1])
-            print('\t{}{}'.format('{0: <30}'.format(test[0]), '{0: >15}'.format(time_str)))
-        for test in failed_tests:
-            time_str = "{0: 2.2f}".format(test[1])
-            print('\t{}{}'.format('{0: <30}'.format(test[0]), '{0: >15}'.format(time_str)))
-        time_str = "{0: 2.2f}".format(teardown_time)
-        print('\t{}{}'.format('{0: <30}'.format('teardown'), '{0: >15}'.format(time_str)))
-
-        total_run_time = setup_time + teardown_time
-        for test in passed_tests:
-            total_run_time += test[1]
-        for test in failed_tests:
-            total_run_time += test[1]
-        total_str = "{0: 5.2f}".format(total_run_time)
-        print("\t---------------------------------------------------------")
-        print('\t{}{}'.format('{0: <30}'.format("Total Run Time"), '{0: >15}'.format(total_str)))
-
-    return [passed_cnt, failed_cnt, skipped_cnt]
-
-def teardown(config, record_time=False):
-    global teardown_time
-    start_time = time.time()
-    try:
-        config.container.stop()
-    except Exception as e:
-        # log but ignore all exceptions
-        Log.log_debug(e)
-    try:
-        config.container.delete()
-    except Exception as e:
-        # log but ignore all exceptions
-        Log.log_debug(e)
-
-    if record_time:
-        teardown_time = time.time() - start_time
-
-def main(config):
-    AUTOMAKE_SKIPPED = 77
-    AUTOMAKE_HARD_ERROR = 99
-    AUTOMAKE_PASSED = 0
-
-    try:
-        setup(config, record_time=True)
-        [passed_cnt, failed_cnt, skipped_cnt] = run_tests(config)
-    finally:
-        teardown(config, record_time=True)
-
-    if failed_cnt > 0:
-        return failed_cnt
-    if skipped_cnt > 0:
-        return AUTOMAKE_SKIPPED
-    if passed_cnt > 0:
-        return AUTOMAKE_PASSED
-
-    return AUTOMAKE_HARD_ERROR
-
-if __name__ == '__main__':
-    config = parse_args()
-    sys.exit(main(config))
diff --git a/tests/ftests/log.py b/tests/ftests/log.py
deleted file mode 100644 (file)
index 2b10d85..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Log class for the libcgroup functional tests
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-import consts
-import datetime
-import log
-
-log_level = consts.DEFAULT_LOG_LEVEL
-log_file = consts.DEFAULT_LOG_FILE
-log_fd = None
-
-
-class Log(object):
-
-    @staticmethod
-    def log(msg, msg_level=consts.DEFAULT_LOG_LEVEL):
-        if log_level >= msg_level:
-            if log.log_fd is None:
-                Log.open_logfd(log.log_file)
-
-            timestamp = datetime.datetime.now().strftime('%b %d %H:%M:%S')
-            log_fd.write("{}: {}\n".format(timestamp, msg))
-
-    @staticmethod
-    def open_logfd(log_file):
-        log.log_fd = open(log_file, "a")
-
-    @staticmethod
-    def log_critical(msg):
-        Log.log("CRITICAL: {}".format(msg), consts.LOG_CRITICAL)
-
-    @staticmethod
-    def log_warning(msg):
-        Log.log("WARNING: {}".format(msg), consts.LOG_WARNING)
-
-    @staticmethod
-    def log_debug(msg):
-        Log.log("DEBUG: {}".format(msg), consts.LOG_DEBUG)
diff --git a/tests/ftests/run.py b/tests/ftests/run.py
deleted file mode 100644 (file)
index 419f38f..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# Run class for the libcgroup functional tests
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-from log import Log
-import subprocess
-import time
-
-class Run(object):
-    @staticmethod
-    def run(command, shell_bool=False):
-        if shell_bool:
-            if isinstance(command, str):
-                # nothing to do.  command is already formatted as a string
-                pass
-            elif isinstance(command, list):
-                command = ' '.join(command)
-            else:
-                raise ValueError('Unsupported command type')
-
-        subproc = subprocess.Popen(command, shell=shell_bool,
-                                   stdout=subprocess.PIPE,
-                                   stderr=subprocess.PIPE)
-        out, err = subproc.communicate()
-        ret = subproc.returncode
-
-        out = out.strip()
-        err = err.strip()
-
-        if shell_bool:
-            Log.log_debug(
-                "run:\n\tcommand = {}\n\tret = {}\n\tstdout = {}\n\tstderr = {}".format(
-                command, ret, out, err))
-        else:
-            Log.log_debug(
-                "run:\n\tcommand = {}\n\tret = {}\n\tstdout = {}\n\tstderr = {}".format(
-                ' '.join(command), ret, out, err))
-
-        if ret != 0:
-            raise RunError("Command '{}' failed".format(''.join(command)),
-                           command, ret, out, err)
-
-        return out
-
-class RunError(Exception):
-    def __init__(self, message, command, ret, stdout, stderr):
-        super(RunError, self).__init__(message)
-
-        self.command = command
-        self.ret = ret
-        self.stdout = stdout
-        self.stderr = stderr
-
-    def __str__(self):
-        out_str = "RunError:\n\tcommand = {}\n\tret = {}".format(
-                  self.command, self.ret)
-        out_str += "\n\tstdout = {}\n\tstderr = {}".format(self.stdout, self.stderr)
-        return out_str
diff --git a/tests/get_all_controller.c b/tests/get_all_controller.c
deleted file mode 100644 (file)
index d643c98..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <libcgroup.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int main()
-{
-       int error;
-       void *handle;
-       struct controller_data info;
-
-       error = cgroup_init();
-
-       if (error) {
-               printf("cgroup_init failed with %s\n", cgroup_strerror(error));
-               exit(1);
-       }
-
-       error = cgroup_get_all_controller_begin(&handle, &info);
-
-       while (error != ECGEOF) {
-               printf("Controller %10s %5d %5d %5d\n", info.name,
-                       info.hierarchy, info.num_cgroups, info.enabled);
-               error = cgroup_get_all_controller_next(&handle, &info);
-               if (error && error != ECGEOF) {
-                       printf("cgroup_get_controller_next failed with %s\n",
-                                                       cgroup_strerror(error));
-                       exit(1);
-               }
-       }
-
-       error = cgroup_get_all_controller_end(&handle);
-
-       return 0;
-}
diff --git a/tests/get_controller.c b/tests/get_controller.c
deleted file mode 100644 (file)
index 1829f5c..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <libcgroup.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int main()
-{
-       int error;
-       void *handle;
-       struct cgroup_mount_point info;
-
-       error = cgroup_init();
-
-       if (error) {
-               printf("cgroup_init failed with %s\n", cgroup_strerror(error));
-               exit(1);
-       }
-
-       error = cgroup_get_controller_begin(&handle, &info);
-
-       while (error != ECGEOF) {
-               printf("Controller %s is mounted at %s\n", info.name,
-                                                               info.path);
-               error = cgroup_get_controller_next(&handle, &info);
-               if (error && error != ECGEOF) {
-                       printf("cgroup_get_contrller_next failed with %s",
-                                                       cgroup_strerror(error));
-                       exit(1);
-               }
-       }
-
-       error = cgroup_get_controller_end(&handle);
-
-       return 0;
-}
diff --git a/tests/get_mount_point.c b/tests/get_mount_point.c
deleted file mode 100644 (file)
index b372092..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <libcgroup.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-int main()
-{
-       int ret;
-       char *mount_point;
-       char string[100];
-
-       strcpy(string, "cpu");
-
-       ret = cgroup_init();
-       if (ret) {
-               printf("cgroup_init failed with %s\n", cgroup_strerror(ret));
-               exit(3);
-       }
-
-       ret = cgroup_get_subsys_mount_point(string, &mount_point);
-       if (ret) {
-               printf("get_mount_point failed with %s\n",
-                                       cgroup_strerror(ret));
-               exit(3);
-       }
-
-       printf("The mount point is %s\n", mount_point);
-       free(mount_point);
-
-       strcpy(string, "obviouslynonexistsubsys");
-
-       ret = cgroup_get_subsys_mount_point(string, &mount_point);
-
-       if (!ret) {
-               printf("get_mount_point failed as it got a "
-                                       "non existant subsys\n");
-               exit(3);
-       }
-
-       if (ret == ECGROUPNOTEXIST) {
-               printf("get_mount_point worked as expected\n");
-               return 0;
-       }
-
-       printf("get_mount_point failed with %s\n", cgroup_strerror(ret));
-
-       return 3;
-}
diff --git a/tests/get_procs.c b/tests/get_procs.c
deleted file mode 100644 (file)
index caa8444..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <stdio.h>
-#include <libcgroup.h>
-#include <stdlib.h>
-
-/*
- * Assumes the cgroup is already mounted at /cgroup/memory/a
- *
- * Assumes some processes are already in the cgroup
- *
- * Assumes it is the memory controller is mounted in at that
- * point
- */
-int main()
-{
-       int size;
-       pid_t *pids;
-       int ret;
-       int i;
-
-       ret = cgroup_init();
-       if (ret) {
-               printf("FAIL: cgroup_init failed with %s\n", cgroup_strerror(ret));
-               exit(3);
-       }
-
-       ret = cgroup_get_procs("a", "memory", &pids, &size);
-       if (ret) {
-               printf("FAIL: cgroup_get_procs failed with %s\n", cgroup_strerror(ret));
-               exit(3);
-       }
-
-       for (i = 0; i < size; i++)
-               printf("%u\n", pids[i]);
-
-       return 0;
-}
diff --git a/tests/get_variable_names.c b/tests/get_variable_names.c
deleted file mode 100644 (file)
index dc2ef14..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <libcgroup.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "../src/libcgroup-internal.h"
-
-int main(int argc, char *argv[])
-{
-       int ret;
-       int i, j;
-       int count;
-       char *name;
-       struct cgroup_controller *group_controller = NULL;
-       struct cgroup *group = NULL;
-       char group_name[] = "/";
-
-       if (argc < 2) {
-               printf("no list of groups provided\n");
-               return -1;
-       }
-
-       ret = cgroup_init();
-
-       if (ret) {
-               printf("cgroup_init failed with %s\n", cgroup_strerror(ret));
-               exit(1);
-       }
-
-       group = cgroup_new_cgroup(group_name);
-       if (group == NULL) {
-               printf("cannot create group '%s'\n", group_name);
-               return -1;
-       }
-
-       ret = cgroup_get_cgroup(group);
-       if (ret != 0) {
-               printf("cannot read group '%s': %s\n",
-                       group_name, cgroup_strerror(ret));
-       }
-
-       for (i = 1; i < argc; i++) {
-
-               group_controller = cgroup_get_controller(group, argv[i]);
-               if (group_controller == NULL) {
-                       printf("cannot find controller "\
-                           "'%s' in group '%s'\n", argv[i], group_name);
-                       ret = -1;
-                       continue;
-               }
-               count = cgroup_get_value_name_count(group_controller);
-               for (j = 0; j < count; j++) {
-                       name = cgroup_get_value_name(group_controller, j);
-                       if (name != NULL)
-                               printf("%s \n", name);
-               }
-       }
-
-       return ret;
-}
diff --git a/tests/gunit/.gitignore b/tests/gunit/.gitignore
deleted file mode 100644 (file)
index 3308721..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-*.log
-*.o
-*.trs
-
-gtest
-libgtest.la
diff --git a/tests/gunit/001-path.cpp b/tests/gunit/001-path.cpp
deleted file mode 100644 (file)
index a0e3c86..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * libcgroup googletest for cg_build_path()
- *
- * Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
- * Author: Tom Hromatka <tom.hromatka@oracle.com>
- */
-
-/*
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License as
- * published by the Free Software Foundation.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "gtest/gtest.h"
-
-#include "libcgroup-internal.h"
-
-class BuildPathV1Test : public ::testing::Test {
-       protected:
-
-       /**
-        * Setup this test case
-        *
-        * This test case calls cg_build_path() to generate various
-        * cgroup paths.  The SetUp() routine creates a simple mount
-        * table that can be used to verify cg_build_path() behavior.
-        *
-        * cg_mount_table for this test is as follows:
-        *      name            mount_point                     index
-        *      -----------------------------------------------------
-        *      controller0     /sys/fs/cgroup/controller0      0
-        *      controller1     /sys/fs/cgroup/controller1      1
-        *      controller2     /sys/fs/cgroup/controller2      2
-        *      controller3     /sys/fs/cgroup/controller3      3
-        *      controller4     /sys/fs/cgroup/controller4      4
-        *      controller5     /sys/fs/cgroup/controller5      5
-        *
-        * Note that controllers 1 and 5 are also given namespaces
-        */
-       void SetUp() override {
-               char NAMESPACE1[] = "ns1";
-               char NAMESPACE5[] = "ns5";
-               const int ENTRY_CNT = 6;
-               int i;
-
-               memset(&cg_mount_table, 0, sizeof(cg_mount_table));
-               memset(cg_namespace_table, 0,
-                       CG_CONTROLLER_MAX * sizeof(cg_namespace_table[0]));
-
-               // Populate the mount table
-               for (i = 0; i < ENTRY_CNT; i++) {
-                       snprintf(cg_mount_table[i].name, FILENAME_MAX,
-                                "controller%d", i);
-                       cg_mount_table[i].index = i;
-
-                       snprintf(cg_mount_table[i].mount.path, FILENAME_MAX,
-                                "/sys/fs/cgroup/%s", cg_mount_table[i].name);
-                       cg_mount_table[i].mount.next = NULL;
-               }
-
-               // Give a couple of the entries a namespace as well
-               cg_namespace_table[1] = NAMESPACE1;
-               cg_namespace_table[5] = NAMESPACE5;
-       }
-};
-
-/**
- * No matching controller test
- * @param BuildPathV1Test googletest test case name
- * @param BuildPathV1_ControllerMismatch test name
- *
- * This test will walk through the entire controller mount table
- * and fail to find a match.
- * https://github.com/libcgroup/libcgroup/blob/62f76650db84c0a25f76ece3a79d9d16a1e9f931/src/api.c#L1300
- */
-TEST_F(BuildPathV1Test, BuildPathV1_ControllerMismatch)
-{
-       char *name = NULL;
-       char path[FILENAME_MAX];
-       /* type intentionally _does not_ match any controllers */
-       char type[] = "FOO";
-       char *out;
-
-       out = cg_build_path(name, path, type);
-       ASSERT_STREQ(out, NULL);
-}
-
-/**
- * Matching controller test
- * @param BuildPathV1Test googletest test case name
- * @param BuildPathV1_ControllerMatch test name
- *
- * This test finds a matching controller in the mount table.  Both the
- * namespace and the cgroup name are NULL.
- */
-TEST_F(BuildPathV1Test, BuildPathV1_ControllerMatch)
-{
-       char *name = NULL;
-       char path[FILENAME_MAX];
-       char type[] = "controller0";
-       char *out;
-
-       out = cg_build_path(name, path, type);
-       ASSERT_STREQ(out, "/sys/fs/cgroup/controller0/");
-}
-
-/**
- * Matching controller test with a cgroup name
- * @param BuildPathV1Test googletest test case name
- * @param BuildPathV1_ControllerMatchWithName test name
- *
- * This test finds a matching controller in the mount table.  The
- * namespace is NULL, but a valid cgroup name is provided.  This
- * exercises the `if (name)` statement
- * https://github.com/libcgroup/libcgroup/blob/62f76650db84c0a25f76ece3a79d9d16a1e9f931/src/api.c#L1289
- */
-TEST_F(BuildPathV1Test, BuildPathV1_ControllerMatchWithName)
-{
-       char name[] = "TomsCgroup1";
-       char path[FILENAME_MAX];
-       char type[] = "controller3";
-       char *out;
-
-       out = cg_build_path(name, path, type);
-       ASSERT_STREQ(out, "/sys/fs/cgroup/controller3/TomsCgroup1/");
-}
-
-/**
- * Matching controller test with a namespace
- * @param BuildPathV1Test googletest test case name
- * @param BuildPathV1_ControllerMatchWithNs test name
- *
- * This test finds a matching controller in the mount table.  The
- * namespace is valid, but the cgroup name is NULL.  This exercises
- * exercises the `if (cg_namespace_table[i])` statement
- * https://github.com/libcgroup/libcgroup/blob/62f76650db84c0a25f76ece3a79d9d16a1e9f931/src/api.c#L1278
- */
-TEST_F(BuildPathV1Test, BuildPathV1_ControllerMatchWithNs)
-{
-       char *name = NULL;
-       char path[FILENAME_MAX];
-       char type[] = "controller1";
-       char *out;
-
-       out = cg_build_path(name, path, type);
-       ASSERT_STREQ(out, "/sys/fs/cgroup/controller1/ns1/");
-}
-
-/**
- * Matching controller test with a namespace and a cgroup name
- * @param BuildPathV1Test googletest test case name
- * @param BuildPathV1_ControllerMatchWithNameAndNs test name
- *
- * This test finds a matching controller in the mount table.  Both the
- * namespace and the cgroup name are valid.  This exercises both if
- * statements in cg_build_path_locked().
- */
-TEST_F(BuildPathV1Test, BuildPathV1_ControllerMatchWithNameAndNs)
-{
-       char name[] = "TomsCgroup2";
-       char path[FILENAME_MAX];
-       char type[] = "controller5";
-       char *out;
-
-       out = cg_build_path(name, path, type);
-       ASSERT_STREQ(out, "/sys/fs/cgroup/controller5/ns5/TomsCgroup2/");
-}
diff --git a/tests/gunit/002-cgroup_parse_rules_options.cpp b/tests/gunit/002-cgroup_parse_rules_options.cpp
deleted file mode 100644 (file)
index b9ec477..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * libcgroup googletest for cgroup_parse_rules_options()
- *
- * Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
- * Author: Tom Hromatka <tom.hromatka@oracle.com>
- */
-
-/*
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License as
- * published by the Free Software Foundation.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "gtest/gtest.h"
-
-#include "libcgroup-internal.h"
-
-class ParseRulesOptionsTest : public ::testing::Test {
-};
-
-TEST_F(ParseRulesOptionsTest, RulesOptions_Ignore)
-{
-       struct cgroup_rule rule;
-       char options[] = "ignore";
-       int ret;
-
-       rule.is_ignore = false;
-
-       ret = cgroup_parse_rules_options(options, &rule);
-       ASSERT_EQ(ret, 0);
-       ASSERT_EQ(rule.is_ignore, true);
-}
-
-TEST_F(ParseRulesOptionsTest, RulesOptions_IgnoreWithComma)
-{
-       struct cgroup_rule rule;
-       char options[] = "ignore,";
-       int ret;
-
-       rule.is_ignore = false;
-
-       ret = cgroup_parse_rules_options(options, &rule);
-       ASSERT_EQ(ret, 0);
-       ASSERT_EQ(rule.is_ignore, true);
-}
-
-TEST_F(ParseRulesOptionsTest, RulesOptions_InvalidOption)
-{
-       struct cgroup_rule rule;
-       char options[] = "ignoretypo";
-       int ret;
-
-       rule.is_ignore = false;
-
-       ret = cgroup_parse_rules_options(options, &rule);
-       ASSERT_EQ(ret, -EINVAL);
-       ASSERT_EQ(rule.is_ignore, false);
-}
-
-TEST_F(ParseRulesOptionsTest, RulesOptions_InvalidOption2)
-{
-       struct cgroup_rule rule;
-       char options[] = "ignore,foobar";
-       int ret;
-
-       rule.is_ignore = false;
-
-       ret = cgroup_parse_rules_options(options, &rule);
-       ASSERT_EQ(ret, -EINVAL);
-       ASSERT_EQ(rule.is_ignore, true);
-}
-
-TEST_F(ParseRulesOptionsTest, RulesOptions_EmptyOptions)
-{
-       struct cgroup_rule rule;
-       char options[] = "";
-       int ret;
-
-       rule.is_ignore = false;
-
-       ret = cgroup_parse_rules_options(options, &rule);
-       ASSERT_EQ(ret, -EINVAL);
-       ASSERT_EQ(rule.is_ignore, false);
-}
-
-TEST_F(ParseRulesOptionsTest, RulesOptions_NullOptions)
-{
-       struct cgroup_rule rule;
-       char *options = NULL;
-       int ret;
-
-       rule.is_ignore = false;
-
-       ret = cgroup_parse_rules_options(options, &rule);
-       ASSERT_EQ(ret, -EINVAL);
-       ASSERT_EQ(rule.is_ignore, false);
-}
diff --git a/tests/gunit/003-cg_get_cgroups_from_proc_cgroups.cpp b/tests/gunit/003-cg_get_cgroups_from_proc_cgroups.cpp
deleted file mode 100644 (file)
index 0b4d289..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * libcgroup googletest for cg_get_cgroups_from_proc_cgroups()
- *
- * Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
- * Author: Tom Hromatka <tom.hromatka@oracle.com>
- */
-
-/*
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License as
- * published by the Free Software Foundation.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "gtest/gtest.h"
-
-#include "libcgroup-internal.h"
-
-class GetCgroupsFromProcCgroupsTest : public ::testing::Test {
-};
-
-static void CreateCgroupProcFile(const char * const contents)
-{
-       FILE *f;
-
-       f = fopen(TEST_PROC_PID_CGROUP_FILE, "w");
-       ASSERT_NE(f, nullptr);
-
-       fprintf(f, "%s", contents);
-       fclose(f);
-}
-
-
-TEST_F(GetCgroupsFromProcCgroupsTest, ReadSingleLine)
-{
-#undef LIST_LEN
-#define LIST_LEN 3
-       char contents[] =
-               "5:pids:/user.slice/user-1000.slice/session-1.scope\n";
-       char *controller_list[LIST_LEN];
-       char *cgroup_list[LIST_LEN];
-       pid_t pid = 1234;
-       int ret, i;
-
-       for (i = 0; i < LIST_LEN; i++) {
-               controller_list[i] = NULL;
-               cgroup_list[i] = NULL;
-       }
-
-       CreateCgroupProcFile(contents);
-
-       ret = cg_get_cgroups_from_proc_cgroups(pid, cgroup_list,
-                       controller_list, LIST_LEN);
-       ASSERT_EQ(ret, 0);
-       ASSERT_STREQ(controller_list[0], "pids");
-       ASSERT_STREQ(cgroup_list[0],
-                    "user.slice/user-1000.slice/session-1.scope");
-}
-
-TEST_F(GetCgroupsFromProcCgroupsTest, ReadSingleLine2)
-{
-#undef LIST_LEN
-#define LIST_LEN 1
-       char contents[] =
-               "5:cpu,cpuacct:/\n";
-       char *controller_list[LIST_LEN];
-       char *cgroup_list[LIST_LEN];
-       pid_t pid = 1234;
-       int ret, i;
-
-       for (i = 0; i < LIST_LEN; i++) {
-               controller_list[i] = NULL;
-               cgroup_list[i] = NULL;
-       }
-
-       CreateCgroupProcFile(contents);
-
-       ret = cg_get_cgroups_from_proc_cgroups(pid, cgroup_list,
-                       controller_list, LIST_LEN);
-       ASSERT_EQ(ret, 0);
-       ASSERT_STREQ(controller_list[0], "cpu,cpuacct");
-       ASSERT_STREQ(cgroup_list[0], "/");
-}
-
-TEST_F(GetCgroupsFromProcCgroupsTest, ReadEmptyController)
-{
-#undef LIST_LEN
-#define LIST_LEN 1
-       char contents[] =
-               "0::/user.slice/user-1000.slice/session-1.scope\n";
-       char *controller_list[LIST_LEN];
-       char *cgroup_list[LIST_LEN];
-       pid_t pid = 1234;
-       int ret, i;
-
-       for (i = 0; i < LIST_LEN; i++) {
-               controller_list[i] = NULL;
-               cgroup_list[i] = NULL;
-       }
-
-       CreateCgroupProcFile(contents);
-
-       ret = cg_get_cgroups_from_proc_cgroups(pid, cgroup_list,
-                       controller_list, LIST_LEN);
-       ASSERT_EQ(ret, 0);
-       ASSERT_EQ(controller_list[0], nullptr);
-       ASSERT_EQ(cgroup_list[0], nullptr);
-}
-
-TEST_F(GetCgroupsFromProcCgroupsTest, ReadExampleFile)
-{
-       char contents[] =
-               "12:memory:/user/johndoe/0\n"
-               "11:perf_event:/\n"
-               "10:rdma:/\n"
-               "9:blkio:/user.slice\n"
-               "8:cpu,cpuacct:/myCgroup\n"
-               "7:freezer:/user/johndoe/0\n"
-               "6:net_cls,net_prio:/\n"
-               "5:pids:/user.slice/user-1000.slice/session-1.scope\n"
-               "4:devices:/user.slice\n"
-               "3:cpuset:/\n"
-               "2:hugetlb:/\n"
-               "1:name=systemd:/user.slice/user-1000.slice/session-1.scope\n"
-               "0::/user.slice/user-1000.slice/session-1.scope\n";
-       char *controller_list[MAX_MNT_ELEMENTS];
-       char *cgroup_list[MAX_MNT_ELEMENTS];
-       pid_t pid = 5678;
-       int ret, i;
-
-       for (i = 0; i < MAX_MNT_ELEMENTS; i++) {
-               controller_list[i] = NULL;
-               cgroup_list[i] = NULL;
-       }
-
-       CreateCgroupProcFile(contents);
-
-       ret = cg_get_cgroups_from_proc_cgroups(pid, cgroup_list,
-                       controller_list, MAX_MNT_ELEMENTS);
-       ASSERT_EQ(ret, 0);
-       ASSERT_STREQ(controller_list[0], "memory");
-       ASSERT_STREQ(cgroup_list[0], "user/johndoe/0");
-       ASSERT_STREQ(controller_list[1], "perf_event");
-       ASSERT_STREQ(cgroup_list[1], "/");
-       ASSERT_STREQ(controller_list[2], "rdma");
-       ASSERT_STREQ(cgroup_list[2], "/");
-       ASSERT_STREQ(controller_list[3], "blkio");
-       ASSERT_STREQ(cgroup_list[3], "user.slice");
-       ASSERT_STREQ(controller_list[4], "cpu,cpuacct");
-       ASSERT_STREQ(cgroup_list[4], "myCgroup");
-       ASSERT_STREQ(controller_list[5], "freezer");
-       ASSERT_STREQ(cgroup_list[5], "user/johndoe/0");
-       ASSERT_STREQ(controller_list[6], "net_cls,net_prio");
-       ASSERT_STREQ(cgroup_list[6], "/");
-       ASSERT_STREQ(controller_list[7], "pids");
-       ASSERT_STREQ(cgroup_list[7], "user.slice/user-1000.slice/session-1.scope");
-       ASSERT_STREQ(controller_list[8], "devices");
-       ASSERT_STREQ(cgroup_list[8], "user.slice");
-       ASSERT_STREQ(controller_list[9], "cpuset");
-       ASSERT_STREQ(cgroup_list[9], "/");
-       ASSERT_STREQ(controller_list[10], "hugetlb");
-       ASSERT_STREQ(cgroup_list[10], "/");
-       ASSERT_STREQ(controller_list[11], "name=systemd");
-       ASSERT_STREQ(cgroup_list[11], "user.slice/user-1000.slice/session-1.scope");
-
-       ASSERT_EQ(controller_list[12], nullptr);
-       ASSERT_EQ(cgroup_list[12], nullptr);
-}
diff --git a/tests/gunit/004-cgroup_compare_ignore_rule.cpp b/tests/gunit/004-cgroup_compare_ignore_rule.cpp
deleted file mode 100644 (file)
index 29341f2..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-/**
- * libcgroup googletest for cgroup_compare_ignore_rule()
- *
- * Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
- * Author: Tom Hromatka <tom.hromatka@oracle.com>
- */
-
-/*
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License as
- * published by the Free Software Foundation.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "gtest/gtest.h"
-
-#include "libcgroup-internal.h"
-
-class CgroupCompareIgnoreRuleTest : public ::testing::Test {
-};
-
-static void CreateCgroupProcFile(const char * const contents)
-{
-       FILE *f;
-
-       f = fopen(TEST_PROC_PID_CGROUP_FILE, "w");
-       ASSERT_NE(f, nullptr);
-
-       fprintf(f, "%s", contents);
-       fclose(f);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, NotAnIgnore)
-{
-       char procname[] = "myprocess";
-       struct cgroup_rule rule;
-       pid_t pid = 1234;
-       bool ret;
-
-       rule.is_ignore = false;
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, false);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, SimpleMatch)
-{
-       char proc_file_contents[] =
-               "7:cpuacct:/SimpleMatchCgroup";
-       char rule_controller[] = "cpuacct";
-       char procname[] = "procfoo";
-       struct cgroup_rule rule;
-       pid_t pid = 2345;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = NULL;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "SimpleMatchCgroup");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, true);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, CgroupsDontMatch)
-{
-       char proc_file_contents[] =
-               "2:cpuacct:CloseButNotQuite";
-       char rule_controller[] = "cpuacct";
-       char procname[] = "procfoo2";
-       struct cgroup_rule rule;
-       pid_t pid = 4567;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "CloseButNotQuit");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, false);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, ControllersDontMatch)
-{
-       char proc_file_contents[] =
-               "5:memory:MyCgroup";
-       char rule_controller[] = "cpuacct";
-       char procname[] = "procfoo3";
-       struct cgroup_rule rule;
-       pid_t pid = 5678;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "MyCgroup");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, false);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, CombinedControllers)
-{
-       char proc_file_contents[] =
-               "13:cpu,cpuacct:/containercg";
-       char rule_controller[] = "cpuacct";
-       char procname[] = "docker";
-       struct cgroup_rule rule = {0};
-       pid_t pid = 6789;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       rule.controllers[1] = NULL;
-       sprintf(rule.destination, "containercg");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, true);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, MatchChildFolder)
-{
-       char proc_file_contents[] =
-               "7:cpuset:/parentcg/childcg/grandchildcg";
-       char rule_controller[] = "cpuset";
-       char procname[] = "childprocess";
-       struct cgroup_rule rule;
-       pid_t pid = 7890;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = procname;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "parentcg/");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, true);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, MatchGrandchildFolder)
-{
-       char proc_file_contents[] =
-               "1:hugetlb:/parentcg/childcg/grandchildcg";
-       char rule_controller[] = "hugetlb";
-       char procname[] = "granchildprocess";
-       struct cgroup_rule rule;
-       pid_t pid = 8901;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = NULL;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "parentcg/childcg/");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, true);
-}
-
-/**
- * This test is designed to highlight the case where the user has not put a
- * trailing slash at the end of the rule's destination.  By design, this will
- * cause the rule to match a wide variety of cases.
- *
- * For example, given the rule destination of "Folder".  The following
- * behavior would be observed:
- *     Process Location        Matches the rule?
- *     Folder                  Yes
- *     Folders                 Yes
- *     Folder/AnotherFolder    Yes
- *     Folder2                 Yes
- *     Folder3/ChildFolder     Yes
- *     Folde                   No
- */
-TEST_F(CgroupCompareIgnoreRuleTest, MatchSimilarChildFolder)
-{
-       char proc_file_contents[] =
-               "1:hugetlb:/parentcg/childcg2";
-       char rule_controller[] = "hugetlb";
-       char procname[] = "granchildprocess";
-       struct cgroup_rule rule;
-       pid_t pid = 8901;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = NULL;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "parentcg/childcg");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, true);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, RealWorldMatch)
-{
-       char proc_file_contents[] =
-               "12:memory:/user/johndoe/0\n"
-               "11:perf_event:/\n"
-               "10:rdma:/\n"
-               "9:blkio:/user.slice\n"
-               "8:cpu,cpuacct:/myCgroup\n"
-               "7:freezer:/user/johndoe/0\n"
-               "6:net_cls,net_prio:/\n"
-               "5:pids:/user.slice/user-1000.slice/session-1.scope\n"
-               "4:devices:/user.slice\n"
-               "3:cpuset:/\n"
-               "2:hugetlb:/\n"
-               "1:name=systemd:/user.slice/user-1000.slice/session-1.scope\n"
-               "0::/user.slice/user-1000.slice/session-1.scope\n";
-       char rule_controller[] = "cpu";
-       char procname[] = "granchildprocess";
-       struct cgroup_rule rule;
-       pid_t pid = 8901;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = NULL;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "myCgroup/");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, true);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, RealWorldNoMatch)
-{
-       char proc_file_contents[] =
-               "12:memory:/user/johndoe/0\n"
-               "11:perf_event:/\n"
-               "10:rdma:/\n"
-               "9:blkio:/user.slice\n"
-               "8:cpu,cpuacct:/myCgroup\n"
-               "7:freezer:/user/johndoe/0\n"
-               "6:net_cls,net_prio:/NetCgroup\n"
-               "5:pids:/user.slice/user-1000.slice/session-1.scope\n"
-               "4:devices:/user.slice\n"
-               "3:cpuset:/\n"
-               "2:hugetlb:/\n"
-               "1:name=systemd:/user.slice/user-1000.slice/session-1.scope\n"
-               "0::/user.slice/user-1000.slice/session-1.scope\n";
-       char rule_controller[] = "net_cls";
-       char procname[] = "NotMatching";
-       struct cgroup_rule rule;
-       pid_t pid = 9012;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = NULL;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "NetCgroup2");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, false);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, SimilarFolderNoMatch)
-{
-       char proc_file_contents[] =
-               "4:memory:/folder1";
-       char rule_controller[] = "memory";
-       char procname[] = "childprocess";
-       struct cgroup_rule rule;
-       pid_t pid = 2345;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = procname;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "folder/");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, false);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, RootDestinationMatch)
-{
-       char proc_file_contents[] =
-               "2:freezer:/";
-       char rule_controller[] = "freezer";
-       char procname[] = "ANewProcess";
-       struct cgroup_rule rule;
-       pid_t pid = 3456;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = procname;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "/");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, true);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, RootDestinationNoMatch)
-{
-       char proc_file_contents[] =
-               "2:freezer:/somerandomcg";
-       char rule_controller[] = "freezer";
-       char procname[] = "ANewProcess";
-       struct cgroup_rule rule;
-       pid_t pid = 3456;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = procname;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "/");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, false);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, WildcardProcnameSimpleMatch)
-{
-       char proc_file_contents[] =
-               "7:cpuacct:/MatchCgroup";
-       char rule_controller[] = "cpuacct";
-       char rule_procname[] = "ssh*";
-       char procname[] = "sshd";
-       struct cgroup_rule rule;
-       pid_t pid = 1234;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = rule_procname;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "MatchCgroup");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, true);
-}
-
-TEST_F(CgroupCompareIgnoreRuleTest, WildcardProcnameNoMatch)
-{
-       char proc_file_contents[] =
-               "7:cpuacct:/AnotherCgroup";
-       char rule_controller[] = "cpuacct";
-       char rule_procname[] = "httpd*";
-       char procname[] = "httpx";
-       struct cgroup_rule rule;
-       pid_t pid = 1234;
-       bool ret;
-
-       CreateCgroupProcFile(proc_file_contents);
-
-       rule.procname = rule_procname;
-       rule.is_ignore = true;
-       rule.controllers[0] = rule_controller;
-       sprintf(rule.destination, "AnotherCgroup");
-
-       ret = cgroup_compare_ignore_rule(&rule, pid, procname);
-       ASSERT_EQ(ret, false);
-}
diff --git a/tests/gunit/005-cgroup_compare_wildcard_procname.cpp b/tests/gunit/005-cgroup_compare_wildcard_procname.cpp
deleted file mode 100644 (file)
index 62adf07..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * libcgroup googletest for cgroup_compare_wildcard_procname()
- *
- * Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
- * Author: Tom Hromatka <tom.hromatka@oracle.com>
- */
-
-/*
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License as
- * published by the Free Software Foundation.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "gtest/gtest.h"
-
-#include "libcgroup-internal.h"
-
-class ProcnameWildcardTest : public ::testing::Test {
-};
-
-TEST_F(ProcnameWildcardTest, ProcnameWildcard_NoAsterisk)
-{
-       char rule_procname[] = "systemd";
-       char procname[] = "bash";
-       bool ret;
-
-       ret = cgroup_compare_wildcard_procname(rule_procname, procname);
-       ASSERT_EQ(ret, false);
-}
-
-TEST_F(ProcnameWildcardTest, ProcnameWildcard_AsteriskNoMatch)
-{
-       char rule_procname[] = "BobIsYour*";
-       char procname[] = "Linda";
-       bool ret;
-
-       ret = cgroup_compare_wildcard_procname(rule_procname, procname);
-       ASSERT_EQ(ret, false);
-}
-
-TEST_F(ProcnameWildcardTest, ProcnameWildcard_AsteriskMatch)
-{
-       char rule_procname[] = "HelloWorl*";
-       char procname[] = "HelloWorld";
-       bool ret;
-
-       ret = cgroup_compare_wildcard_procname(rule_procname, procname);
-       ASSERT_EQ(ret, true);
-}
-
-TEST_F(ProcnameWildcardTest, ProcnameWildcard_AsteriskNoMatch2)
-{
-       char rule_procname[] = "HelloW*";
-       char procname[] = "Hello";
-       bool ret;
-
-       ret = cgroup_compare_wildcard_procname(rule_procname, procname);
-       ASSERT_EQ(ret, false);
-}
-
-TEST_F(ProcnameWildcardTest, ProcnameWildcard_AsteriskMatchExactly)
-{
-       char rule_procname[] = "strace*";
-       char procname[] = "strace";
-       bool ret;
-
-       ret = cgroup_compare_wildcard_procname(rule_procname, procname);
-       ASSERT_EQ(ret, true);
-}
-
-TEST_F(ProcnameWildcardTest, ProcnameWildcard_NoAsteriskMatchExactly)
-{
-       char rule_procname[] = "systemd-cgls";
-       char procname[] = "systemd-cgls";
-       bool ret;
-
-       ret = cgroup_compare_wildcard_procname(rule_procname, procname);
-       ASSERT_EQ(ret, false);
-}
-
-TEST_F(ProcnameWildcardTest, ProcnameWildcard_AsteriskFirstChar)
-{
-       char rule_procname[] = "*";
-       char procname[] = "tomcat";
-       bool ret;
-
-       ret = cgroup_compare_wildcard_procname(rule_procname, procname);
-       ASSERT_EQ(ret, true);
-}
diff --git a/tests/gunit/Makefile.am b/tests/gunit/Makefile.am
deleted file mode 100644 (file)
index c6d2e42..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# libcgroup googletests Makefile.am
-#
-# Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
-# Author: Tom Hromatka <tom.hromatka@oracle.com>
-#
-
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License as
-# published by the Free Software Foundation.
-#
-# This library 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 Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, see <http://www.gnu.org/licenses>.
-#
-
-AM_CPPFLAGS = -I$(top_srcdir)/include \
-             -I$(top_srcdir)/src \
-             -I$(top_builddir)/googletest/googletest/include \
-             -I$(top_builddir)/googletest/googletest \
-             -std=c++11 \
-             -DSTATIC= \
-             -DUNIT_TEST
-LDADD = $(top_builddir)/src/.libs/libcgroupfortesting.la
-
-EXTRA_DIST = $(top_srcdir)/googletest/googletest/libgtest.so \
-            $(top_srcdir)/googletest/googletest/libgtest_main.so \
-            $(top_srcdir)/googletest/googletest/include \
-            libcgroup_unittest.map
-
-check_PROGRAMS = gtest
-TESTS = gtest
-
-gtest_SOURCES = gtest.cpp \
-               001-path.cpp \
-               002-cgroup_parse_rules_options.cpp \
-               003-cg_get_cgroups_from_proc_cgroups.cpp \
-               004-cgroup_compare_ignore_rule.cpp \
-               005-cgroup_compare_wildcard_procname.cpp
-gtest_LDFLAGS = -L$(top_builddir)/googletest/googletest -l:libgtest.so \
-               -rpath $(abs_top_builddir)/googletest/googletest
diff --git a/tests/gunit/gtest.cpp b/tests/gunit/gtest.cpp
deleted file mode 100644 (file)
index 1ff88c2..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * libcgroup googletest main entry point
- *
- * Copyright (c) 2019 Oracle and/or its affiliates.  All rights reserved.
- * Author: Tom Hromatka <tom.hromatka@oracle.com>
- */
-
-/*
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License as
- * published by the Free Software Foundation.
- *
- * This library 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "gtest/gtest.h"
-
-int main(int argc, char **argv)
-{
-    ::testing::InitGoogleTest(&argc, argv);
-
-    return RUN_ALL_TESTS();
-}
diff --git a/tests/gunit/libcgroup_unittest.map b/tests/gunit/libcgroup_unittest.map
deleted file mode 100644 (file)
index d2af56c..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-CGROUP_0.32 {
-global:
-       cgroup_init;
-       cgroup_attach_task;
-       cgroup_modify_cgroup;
-       cgroup_create_cgroup;
-       cgroup_delete_cgroup;
-       cgroup_attach_task_pid;
-       cgroup_get_cgroup;
-       cgroup_create_cgroup_from_parent;
-       cgroup_copy_cgroup;
-       cgroup_change_cgroup_uid_gid;
-       cgroup_change_cgroup_path;
-       cgroup_new_cgroup;
-       cgroup_add_controller;
-       cgroup_free;
-       cgroup_free_controllers;
-       cgroup_add_value_string;
-       cgroup_add_value_int64;
-       cgroup_add_value_uint64;
-       cgroup_add_value_bool;
-       cgroup_compare_cgroup;
-       cgroup_compare_controllers;
-       cgroup_set_uid_gid;
-       cgroup_get_uid_gid;
-       cgroup_get_value_string;
-       cgroup_set_value_string;
-       cgroup_get_value_int64;
-       cgroup_set_value_int64;
-       cgroup_get_value_uint64;
-       cgroup_set_value_uint64;
-       cgroup_get_value_bool;
-       cgroup_set_value_bool;
-       cgroup_change_cgroup_uid_gid_flags;
-       cgroup_print_rules_config;
-       cgroup_reload_cached_rules;
-       cgroup_init_rules_cache;
-       cgroup_get_current_controller_path;
-       cgroup_config_load_config;
-       *;
-};
-
-CGROUP_0.32.1 {
-global:
-       cgroup_strerror;
-} CGROUP_0.32;
-
-CGROUP_0.33 {
-global:
-       cgroup_get_last_errno;
-       cgroup_walk_tree_begin;
-       cgroup_walk_tree_next;
-       cgroup_walk_tree_end;
-} CGROUP_0.32.1;
-
-CGROUP_0.34 {
-global:
-       cgroup_get_task_begin;
-       cgroup_get_task_end;
-       cgroup_get_task_next;
-       cgroup_read_stats_begin;
-       cgroup_read_stats_next;
-       cgroup_read_stats_end;
-       cgroup_walk_tree_set_flags;
-       cgroup_get_controller_end;
-       cgroup_get_controller_next;
-       cgroup_get_controller_begin;
-       cgroup_unload_cgroups;
-       cgroup_get_controller;
-       cgroup_get_uid_gid_from_procfs;
-       cgroup_get_subsys_mount_point;
-       cgroup_get_procname_from_procfs;
-       cgroup_register_unchanged_process;
-       cgroup_change_cgroup_flags;
-} CGROUP_0.33;
-
-CGROUP_0.35 {
-global:
-       create_cgroup_from_name_value_pairs;
-       cgroup_delete_cgroup_ext;
-       cgroup_get_all_controller_begin;
-       cgroup_get_all_controller_next;
-       cgroup_get_all_controller_end;
-       cgroup_get_value_name_count;
-       cgroup_get_value_name;
-} CGROUP_0.34;
-
-CGROUP_0.36 {
-} CGROUP_0.35;
-
-CGROUP_0.37 {
-       cgroup_get_procs;
-       cgroup_read_value_begin;
-       cgroup_read_value_next;
-       cgroup_read_value_end;
-       cg_chmod_recursive;
-} CGROUP_0.36;
-
-CGROUP_0.38 {
-       cgroup_get_subsys_mount_point_begin;
-       cgroup_get_subsys_mount_point_next;
-       cgroup_get_subsys_mount_point_end;
-       cgroup_set_permissions;
-       cgroup_config_unload_config;
-       cgroup_config_set_default;
-} CGROUP_0.37;
-
-CGROUP_0.39 {
-       cgroup_reload_cached_templates;
-       cgroup_init_templates_cache;
-       cgroup_config_create_template_group;
-       cgroup_change_all_cgroups;
-       cgroup_set_logger;
-       cgroup_set_default_logger;
-       cgroup_set_loglevel;
-       cgroup_log;
-       cgroup_parse_log_level_str;
-} CGROUP_0.38;
-
-CGROUP_0.40 {
-       cgroup_templates_cache_set_source_files;
-       cgroup_load_templates_cache_from_files;
-} CGROUP_0.39;
-
-CGROUP_0.41 {
-} CGROUP_0.40;
-
-CGROUP_0.42 {
-       cgroup_add_all_controllers;
-} CGROUP_0.41;
diff --git a/tests/libcg_ba.cpp b/tests/libcg_ba.cpp
deleted file mode 100644 (file)
index 322794b..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright IBM Corporation. 2007
- *
- * Author:     Balbir Singh <balbir@linux.vnet.ibm.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Basic acceptance test for libcgroup - Written one late night by Balbir Singh
- */
-using namespace std;
-
-#include <string>
-#include <stdexcept>
-#include <iostream>
-#include <libcgroup.h>
-#include <sys/types.h>
-#include <pwd.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <grp.h>
-
-#include "../config.h"
-
-#ifdef CGROUP_DBG
-#define cgroup_dbg(p...)       printf(p...)
-#else
-#define cgroup_dbg(p...)       do {} while (0)
-#endif
-
-namespace cgtest {
-
-class cg {
-private:
-public:
-       cg();
-       ~cg()
-       { }
-       struct cgroup *makenode(const string &name, const string &task_uid,
-                       const string &task_gid, const string &control_uid,
-                       const string &control_gid);
-       struct cgroup *makenodefromparent(const string &name);
-};
-
-cg::cg(void)
-{
-       int ret;
-
-       ret = cgroup_init();
-       if (ret)
-               throw logic_error("Control Group Initialization failed..."
-                               "Please check that cgroups are mounted and\n"
-                               "at a single place");
-}
-
-struct cgroup *cg::makenode(const string &name, const string &task_uid,
-               const string &task_gid, const string &control_uid,
-               const string &control_gid)
-{
-       uid_t tuid, cuid;
-       gid_t tgid, cgid;
-       char *cgroup_name;
-       struct cgroup *ccg;
-       struct cgroup_controller *cpu, *cpuacct;
-       struct passwd *passwd;
-       struct group *grp;
-       int ret;
-
-       passwd = getpwnam(task_uid.c_str());
-       if (!passwd)
-               return NULL;
-       tuid = passwd->pw_uid;
-
-       grp = getgrnam(task_gid.c_str());
-       if (!grp)
-               return NULL;
-       tgid = grp->gr_gid;
-
-       passwd = getpwnam(control_uid.c_str());
-       if (!passwd)
-               return NULL;
-       cuid = passwd->pw_uid;
-
-       grp = getgrnam(control_gid.c_str());
-       if (!grp)
-               return NULL;
-       cgid = grp->gr_gid;
-
-       cgroup_dbg("tuid %d, tgid %d, cuid %d, cgid %d\n", tuid, tgid, cuid, cgid);
-
-       cgroup_name = (char *) malloc(name.length());
-       strncpy(cgroup_name, name.c_str(), name.length() + 1);
-
-       ccg = cgroup_new_cgroup(cgroup_name);
-       cgroup_set_uid_gid(ccg, tuid, tgid, cuid, cgid);
-       cpu = cgroup_add_controller(ccg, "cpu");
-       cgroup_add_value_uint64(cpu, "cpu.shares", 2048);
-       cpuacct = cgroup_add_controller(ccg, "cpuacct");
-       cgroup_add_value_uint64(cpuacct, "cpuacct.usage", 0);
-
-
-       ret = cgroup_create_cgroup(ccg, 1);
-       if (ret) {
-               cout << "cg create group failed " << errno << endl;
-               ret = cgroup_delete_cgroup(ccg, 1);
-               if (ret)
-                       cout << "cg delete group failed " << errno << endl;
-       }
-       return ccg;
-}
-
-struct cgroup *cg::makenodefromparent(const string &name)
-{
-       char *cgroup_name;
-       struct cgroup *ccg;
-       int ret;
-
-       cgroup_name = (char *) malloc(name.length());
-       memset(cgroup_name, '\0', name.length());
-       strcpy(cgroup_name, name.c_str());
-
-       ccg = cgroup_new_cgroup(cgroup_name);
-       ret = cgroup_create_cgroup_from_parent(ccg, 1);
-       if (ret) {
-               cout << "cg create group failed " << errno << endl;
-               ret = cgroup_delete_cgroup(ccg, 1);
-               if (ret)
-                       cout << "cg delete group failed " << errno << endl;
-       }
-       return ccg;
-}
-
-} // namespace
-
-using namespace cgtest;
-int main(int argc, char *argv[])
-{
-       try {
-               cg *app = new cg();
-               struct cgroup *ccg, *ccg_child1, *ccg_child2;
-               ccg = app->makenode("database", "root", "root", "balbir",
-                                       "balbir");
-               ccg_child1 = app->makenodefromparent("mysql");
-               ccg_child2 = app->makenodefromparent("mysql/db1");
-               cgroup_free(&ccg);
-               cgroup_free(&ccg_child1);
-               cgroup_free(&ccg_child2);
-               delete app;
-       } catch (exception &e) {
-               cout << e.what() << endl;
-               exit(1);
-       }
-       return 0;
-}
diff --git a/tests/libcgrouptest.h b/tests/libcgrouptest.h
deleted file mode 100644 (file)
index 98b1ba9..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-
-/*
- * Copyright IBM Corporation. 2008
- *
- * Author:     Sudhir Kumar <skumar@linux.vnet.ibm.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Description: This file is the header file for libcgroup test programs.
- */
-
-#ifndef __LIBCGROUPTEST_H
-#define __LIBCGROUPTEST_H
-
-#include <errno.h>
-#include <fcntl.h>
-#include <mntent.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <libcgroup.h>
-#include "../config.h"
-#include <unistd.h>
-#include <inttypes.h>
-
-#define SIZE 100       /* Max size of a message to be printed */
-#define NUM_MSGS 20    /* Number of such messsages */
-#define PASS 1         /* test passed */
-#define FAIL 0         /* test failed */
-
-enum cgroup_mount_t {
-       FS_NOT_MOUNTED,
-       FS_MOUNTED,
-       FS_MULTI_MOUNTED,
-};
-
-enum controller_t {
-       CPU,
-       MEMORY,
-       CPUSET,
-       /* Add new controllers here */
-};
-
-enum cgroup_control_val_t {
-       BOOL,
-       INT64,
-       UINT64,
-       STRING,
-};
-
-enum info_message_t {
-       NULLGRP,
-       COMMONGRP,
-       NOTCRTDGRP,
-       SAMEGRP,
-       TASKINGRP,
-       TASKNOTINGRP,
-       TASKNOTINANYGRP,
-       GRPINFS,
-       GRPNOTINFS,
-       GRPINBOTHCTLS,
-       GRPNOTIN2NDCTL,
-       GRPNOTIN1STCTL,
-       GRPMODINBOTHCTLS,
-       GRPNOTMODIN2NDCTL,
-       GRPNOTMODINANYCTL,
-       GRPDELETEDINFS,
-       GRPNOTDELETEDINFS,
-       GRPNOTDELETEDGLOBALY,
-       NOMESSAGE,
-};
-
-/* Keep a single struct of all ids */
-struct uid_gid_t {
-       uid_t control_uid;
-       gid_t control_gid;
-       uid_t tasks_uid;
-       gid_t tasks_gid;
-};
-
-/* Keep a single struct of all control values */
-struct cntl_val_t {
-       int64_t val_int64;
-       u_int64_t val_uint64;
-       bool val_bool;
-       /* size worth of 100 digit num is fair enough */
-       char val_string[100];   /* string value of control parameter */
-};
-
-extern int cpu, memory;
-
-/* The set of verbose messages useful to the user */
-extern char info[NUM_MSGS][SIZE];
-
-/* this variable is never modified */
-extern int fs_mounted;
-
-/* The mountpoints as received from script
- * We use mountpoint for single mount.
- * For multimount we use mountpoint and mountpoint2.
- */
-extern char mountpoint[], mountpoint2[];
-
-/* Functions to test each API */
-void test_cgroup_init(int retcode, int i);
-void test_cgroup_attach_task(int retcode, struct cgroup *cgroup1,
-               const char *group1, const char *group2, pid_t pid,
-               int k, int i);
-struct cgroup *create_new_cgroup_ds(int ctl, const char *grpname,
-        int value_type, struct cntl_val_t cval, struct uid_gid_t ids, int i);
-void test_cgroup_create_cgroup(int retcode, struct cgroup *cgrp,
-                const char *name, int common, int mpnt, int ign, int i);
-void test_cgroup_delete_cgroup(int retcode, struct cgroup *cgrp,
-                const char *name, int common, int mpnt, int ign, int i);
-void test_cgroup_modify_cgroup(int retcode, struct cgroup *cgrp,
-                const char *name, int which_ctl, int ctl1, int ctl2,
-                                                int value_type, int i);
-void test_cgroup_get_cgroup(int ctl1, int ctl2, struct uid_gid_t ids, int i);
-/* API test functions end here */
-
-void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i);
-void test_cgroup_add_free_controller(int i);
-void is_subsystem_enabled(const char *name, int *exist);
-int group_exist(char *path_group);
-int set_controller(int controller, char *controller_name,
-                                                char *control_file);
-int group_modified(char *path_control_file, int value_type,
-                                                struct cntl_val_t cval);
-int add_control_value(struct cgroup_controller *newcontroller,
-        char *control_file, char *wr, int value_type, struct cntl_val_t cval);
-struct cgroup *new_cgroup(char *group, char *controller_name,
-        char *control_file, int value_type, struct cntl_val_t cval,
-                                        struct uid_gid_t ids, int i);
-int check_fsmounted(int multimnt);
-int check_task(char *tasksfile, pid_t pid);
-/* function to print messages in better format */
-void message(int num, int pass, const char *api,
-                                                int ret, char *extra);
-void build_path(char *target, char *mountpoint,
-                                const char *group, const char *file);
-pid_t cgrouptest_gettid();
-
-#ifdef CGROUP_DEBUG
-#define cgroup_dbg(p...)       printf(p)
-#else
-#define cgroup_dbg(p...)       do {} while (0);
-#endif
-
-#endif
diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c
deleted file mode 100644 (file)
index d7770a0..0000000
+++ /dev/null
@@ -1,756 +0,0 @@
-/*
- * Copyright IBM Corporation. 2008
- *
- * Author:     Sudhir Kumar <skumar@linux.vnet.ibm.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Description: This file contains the test code for testing libcgroup apis.
- */
-
-#include "libcgrouptest.h"
-#include <errno.h>
-
-int cpu, memory;
-int fs_mounted;
-/* We use mountpoint for single mount.
- * For multimount we use mountpoint and mountpoint2.
- */
-char mountpoint[FILENAME_MAX], mountpoint2[FILENAME_MAX];
-
-int main(int argc, char *argv[])
-{
-       int retval;
-       struct uid_gid_t ids = {0}; /* Set default control permissions */
-
-       struct cntl_val_t cval;
-       cval.val_int64 = 200000;
-       cval.val_uint64 = 200000;
-       cval.val_bool = 1;
-       strcpy(cval.val_string, "200000");
-
-       struct cgroup *cgroup1, *cgroup2, *cgroup3, *nullcgroup = NULL;
-       struct cgroup_controller *sec_controller;
-       /* In case of multimount for readability we use the controller name
-        * before the cgroup structure name */
-       struct cgroup *ctl1_cgroup1, *ctl2_cgroup1, *ctl2_cgroup2;
-       struct cgroup *mod_ctl1_cgroup1, *mod_ctl2_cgroup1, *mod_common_cgroup;
-       struct cgroup *common_cgroup;
-       char controller_name[FILENAME_MAX], control_file[FILENAME_MAX];
-       char path_control_file[FILENAME_MAX];
-
-       /* Get controllers name from script */
-       int ctl1 = CPU, ctl2 = MEMORY;
-
-       if ((argc < 2) || (argc > 6) || (atoi(argv[1]) < 0)) {
-               printf("ERROR: Wrong no of parameters recieved from script\n");
-               printf("Exiting the libcgroup testset\n");
-               exit(1);
-       }
-       fs_mounted = atoi(argv[1]);
-       cgroup_dbg("C:DBG: fs_mounted as recieved from script=%d\n",
-                                                               fs_mounted);
-       /* All possible controller will be element of an enum */
-       if (fs_mounted) {
-               ctl1 = atoi(argv[2]);
-               ctl2 = atoi(argv[3]);
-               strncpy(mountpoint, argv[4], sizeof(mountpoint) - 1);
-               cgroup_dbg("C:DBG: mountpoint1 as recieved from script=%s\n",
-                                                                mountpoint);
-               if (fs_mounted == FS_MULTI_MOUNTED) {
-                       strncpy(mountpoint2, argv[5], sizeof(mountpoint2) - 1);
-                       cgroup_dbg("C:DBG: mountpoint2 as recieved from "
-                                       "script=%s\n", mountpoint2);
-               }
-
-       }
-
-       /*
-        * check if one of the supported controllers is cpu or memory
-        */
-       is_subsystem_enabled("cpu", &cpu);
-       is_subsystem_enabled("memory", &memory);
-       if (cpu == 0 && memory == 0) {
-               fprintf(stderr, "none of cpu and memory controllers"
-                                               " is enabled in kernel\n");
-               fprintf(stderr, "Exiting the libcgroup testcases......\n");
-               exit(1);
-       }
-
-       /*
-        * Testsets: Testcases are broadly devided into 3 categories based on
-        * filesystem(fs) mount scenario. fs not mounted, fs mounted, fs multi
-        * mounted. Call different apis in these different scenarios.
-        */
-
-       switch (fs_mounted) {
-
-       case FS_NOT_MOUNTED:
-
-               /*
-                * Test01: call cgroup_init() and check return values
-                * Exp outcome: error ECGROUPNOTMOUNTED
-                */
-
-               test_cgroup_init(ECGROUPNOTMOUNTED, 1);
-
-               /*
-                * Test02: call cgroup_attach_task() with null group
-                * Exp outcome: error non zero return value
-                */
-
-               test_cgroup_attach_task(ECGROUPNOTINITIALIZED, nullcgroup,
-                                                NULL, NULL, 0, NULLGRP, 2);
-
-               /*
-                * Test03: Create a valid cgroup ds and check all return values
-                * Exp outcome: no error
-                */
-
-               cgroup1 = create_new_cgroup_ds(0, "group1",
-                                                STRING, cval, ids, 3);
-
-               /*
-                * Test04: Then Call cgroup_create_cgroup() with this valid grp
-                * Exp outcome: non zero return value
-                */
-               test_cgroup_create_cgroup(ECGROUPNOTINITIALIZED, cgroup1,
-                                                        "group1", 0, 1, 1, 4);
-
-               /*
-                * Test05: delete cgroup
-                * Exp outcome: non zero return value but what ?
-                */
-               test_cgroup_delete_cgroup(ECGROUPNOTINITIALIZED, cgroup1,
-                                                        "group1", 0, 1, 1, 5);
-
-               /*
-                * Test06: Check if cgroup_create_cgroup() handles a NULL cgroup
-                * Exp outcome: error ECGROUPNOTALLOWED
-                */
-               test_cgroup_create_cgroup(ECGROUPNOTINITIALIZED, nullcgroup,
-                                                        "group1", 0, 1, 1, 6);
-
-               /*
-                * Test07: delete nullcgroup
-                */
-               test_cgroup_delete_cgroup(ECGROUPNOTINITIALIZED, nullcgroup,
-                                                        "group1", 0, 1, 1, 7);
-               /* Test08: test the wrapper */
-               test_cgroup_add_free_controller(8);
-
-               cgroup_free(&nullcgroup);
-               cgroup_free(&cgroup1);
-
-               break;
-
-       case FS_MOUNTED:
-
-               /* Do a sanity check if cgroup fs is mounted */
-               if (check_fsmounted(0)) {
-                       printf("Sanity check fails. cgroup fs not mounted\n");
-                       printf("Exiting without running this set of tests\n");
-                       exit(1);
-               }
-
-               /*
-                * Test01: call cgroup_attach_task() with null group
-                * without calling cgroup_init(). We can check other apis too.
-                * Exp outcome: error ECGROUPNOTINITIALIZED
-                */
-
-               test_cgroup_attach_task(ECGROUPNOTINITIALIZED, nullcgroup,
-                                                NULL, NULL, 0, NULLGRP, 1);
-
-               /*
-                * Test02: call cgroup_init() and check return values
-                * Exp outcome:  no error. return value 0
-                */
-
-               test_cgroup_init(0, 2);
-
-               /*
-                * Test03: Call cgroup_attach_task() with null group and check
-                * if return values are correct. If yes check if task exists in
-                * root group tasks file
-                * TODO: This test needs some modification in script
-                * Exp outcome: current task should be attached to root group
-                */
-
-               test_cgroup_attach_task(0, nullcgroup, NULL, NULL, 0,
-                                                        NULLGRP, 3);
-               /*
-                * Test04: Call cgroup_attach_task_pid() with null group
-                * and invalid pid
-                * Exp outcome: error
-                */
-               retval = cgroup_attach_task_pid(nullcgroup, -1);
-               if (retval != 0)
-                       message(4, PASS, "attach_task_pid()", retval,
-                                                        info[NOMESSAGE]);
-               else
-                       message(4, FAIL, "attach_task_pid()", retval,
-                                                        info[NOMESSAGE]);
-
-               /*
-                * Test05: Create a valid cgroup structure
-                * Exp outcome: no error. 0 return value
-                */
-               cgroup1 = create_new_cgroup_ds(ctl1, "group1",
-                                                        STRING, cval, ids, 5);
-               if (!cgroup1) {
-                       fprintf(stderr, "Failed to create new cgroup ds. "
-                                       "Trying with second controller\n");
-                       cgroup1 = create_new_cgroup_ds(ctl2, "group1", STRING,
-                                                               cval, ids, 5);
-                       if (!cgroup1) {
-                               fprintf(stderr, "Failed to create cgroup ds. "
-                                       "Tests dependent on this structure "
-                                       "will fail. So exiting...\n");
-                               exit(1);
-                       }
-               }
-
-               /*
-                * Test06: Then Call cgroup_create_cgroup() with this group
-                * Exp outcome: zero return value
-                */
-               test_cgroup_create_cgroup(0, cgroup1, "group1", 0, 1, 1, 6);
-
-               /*
-                * Test07: Call cgroup_attach_task() with valid cgroup and check
-                * if return values are correct. If yes check if task exists in
-                * that group's tasks file
-                * Exp outcome: current task should be attached to that group
-                */
-
-               test_cgroup_attach_task(0, cgroup1, "group1", NULL,
-                                                        0, NOMESSAGE, 7);
-
-               /*
-                * Test08: modify cgroup with the same cgroup
-                * Exp outcome: zero return value. No change.
-                */
-               set_controller(ctl1, controller_name, control_file);
-               build_path(path_control_file, mountpoint,
-                                                "group1", control_file);
-               strncpy(cval.val_string, "260000", sizeof(cval.val_string));
-               retval = cgroup_modify_cgroup(cgroup1);
-               /* Check if the values are changed. cval contains orig values */
-               if (!retval && !group_modified(path_control_file, STRING, cval))
-                       message(8, PASS, "modify_cgroup()", retval,
-                                                        info[SAMEGRP]);
-               else
-                       message(8, FAIL, "modify_cgroup()", retval,
-                                                        info[SAMEGRP]);
-
-               /*
-                * Create another valid cgroup structure with same group
-                * to modify the existing group
-                */
-               cgroup2 = create_new_cgroup_ds(ctl1, "group1",
-                                                STRING, cval, ids, 9);
-               if (!cgroup2) {
-                       fprintf(stderr, "Failed to create new cgroup ds. "
-                                       "Trying with second controller\n");
-                       cgroup2 = create_new_cgroup_ds(ctl2, "group1",
-                                                        STRING, cval, ids, 9);
-                       if (!cgroup2) {
-                               fprintf(stderr, "Failed to create cgroup ds. "
-                                       "Tests dependent on this structure "
-                                       "will fail. So exiting...\n");
-                               exit(1);
-                       }
-               }
-
-               /*
-                * Test10: modify cgroup with this new cgroup
-                * Exp outcome: zero return value
-                * Drawback: In case of first attempt failure above for
-                * create_new_cgroup_ds(), this test will fail
-                */
-               test_cgroup_modify_cgroup(0, cgroup2, "group1",
-                                        1, ctl1, ctl2, STRING, 10);
-
-               /*
-                * Test11: modify cgroup with the null cgroup
-                * Exp outcome: zero return value.
-                */
-
-               test_cgroup_modify_cgroup(ECGROUPNOTALLOWED, nullcgroup,
-                                        "group1", 1, ctl1, ctl2, STRING, 11);
-
-               /*
-                * Create another valid cgroup structure with diff controller
-                * to modify the existing group
-                */
-               cval.val_int64 = 262144;
-               cgroup3 = create_new_cgroup_ds(ctl2, "group1",
-                                                INT64, cval, ids, 12);
-               if (!cgroup3) {
-                       fprintf(stderr, "Failed to create new cgroup ds. "
-                                       "Tests dependent on this structure "
-                                       "will fail. So exiting...\n");
-                       exit(1);
-               }
-
-               /*
-                * Test13: modify existing group with this cgroup
-                * Exp outcome: zero return value
-                */
-               test_cgroup_modify_cgroup(0, cgroup3, "group1",
-                                                2, ctl1, ctl2, INT64, 13);
-
-               /* Test14: Test cgroup_get_cgroup() api
-                * The group group1 has been created and modified in the
-                * filesystem. Read it using the api and check if the values
-                * are correct as we know all the control values now.
-                * WARN: If any of the previous api fails and control reaches
-                * here, this api also will fail. Also the test function assumes
-                * that "group1" exists in fs. So call cgroup_create_cgroup()
-                * with "group1" named group before calling this test function.
-                */
-               test_cgroup_get_cgroup(ctl1, ctl2, ids, 14);
-
-               /*
-                * Test16: delete cgroup
-                * Exp outcome: zero return value
-                */
-               test_cgroup_delete_cgroup(0, cgroup1, "group1", 0, 1, 1, 16);
-
-               /*
-                * Test16: Check if cgroup_create_cgroup() handles a NULL cgroup
-                * Exp outcome: error ECGROUPNOTALLOWED
-                */
-               test_cgroup_create_cgroup(ECGROUPNOTALLOWED, nullcgroup,
-                                                        "group1", 0, 1, 1, 17);
-
-               /*
-                * Test16: delete nullcgroup
-                */
-               test_cgroup_delete_cgroup(ECGROUPNOTALLOWED, NULL,
-                                                        "group1", 0, 1, 1, 18);
-
-               /* Test17: Test the wrapper to compare cgroup
-                * Create 2 cgroups and test it
-                */
-               test_cgroup_compare_cgroup(ctl1, ctl2, 19);
-
-               cgroup_free(&nullcgroup);
-               cgroup_free(&cgroup1);
-               cgroup_free(&cgroup2);
-               cgroup_free(&cgroup3);
-
-               break;
-
-       case FS_MULTI_MOUNTED:
-
-               /* Do a sanity check if cgroup fs is multi mounted */
-               if (check_fsmounted(1)) {
-                       printf("Sanity check fails. cgroup fs is not multi "
-                               "mounted. Exiting without running this set "
-                                       "of testcases\n");
-                       exit(1);
-               }
-
-               /*
-                * Test01: call apis and check return values
-                * Exp outcome:
-                */
-
-               /*
-                * Scenario 1: cgroup fs is multi mounted
-                * Exp outcome: no error. 0 return value
-                */
-
-               test_cgroup_init(0, 1);
-
-               /*
-                * Test02: Call cgroup_attach_task() with null group and check
-                * if return values are correct. If yes check if task exists in
-                * root group tasks file for each controller
-                * TODO: This test needs some modification in script
-                * Exp outcome: current task should be attached to root groups
-                */
-
-               test_cgroup_attach_task(0, nullcgroup, NULL, NULL,
-                                                        0, NULLGRP, 2);
-
-               /*
-                * Test03: Create a valid cgroup structure
-                * Exp outcome: no error. 0 return value
-                */
-               ctl1_cgroup1 = create_new_cgroup_ds(ctl1, "ctl1_group1",
-                                                        STRING, cval, ids, 3);
-               if (!ctl1_cgroup1) {
-                       fprintf(stderr, "Failed to create new cgroup ds. "
-                                       "Tests dependent on this structure "
-                                       "will fail. So exiting...\n");
-                       exit(1);
-               }
-
-               /*
-                * Test04: Then Call cgroup_create_cgroup() with this valid grp
-                * Exp outcome: zero return value
-                */
-               test_cgroup_create_cgroup(0, ctl1_cgroup1,
-                                                "ctl1_group1", 0, 1, 1, 4);
-
-               /*
-                * Test05: Create a valid cgroup structure
-                * Exp outcome: no error. 0 return value
-                */
-               ctl2_cgroup1 = create_new_cgroup_ds(ctl2, "ctl2_group1",
-                                                        STRING, cval, ids, 5);
-               if (!ctl2_cgroup1) {
-                       fprintf(stderr, "Failed to create new cgroup ds. "
-                                       "Tests dependent on this structure "
-                                       "will fail. So exiting...\n");
-                       exit(1);
-               }
-
-               /*
-                * Test06: Then Call cgroup_create_cgroup() with this valid grp
-                * Exp outcome: zero return value
-                */
-               test_cgroup_create_cgroup(0, ctl2_cgroup1,
-                                                "ctl2_group1", 0, 2, 1, 6);
-
-               /*
-                * Test07: Call cgroup_create_cgroup() with the same group
-                * Exp outcome: zero return value as the latest changes in api
-                */
-               test_cgroup_create_cgroup(0, ctl2_cgroup1,
-                                                "ctl2_group1", 0, 2, 1, 7);
-
-               /*
-                * Test06: Call cgroup_attach_task() with a group with ctl1
-                * controller and check if return values are correct. If yes
-                * check if task exists in that group under only ctl1 controller
-                * hierarchy and in the root group under other controllers
-                * hierarchy.
-                */
-
-               test_cgroup_attach_task(0, ctl1_cgroup1, "ctl1_group1",
-                                                NULL, 0, NOMESSAGE, 8);
-
-               /*
-                * Test07: Call cgroup_attach_task() with a group with ctl2
-                * controller and check if return values are correct. If yes
-                * check if task exists in the groups under both controller's
-                * hierarchy.
-                */
-
-               test_cgroup_attach_task(0, ctl2_cgroup1, "ctl1_group1",
-                                        "ctl2_group1", 0, NOMESSAGE, 9);
-
-               /*
-                * Test: Create a valid cgroup structure
-                * Exp outcome: no error. 0 return value
-                */
-               ctl2_cgroup2 = create_new_cgroup_ds(ctl2, "ctl2_group2",
-                                                        STRING, cval, ids, 10);
-               if (!ctl2_cgroup2) {
-                       fprintf(stderr, "Failed to create new cgroup ds. "
-                                       "Tests dependent on this structure "
-                                       "will fail. So exiting...\n");
-                       exit(1);
-               }
-
-               /*
-                * Test08: Try to attach a task to this non existing group.
-                * Group does not exist in fs so should return ECGROUPNOTEXIST
-                */
-
-               test_cgroup_attach_task(ECGROUPNOTEXIST, ctl2_cgroup2,
-                                        NULL, NULL, 0, NOTCRTDGRP, 11);
-
-               /*
-                * Create another valid cgroup structure with same group name
-                * to modify the existing group ctl1_group1
-                * Exp outcome: no error. 0 return value
-                */
-               mod_ctl1_cgroup1 = create_new_cgroup_ds(ctl1, "ctl1_group1",
-                                                        STRING, cval, ids, 12);
-               if (!mod_ctl1_cgroup1) {
-                       fprintf(stderr, "Failed to create new cgroup ds. "
-                                       "Tests dependent on this structure "
-                                       "will fail. So exiting...\n");
-                       exit(1);
-               }
-
-               /*
-                * Test09: modify existing cgroup with this new cgroup
-                * Exp outcome: zero return value and control value modified
-                */
-               test_cgroup_modify_cgroup(0, mod_ctl1_cgroup1, "ctl1_group1",
-                                                1, ctl1, ctl2, STRING, 13);
-
-               /*
-                * Create another valid cgroup structure with same group name
-                * to modify the existing group ctl2_group1
-                * Exp outcome: no error. 0 return value
-                */
-               mod_ctl2_cgroup1 = create_new_cgroup_ds(ctl2, "ctl2_group1",
-                                                        STRING, cval, ids, 14);
-               if (!mod_ctl2_cgroup1) {
-                       fprintf(stderr, "Failed to create new cgroup ds. "
-                                       "Tests dependent on this structure "
-                                       "will fail. So exiting...\n");
-                       exit(1);
-               }
-
-               /*
-                * Test10: modify existing cgroup with this new cgroup
-                * Exp outcome: zero return value and control value modified
-                */
-               test_cgroup_modify_cgroup(0, mod_ctl2_cgroup1, "ctl2_group1",
-                                                2, ctl1, ctl2, STRING, 15);
-
-               /*
-                * Test11: delete cgroups
-                * Exp outcome: zero return value
-                */
-               test_cgroup_delete_cgroup(0, ctl1_cgroup1,
-                                                "ctl1_group1", 0, 1, 1, 16);
-
-               /*
-                * Test09: delete other cgroups too
-                * Exp outcome: zero return value
-                */
-               test_cgroup_delete_cgroup(0, ctl2_cgroup1,
-                                                "ctl2_group1", 0, 1, 1, 17);
-
-               /*
-                * Test15: Create a valid cgroup structure
-                * which has multiple controllers
-                * Exp outcome: no error. 0 return value
-                */
-               common_cgroup = create_new_cgroup_ds(ctl1, "commongroup",
-                                                        STRING, cval, ids, 18);
-               if (!common_cgroup) {
-                       fprintf(stderr, "Failed to create new cgroup ds. "
-                                       "Tests dependent on this structure "
-                                       "will fail. So exiting...\n");
-                       exit(1);
-               }
-
-               /* Add one more controller to the cgroup */
-               /* This also needs to be a function.. will do?? */
-               retval = set_controller(ctl2, controller_name, control_file);
-               if (retval) {
-                       fprintf(stderr, "Setting controller failled "
-                               " Exiting without running further testcases\n");
-                       exit(1);
-               }
-               if (!cgroup_add_controller(common_cgroup, controller_name)) {
-                       message(15, FAIL, "add_controller()", retval,
-                                                        info[NOMESSAGE]);
-                       fprintf(stderr, "Adding second controller failled "
-                               " Exiting without running further testcases\n");
-                       exit(1);
-               }
-
-               /*
-                * Test11: Then Call cgroup_create_cgroup() with this valid grp
-                * Exp outcome: zero return value
-                */
-               test_cgroup_create_cgroup(0, common_cgroup,
-                                                "commongroup", 1, 2, 1, 19);
-
-               /*
-                * Test12: Call cgroup_attach_task() with this common group
-                * and check if return values are correct. If yes check if
-                * task exists in the group under both controller's hierarchy
-                */
-
-               test_cgroup_attach_task(0, common_cgroup, "commongroup",
-                                        "commongroup", 0, COMMONGRP, 20);
-
-               /*
-                * Test18: Create a valid cgroup structure to modify the
-                * commongroup which is under multiple controllers
-                * Exp outcome: no error. 0 return value
-                */
-               mod_common_cgroup = create_new_cgroup_ds(ctl1, "commongroup",
-                                                        STRING, cval, ids, 21);
-               if (!common_cgroup) {
-                       fprintf(stderr, "Failed to create new cgroup ds. "
-                                       "Tests dependent on this structure "
-                                       "will fail. So exiting...\n");
-                       exit(1);
-               }
-
-               /* Add one more controller to the cgroup */
-               /* This also needs to be a function.. will do?? */
-               retval = set_controller(ctl2, controller_name, control_file);
-               if (retval) {
-                       fprintf(stderr, "Setting controller failled "
-                               " Exiting without running further testcases\n");
-                       exit(1);
-               }
-               sec_controller = cgroup_add_controller(mod_common_cgroup,
-                                                        controller_name);
-               if (!sec_controller) {
-                       message(18, FAIL, "add_controller()", retval,
-                                                        info[NOMESSAGE]);
-                       fprintf(stderr, "Adding second controller failled "
-                               " Exiting without running further testcases\n");
-                       exit(1);
-               }
-
-               strncpy(cval.val_string, "7000064", sizeof(cval.val_string));
-               retval = cgroup_add_value_string(sec_controller,
-                                                control_file, cval.val_string);
-               if (retval)
-                       printf("The cgroup_modify_cgroup() test will fail\n");
-
-               /*
-                * Test14: modify existing cgroup with this new cgroup
-                * Exp outcome: zero return value and control value modified
-                */
-               test_cgroup_modify_cgroup(0, mod_common_cgroup, "commongroup",
-                                                0, ctl1, ctl2, STRING, 22);
-
-               /*
-                * Test15: delete this common cgroup
-                * Exp outcome: zero return value
-                */
-               test_cgroup_delete_cgroup(0, common_cgroup,
-                                                "commongroup", 1, 2, 1, 23);
-               test_cgroup_get_cgroup(ctl1, ctl2, ids, 24);
-
-               /* Free the cgroup structures */
-               cgroup_free(&nullcgroup);
-               cgroup_free(&ctl1_cgroup1);
-               cgroup_free(&ctl2_cgroup1);
-               cgroup_free(&ctl2_cgroup2);
-
-               break;
-
-       default:
-               fprintf(stderr, "ERROR: Wrong parameters recieved from script. \
-                                               Exiting tests\n");
-               exit(1);
-               break;
-       }
-       return 0;
-}
-
-void test_cgroup_modify_cgroup(int retcode, struct cgroup *cgrp,
-                        const char *name, int which_ctl, int ctl1,
-                                        int ctl2, int value_type, int i)
-{
-       int retval;
-       struct cntl_val_t cval = {0, 0, 0, "1000"};
-       char path1_control_file[FILENAME_MAX], path2_control_file[FILENAME_MAX];
-       char controller_name[FILENAME_MAX], control_file[FILENAME_MAX];
-
-       /* Check, In case some error is expected due to a negative scenario */
-       if (retcode) {
-               retval = cgroup_modify_cgroup(cgrp);
-               if (retval == retcode)
-                       message(i, PASS, "modify_cgroup()", retval,
-                                                        info[NOMESSAGE]);
-               else
-                       message(i, FAIL, "modify_cgroup()", retval,
-                                                        info[NOMESSAGE]);
-
-               return;
-       }
-
-       /* Now there is no error and it is a genuine call */
-       retval = cgroup_modify_cgroup(cgrp);
-       if (retval) {
-               message(i, FAIL, "modify_cgroup()", retval,  info[NOMESSAGE]);
-               return;
-       }
-
-       /* Let us now check if the group modified in file system */
-       switch (which_ctl) { /* group modified under which controllers */
-
-       case 1: /* group is modified under ctl1 which is always
-                * mounted at mountpoint in both cases */
-               set_controller(ctl1, controller_name, control_file);
-               build_path(path1_control_file, mountpoint, name, control_file);
-               /* this approach will be changed in coming patches */
-               strncpy(cval.val_string, "260000", sizeof(cval.val_string));
-
-               if (!group_modified(path1_control_file, value_type, cval))
-                       message(i, PASS, "modify_cgroup()", retval,
-                                                        info[NOMESSAGE]);
-               else
-                       message(i, FAIL, "modify_cgroup()", retval,
-                                                        info[NOMESSAGE]);
-
-               break;
-       case 2: /* group is modified under ctl2 which may be
-                * mounted at mountpoint or mountpoint2 */
-               set_controller(ctl2, controller_name, control_file);
-
-               if (fs_mounted == FS_MOUNTED)   /* group under mountpoint */
-                       build_path(path2_control_file, mountpoint,
-                                                name, control_file);
-               else    /* group under mountpoint2 */
-                       build_path(path2_control_file, mountpoint2,
-                                                name, control_file);
-
-               /* this approach will be changed in coming patches */
-               strncpy(cval.val_string, "7000064", sizeof(cval.val_string));
-               cval.val_int64 = 262144;
-               if (!group_modified(path2_control_file, value_type, cval))
-                       message(i, PASS, "modify_cgroup()", retval,
-                                                        info[NOMESSAGE]);
-               else
-                       message(i, FAIL, "modify_cgroup()", retval,
-                                                        info[NOMESSAGE]);
-
-               break;
-       case 0:
-               /* ctl1 is always mounted at mountpoint */
-               set_controller(ctl1, controller_name, control_file);
-               build_path(path1_control_file, mountpoint,
-                                                name, control_file);
-               /* ctl2 may be mounted at mountpoint or mountpoint2 depending
-                * on single or multiple mount case */
-               if (fs_mounted == FS_MOUNTED) { /* group under mountpoint */
-                       set_controller(ctl2, controller_name, control_file);
-                       build_path(path2_control_file, mountpoint,
-                                                name, control_file);
-               } else {        /* group under mountpoint2 */
-                       set_controller(ctl2, controller_name, control_file);
-                       build_path(path2_control_file, mountpoint2,
-                                                name, control_file);
-               }
-               /* this approach will be changed in coming patches */
-               strncpy(cval.val_string, "260000", sizeof(cval.val_string));
-               if (!group_modified(path1_control_file, value_type, cval)) {
-                       strncpy(cval.val_string, "7000064",
-                                                sizeof(cval.val_string));
-                       if (!group_modified(path2_control_file,
-                                                        value_type, cval))
-                               message(i, PASS, "modify_cgroup()",
-                                        retval, info[GRPMODINBOTHCTLS]);
-                       else
-                               message(i, FAIL, "modify_cgroup()",
-                                        retval, info[GRPNOTMODIN2NDCTL]);
-               } else {
-                       message(i, FAIL, "modify_cgroup()", retval,
-                                                info[GRPNOTMODINANYCTL]);
-               }
-
-               break;
-       default:
-               printf("Wrong controller parameter received....\n");
-               message(i, FAIL, "modify_cgroup()", retval, info[NOMESSAGE]);
-               break;
-       }
-
-       return;
-}
diff --git a/tests/logger.c b/tests/logger.c
deleted file mode 100644 (file)
index b7f1b70..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright Red Hat Inc., 2012
- *
- * Author:     Jan Safranek <jsafrane@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Description: This file contains the test code for libcgroup logging.
- */
-
-#include "config.h"
-#include "libcgroup.h"
-#include "../src/libcgroup-internal.h"
-#include <string.h>
-#include <stdlib.h>
-
-static void mylogger(void *userdata, int loglevel, const char *fmt, va_list ap)
-{
-       printf("custom: ");
-       vprintf(fmt, ap);
-}
-
-int main(int argc, char **argv)
-{
-       int custom = 0;
-       int loglevel = -1;
-       int i;
-
-       for (i = 1; i < argc; i++) {
-               if (strcmp("custom", argv[i]) == 0)
-                       custom = 1;
-               else
-                       loglevel = atoi(argv[i]);
-       }
-
-       if (custom)
-               cgroup_set_logger(mylogger, loglevel, NULL);
-       else
-               cgroup_set_default_logger(loglevel);
-
-       cgroup_dbg("DEBUG message\n");
-       cgroup_info("INFO message\n");
-       cgroup_warn("WARNING message\n");
-       cgroup_err("ERROR message\n");
-
-       return 0;
-}
diff --git a/tests/logger.sh b/tests/logger.sh
deleted file mode 100755 (executable)
index b3c82a5..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/bin/bash
-# Test various log levels
-
-export LOGFILE=
-export RET=0
-unset CGROUP_LOGLEVEL
-
-function run_logger()
-{
-       LOGFILE=`mktemp`
-       echo "Running CGROUP_LOGLEVEL=$CGROUP_LOGLEVEL logger $* >$LOGFILE"
-       ./logger $* >$LOGFILE
-}
-
-function assert_grep()
-{
-       if ! grep "$@" <$LOGFILE >/dev/null; then
-               echo "Error: expecting $* in output"
-               RET=1
-       fi
-}
-
-function assert_not_grep()
-{
-       if grep "$@" <$LOGFILE >/dev/null; then
-               echo "Error: unexptected $* in output"
-               RET=1
-       fi
-}
-
-# CGROUP_LOGLEVEL is case-insensitive
-CGROUP_LOGLEVEL=DeBuG run_logger -1
-assert_grep "^DEBUG message"
-assert_grep "^INFO message"
-assert_grep "^WARNING message"
-assert_grep "^ERROR message"
-rm $LOGFILE
-
-# missing CGROUP_LOGLEVEL leads to ERRORs only
-run_logger -1
-assert_not_grep "^DEBUG message"
-assert_not_grep "^INFO message"
-assert_not_grep "^WARNING message"
-assert_grep "^ERROR message"
-rm $LOGFILE
-
-# wrong CGROUP_LOGLEVEL leads to ERRORs only
-CGROUP_LOGLEVEL=xyz run_logger -1
-assert_not_grep "^DEBUG message"
-assert_not_grep "^INFO message"
-assert_not_grep "^WARNING message"
-assert_grep "^ERROR message"
-rm $LOGFILE
-
-# numeric CGROUP_LOGLEVEL
-CGROUP_LOGLEVEL=3 run_logger -1
-assert_not_grep "^DEBUG message"
-assert_grep "^INFO message"
-assert_grep "^WARNING message"
-assert_grep "^ERROR message"
-rm $LOGFILE
-
-# errors only CGROUP_LOGLEVEL
-CGROUP_LOGLEVEL=ERROR run_logger -1
-assert_not_grep "^DEBUG message"
-assert_not_grep "^INFO message"
-assert_not_grep "^WARNING message"
-assert_grep "^ERROR message"
-rm $LOGFILE
-
-# no CGROUP_LOGLEVEL -> DEBUG
-run_logger 4
-assert_grep "^DEBUG message"
-assert_grep "^INFO message"
-assert_grep "^WARNING message"
-assert_grep "^ERROR message"
-rm $LOGFILE
-
-# no CGROUP_LOGLEVEL -> INFO
-run_logger 3
-assert_not_grep "^DEBUG message"
-assert_grep "^INFO message"
-assert_grep "^WARNING message"
-assert_grep "^ERROR message"
-rm $LOGFILE
-
-# no CGROUP_LOGLEVEL -> WARN
-run_logger 2
-assert_not_grep "^DEBUG message"
-assert_not_grep "^INFO message"
-assert_grep "^WARNING message"
-assert_grep "^ERROR message"
-rm $LOGFILE
-
-# no CGROUP_LOGLEVEL -> ERROR
-run_logger 1
-assert_not_grep "^DEBUG message"
-assert_not_grep "^INFO message"
-assert_not_grep "^WARNING message"
-assert_grep "^ERROR message"
-rm $LOGFILE
-
-# no CGROUP_LOGLEVEL -> nothing
-run_logger 0
-assert_not_grep "^DEBUG message"
-assert_not_grep "^INFO message"
-assert_not_grep "^WARNING message"
-assert_not_grep "^ERROR message"
-rm $LOGFILE
-
-
-# custom logger -> DEBUG
-run_logger custom 4
-assert_grep "^custom: DEBUG message"
-assert_grep "^custom: INFO message"
-assert_grep "^custom: WARNING message"
-assert_grep "^custom: ERROR message"
-rm $LOGFILE
-
-# custom logger -> INFO
-run_logger custom 3
-assert_not_grep "^custom: DEBUG message"
-assert_grep "^custom: INFO message"
-assert_grep "^custom: WARNING message"
-assert_grep "^custom: ERROR message"
-rm $LOGFILE
-
-# custom logger -> WARN
-run_logger custom 2
-assert_not_grep "^custom: DEBUG message"
-assert_not_grep "^custom: INFO message"
-assert_grep "^custom: WARNING message"
-assert_grep "^custom: ERROR message"
-rm $LOGFILE
-
-exit $RET
-
diff --git a/tests/proctest.c b/tests/proctest.c
deleted file mode 100644 (file)
index 8e840c1..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright NEC Soft Ltd. 2009
- *
- * Author:     Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "../src/libcgroup-internal.h"
-
-int main(int argc, char *argv[])
-{
-       int i;
-       int ret;
-       pid_t pid;
-       uid_t uid;
-       gid_t gid;
-       char *procname;
-
-       if (argc < 2) {
-               printf("Specify process-id.\n");
-               return 1;
-       }
-       printf("  Pid  |        Process name              |  Uid  |  Gid  \n");
-       printf("-------+----------------------------------+-------+-------\n");
-
-       for (i = 1; i < argc; i++) {
-               pid = atoi(argv[i]);
-
-               ret = cgroup_get_uid_gid_from_procfs(pid, &uid, &gid);
-               if (ret) {
-                       printf("%6d | ret = %d\n", pid, ret);
-                       continue;
-               }
-               ret = cgroup_get_procname_from_procfs(pid, &procname);
-               if (ret) {
-                       printf("%6d | ret = %d\n", pid, ret);
-                       continue;
-               }
-               printf("%6d | %32s | %5d | %5d\n", pid, procname, uid, gid);
-               free(procname);
-       }
-       return 0;
-}
diff --git a/tests/read_stats.c b/tests/read_stats.c
deleted file mode 100644 (file)
index 0583039..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include <libcgroup.h>
-
-int read_stats(char *path, char *controller)
-{
-       int ret;
-       void *handle;
-       struct cgroup_stat stat;
-
-       ret = cgroup_read_stats_begin(controller, path,  &handle, &stat);
-
-       if (ret != 0) {
-               fprintf(stderr, "stats read failed\n");
-               return -1;
-       }
-
-       printf("Stats for %s:\n", path);
-       printf("%s: %s", stat.name, stat.value);
-
-       while ((ret = cgroup_read_stats_next(&handle, &stat)) !=
-                       ECGEOF) {
-               printf("%s: %s", stat.name, stat.value);
-       }
-
-       cgroup_read_stats_end(&handle);
-       printf("\n");
-       return 0;
-}
-
-int main(int argc, char *argv[])
-{
-       int ret;
-       char *controller;
-       void *handle;
-       struct cgroup_file_info info;
-       int lvl;
-       char cgroup_path[FILENAME_MAX];
-       int root_len;
-
-       if (argc < 2) {
-               fprintf(stderr, "Usage %s: <controller name>\n",
-                       argv[0]);
-               exit(EXIT_FAILURE);
-       }
-
-       controller = argv[1];
-
-       ret = cgroup_init();
-       if (ret != 0) {
-               fprintf(stderr, "init failed\n");
-               exit(EXIT_FAILURE);
-       }
-
-       ret = cgroup_walk_tree_begin(controller, "/", 0, &handle, &info, &lvl);
-
-       if (ret != 0) {
-               fprintf(stderr, "Walk failed\n");
-               exit(EXIT_FAILURE);
-       }
-
-       root_len = strlen(info.full_path) - 1;
-       strncpy(cgroup_path, info.path, FILENAME_MAX - 1);
-       ret = read_stats(cgroup_path, controller);
-       if (ret < 0)
-               exit(EXIT_FAILURE);
-
-       while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) !=
-                       ECGEOF) {
-               if (info.type != CGROUP_FILE_TYPE_DIR)
-                       continue;
-               strncpy(cgroup_path, info.full_path + root_len, FILENAME_MAX - 1);
-               strcat(cgroup_path, "/");
-               ret = read_stats(cgroup_path, controller);
-               if (ret < 0)
-                       exit(EXIT_FAILURE);
-       }
-       cgroup_walk_tree_end(&handle);
-
-       return EXIT_SUCCESS;
-}
diff --git a/tests/runlibcgrouptest.sh.in b/tests/runlibcgrouptest.sh.in
deleted file mode 100755 (executable)
index 119addd..0000000
+++ /dev/null
@@ -1,444 +0,0 @@
-#!/bin/bash
-# usage ./runlibcgrouptest.sh
-# Copyright IBM Corporation. 2008
-#
-# Author:      Sudhir Kumar <skumar@linux.vnet.ibm.com>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-# Description: This script runs the the basic tests for testing libcgroup apis.
-#
-
-# TODO path to config.h have to be set properly
-OPAQUE_HIERARCHY=`grep "OPAQUE_HIERARCHY" @abs_top_srcdir@/config.h |\
-        cut -d" " -f3 | sed  's|\"||g'`
-DEBUG=false;           # for debug messages
-FS_MOUNTED=0;          # 0 for not mounted, 1 for mounted, 2 for multimounted
-MOUNTPOINT=/dev/cgroup_controllers;    # Just to initialize
-TARGET=/dev/cgroup_controllers;
-CONTROLLERS=cpu,memory;
-NUM_MOUNT=1;           # Number of places to be mounted on
-MULTIMOUNT=false;      # mounted at one point only
-NUM_CTLRS=0;           # num of controllers supported
-CTLR1="";
-CTLR2="";
-CPU="";
-MEMORY="";
-SKIP_TEST=77
-RET=0
-
-declare -a allcontrollers;
-declare -a targets;
-
-debug()
-{
-       # Function parameter is the string to print out
-       if $DEBUG
-       then
-               echo SH:DBG: $1;
-       fi
-}
-
-check_mount_fs ()
-{
-       local NUM_MOUNT=0;
-       CGROUP=`cat /proc/mounts|grep -w ^cgroup|tr -s [:space:]|cut -d" " -f3`;
-
-       # get first word in case of multiple mounts
-       CGROUP=`echo $CGROUP|cut -d" " -f1`;
-
-       debug "check_mount_fs(): CGROUP is $CGROUP";
-       if [ "$CGROUP" = "cgroup" ]
-       then
-               NUM_MOUNT=`cat /proc/mounts|grep -w ^cgroup|wc -l`;
-               debug "check_mount_fs(): fs mounted at $NUM_MOUNT places";
-
-               if [ $NUM_MOUNT -eq 1 ]
-               then
-                       FS_MOUNTED=1;
-               else
-                       # Any number of mounts is multi mount
-                       FS_MOUNTED=2;
-               fi;
-               return 0;       # True
-       else
-               FS_MOUNTED=0;
-               return 1;       # false
-       fi
-}
-
-umount_fs ()
-{
-       PROC_ENTRY_NUMBER=`cat /proc/mounts|grep ^cgroup | wc -l`;
-       NUMBER=1;
-       #go and remove all ot opaque mount points
-       while [ $PROC_ENTRY_NUMBER -ge $NUMBER ]
-       do
-               # Get $NUMBER-th mountpoint in case of multiple mount
-               PROC_ENTRY=`cat /proc/mounts|grep ^cgroup|\
-                               tr -s [:space:]|cut -d" " -f2 |\
-                               head -n$NUMBER | tail -n1`;
-               # if the hierarchy is opaque skip to next item
-               if [ -n "$OPAQUE_HIERARCHY" ]
-               then
-                       # find whether is the NUMBER-th item opaque
-                       PROC_ENTRY_OPT=`cat /proc/mounts|grep ^cgroup|\
-                               tr -s [:space:]|cut -d" " -f4 |\
-                               head -n$NUMBER | tail -n1`;
-                       echo $PROC_ENTRY_OPT | grep $OPAQUE_HIERARCHY
-                       # if yes skip it to the next item
-                       if [ $? -eq 0 ]
-                       then
-                               let NUMBER=$NUMBER+1
-                               continue
-                       fi;
-               fi;
-               # remove the item
-               if [ ! -z "$PROC_ENTRY" ]
-               then
-                       TARGET=$PROC_ENTRY;
-                       # Need to take care of running tasks in any group ??
-                       rmdir $TARGET/* 2> /dev/null ;
-                       umount $TARGET;
-                       rmdir  $TARGET;
-                       debug "umounted $TARGET";
-               fi;
-               # go to the next item
-               let NUMBER=$NUMBER+1
-       done;
-       FS_MOUNTED=0;
-       TARGET=/dev/cgroup_controllers; #??
-       echo "Cleanup done";
-}
-
-# Put all the supported controllers in an array
-# We have the priority for cpu and memory controller. So prefer to mount
-# them if they exist
-get_all_controllers()
-{
-       while [ 1 ]; do
-               read line || break;
-               if ! echo $line | grep -q ^#
-               then
-                       allcontrollers[$NUM_CTLRS]=`echo $line | cut -d" " -f1`;
-                       if [ ${allcontrollers[$NUM_CTLRS]} == "cpu" ]; then
-                               CPU="cpu";
-                       elif [ ${allcontrollers[$NUM_CTLRS]} == "memory" ]; then
-                               MEMORY="memory";
-                       fi;
-                       debug "controller: ${allcontrollers[$NUM_CTLRS]}";
-                       NUM_CTLRS=`expr $NUM_CTLRS + 1`;
-               fi
-       done < /proc/cgroups;
-       debug "Total controllers $NUM_CTLRS";
-}
-
-# Get a second controller other than cpu or memory
-get_second_controller()
-{
-       local i=0;
-       while [ $i -lt $NUM_CTLRS ]
-       do
-               if [ "${allcontrollers[$i]}" != "cpu" ] &&
-                                [ "${allcontrollers[$i]}" != "memory" ]
-               then
-                       CTLR2=${allcontrollers[$i]};
-                       return 0;
-               fi;
-       i=`expr $i + 1`;
-       done;
-}
-
-# Check if kernel is not having any of the controllers enabled
-no_controllers()
-{
-       # prefer if cpu and memory controller are enabled
-       if [ ! -z $CPU ] && [ ! -z $MEMORY ]
-       then
-               CONTROLLERS=$CPU,$MEMORY ;
-               CTLR1=$CPU;
-               CTLR2=$MEMORY;
-               debug "first controller is $CTLR1";
-               debug "second controller is $CTLR2";
-               return 1;       # false
-       elif [ ! -z $CPU ]
-       then
-               CONTROLLERS=$CPU ;
-               CTLR1=$CPU;
-               get_second_controller;
-               debug "first controller is $CTLR1";
-               debug "second controller is $CTLR2";
-               return 1;       # false
-       elif [ ! -z $MEMORY ]
-       then
-               CONTROLLERS=$MEMORY ;
-               CTLR1=$MEMORY;
-               get_second_controller;
-               debug "first controller is $CTLR1";
-               debug "second controller is $CTLR2";
-               return 1;       # false
-       fi;
-       # Kernel has neither cpu nor memory controller enabled. So there is
-       # no point in running the testcases. At least one of them should be
-       # supported.(or should I run testcases with controllers such as
-       #  ns, devices etc? Thoughts???)
-       if [ $NUM_CTLRS -lt 2 ]
-       then
-               echo "Kernel needs to have 2 controllers enabled";
-               echo "Recompile your kernel with at least 2 controllers"
-               echo "Exiting the tests.....";
-               exit $SKIP_TEST;
-       fi;
-
-       return 0;       # true
-}
-
-
-mount_fs ()
-{
-       local NUM_MOUNT=0;      # On how many places to mount on
-       local CUR_MOUNT=1;
-       FS_MOUNTED=0;
-
-       # Check if kernel has controllers enabled
-       if no_controllers
-       then
-               echo "Kernel has none of cpu/memory controllers enabled";
-               echo "Recompile your kernel with at least one of these enabled"
-               echo "Exiting the tests.....";
-               exit $SKIP_TEST;
-       fi;
-
-       # At least one Controller is enabled. So proceed further.
-       if [ -z $1 ]
-       then
-               echo "WARN: No parameter passed to function mount_fs";
-               echo "taking default as 0....So not mounting cgroup fs";
-       else
-               NUM_MOUNT=$1;
-               debug "mount_fs fs will be mounted on $NUM_MOUNT places";
-       fi;
-
-       # create so many directories i.e. mountpoints
-       while [ $NUM_MOUNT -ge $CUR_MOUNT ]
-       do
-               NEWTARGET="$TARGET-$CUR_MOUNT";
-               if [ -e $NEWTARGET ]
-               then
-                       echo "WARN: $NEWTARGET already exist..overwriting";
-                       check_mount_fs; # Possibly fs might be mounted on it
-                       if [ $FS_MOUNTED -gt 0 ]
-                       then
-                               umount_fs;
-                       else
-                               rmdir $NEWTARGET ;
-                       fi;
-               fi;
-               mkdir $NEWTARGET;
-
-               # In case of multimount, mount controllers at diff points
-               if $MULTIMOUNT ; then
-                       if [ $CTLR1 ] && [ $CTLR2 ] ; then
-                               if [ $CUR_MOUNT -eq 1 ] ; then
-                                       CONTROLLERS=$CTLR1;
-                               else
-                                       CONTROLLERS=$CTLR2;
-                               fi;
-                       else
-                               echo "Only 1 controler enabled in kernel";
-                               echo "So not running multiple mount testcases";
-                               exit $SKIP_TEST;
-                       fi;
-               fi;
-
-               mount -t cgroup -o $CONTROLLERS cgroup $NEWTARGET;
-               if [ $? -ne 0 ]
-               then
-                       echo "ERROR: in mounting cgroup fs on $NEWTARGET."
-                       echo "Exiting test";
-                       umount_fs;
-                       exit -1;
-               fi;
-               target[$CUR_MOUNT]=$NEWTARGET;
-               CUR_MOUNT=`expr $CUR_MOUNT + 1`;
-               FS_MOUNTED=`expr $FS_MOUNTED + 1`;
-
-               # Group created earlier may again be visible if not cleaned.
-               # So clean them all
-               if [ -e $NEWTARGET/group1 ] # first group that is created
-               then
-                       # Need to handle if tasks are running in them
-                       rmdir $NEWTARGET/group*
-                       echo "WARN: Earlier groups found and removed...";
-               fi;
-
-               debug "$CONTROLLERS controllers mounted on $NEWTARGET  directory"
-       done;
-
-       if [ $FS_MOUNTED -gt 2 ]
-       then
-               FS_MOUNTED=2;
-       fi;
-
-}
-
-get_ctl_num()
-{
-       ctl1=$1;
-       ctl2=$2;
-       if [ -z $ctl1 ] || [ -z $ctl2 ]; then
-               echo "Null controller passed to function get_ctl_num"
-               echo "Exiting the testcases....."
-       fi
-
-       # Add any new controller developed here
-       declare -a ctl_list;
-       # Following list has to be in sync with enums in header
-       ctl_list[0]="cpu";
-       ctl_list[1]="memory";
-       ctl_list[2]="cpuset";
-
-       local i=0;
-       while [ ! -z ${ctl_list[$i]} ]; do
-               if [ "${ctl_list[$i]}" == "$ctl1" ]; then
-                       ctl1=$i;
-               fi;
-
-               if [ "${ctl_list[$i]}" == "$ctl2" ]; then
-                       ctl2=$i;
-               fi;
-       i=`expr $i + 1`;
-       done;
-}
-
-runtest()
-{
-       MOUNT_INFO=$1;
-       TEST_EXEC=$2;
-       if [ -f $TEST_EXEC ]
-       then
-               ./$TEST_EXEC $MOUNT_INFO $ctl1 $ctl2 ${target[1]} ${target[2]};
-               if [ $? -ne 0 ]
-               then
-                       echo Error in running ./$TEST_EXEC
-                       echo Exiting tests.
-               else
-                       PID=$!;
-               fi;
-       else
-               echo Sources not compiled. please run make;
-       fi
-}
-
-###############################
-# Main starts here
-       # Check if kernel has controllers support
-       if [ -e /proc/cgroups ]
-       then
-               get_all_controllers;
-       else
-               echo "Your Kernel seems to be too old. Plz recompile your"
-               echo "Kernel with cgroups and appropriate controllers enabled"
-               echo " Exiting the testcases...."
-               exit $SKIP_TEST;
-       fi;
-
-       MY_ID=`id -u`
-       if [ $MY_ID -ne 0 ]; then
-               echo "Only root can start this script."
-               echo " Exiting the testcase..."
-               exit $SKIP_TEST
-       fi
-
-# TestSet01: Run tests without mounting cgroup filesystem
-       echo;
-       echo Running first set of testcases;
-       echo ==============================
-       FS_MOUNTED=0;
-       FILE=libcgrouptest01;
-       check_mount_fs;
-       # unmount fs if already mounted
-       if [ $FS_MOUNTED -ne 0 ]
-       then
-               umount_fs;
-       fi;
-       debug "FS_MOUNTED = $FS_MOUNTED"
-       runtest $FS_MOUNTED $FILE
-
-       wait $PID;
-       RC=$?;
-       if [ $RC -ne 0 ]
-       then
-               echo Test binary $FILE exited abnormaly with return value $RC;
-               # Do not exit here. Failure in this case does not imply
-               # failure in other cases also
-               RET=$RC
-       fi;
-
-# TestSet02: Run tests with mounting cgroup filesystem
-       echo;
-       echo Running second set of testcases;
-       echo ==============================
-       FILE=libcgrouptest01;
-       check_mount_fs;
-       # mount fs at one point if not already mounted or multimounted
-       NUM_MOUNT=1;
-       if [ $FS_MOUNTED -eq 0 ]
-       then
-               mount_fs $NUM_MOUNT;
-       elif [ $FS_MOUNTED -gt 1 ]
-       then
-               umount_fs;
-               mount_fs $NUM_MOUNT;
-       fi;
-       debug "FS_MOUNTED = $FS_MOUNTED"
-       get_ctl_num $CTLR1 $CTLR2;
-       runtest $FS_MOUNTED $FILE
-
-       wait $PID;
-       RC=$?;
-       if [ $RC -ne 0 ]
-       then
-               echo Test binary $FILE exited abnormaly with return value $RC;
-               RET=$RC
-       fi;
-       umount_fs;
-
-
-# TestSet03: Run tests with mounting cgroup filesystem at multiple points
-       echo;
-       echo Running third set of testcases;
-       echo ==============================
-       FILE=libcgrouptest01;
-       check_mount_fs;
-       # mount fs at multiple points
-       MULTIMOUNT=true;
-       NUM_MOUNT=2;
-       if [ $FS_MOUNTED -eq 0 ]
-       then
-               mount_fs $NUM_MOUNT;
-       elif [ $FS_MOUNTED -eq 1 ]
-       then
-               umount_fs;
-               mount_fs $NUM_MOUNT;
-       fi;
-       debug "FS_MOUNTED = $FS_MOUNTED"
-       get_ctl_num $CTLR1 $CTLR2;
-       runtest $FS_MOUNTED $FILE
-
-       wait $PID;
-       RC=$?;
-       if [ $RC -ne 0 ]
-       then
-               echo Test binary $FILE exited abnormaly with return value $RC;
-               RET=$RC
-       fi;
-       umount_fs;
-
-       exit $RET;
diff --git a/tests/setuid.c b/tests/setuid.c
deleted file mode 100644 (file)
index 02916e4..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright Red Hat Inc. 2008
- *
- * Author:      Steve Olivieri <sjo@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <grp.h>
-#include <errno.h>
-#include <string.h>
-
-/* 
- * This is just a simple program for changing a UID or a GID.  Comment out
- * whichever block you don't want to use.
- */
-int main(int argc, char *argv[])
-{
-       /* User data */
-       struct passwd *pwd;
-
-       /* UID of user */
-       uid_t uid;
-
-       /* Return codes */
-       int ret = 0;
-
-       if (argc < 2) {
-               printf("Usage: %s <uid_value> \n", argv[0]);
-               goto finished;
-       }
-
-       pwd = getpwnam(argv[1]);
-       if (!pwd) {
-               fprintf(stderr, "getpwnam() failed: %s\n",
-                               strerror(errno));
-               ret = -errno;
-               goto finished;
-       }
-       uid = pwd->pw_uid;
-       fprintf(stdout, "Setting UID to %s (%d).\n", pwd->pw_name, uid);
-       if ((ret = setuid(uid))) {
-               fprintf(stderr, "Call to setuid() failed with error: %s\n",
-                               strerror(errno));
-               ret = -errno;
-               goto finished;
-       }
-
-//     while(1) {
-//             grp = getgrnam("root");
-//             gid = grp->gr_gid;
-//             fprintf(stdout, "Setting GID to %s (%d).\n",
-//                             grp->gr_name, gid);
-//             if ((ret = setgid(gid))) {
-//                     fprintf(stderr, "Call to setgid() failed with error:"
-//                                     " %s\n", strerror(errno));
-//                     ret = -errno;
-//                     goto finished;
-//             }
-//     }
-
-       while (1) {
-               usleep(3000000);
-       }
-
-finished:
-       return ret;
-}
diff --git a/tests/test_functions.c b/tests/test_functions.c
deleted file mode 100644 (file)
index f357ab2..0000000
+++ /dev/null
@@ -1,927 +0,0 @@
-/*
- * Copyright IBM Corporation. 2008
- *
- * Author:     Sudhir Kumar <skumar@linux.vnet.ibm.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Description: This file contains the functions for testing libcgroup apis.
- */
-
-#include "libcgrouptest.h"
-
-/* The messages that may be useful to the user */
-char info[][SIZE] = {
-       " Parameter nullcgroup\n",                      /* NULLGRP */
-       " Parameter commoncgroup\n",                    /* COMMONGRP */
-       " Parameter not created group\n",               /* NOTCRTDGRP */
-       " Parameter same cgroup\n",                     /* SAMEGRP */
-       " Task found in group/s\n",                     /* TASKINGRP */
-       " Task not found in group/s\n",                 /* TASKNOTINGRP */
-       " Task not found in all groups\n",              /* TASKNOTINANYGRP */
-       " group found in filesystem\n",                 /* GRPINFS */
-       " group not found in filesystem\n",             /* GRPNOTINFS */
-       " group found under both controllers\n",        /* GRPINBOTHCTLS */
-       " group not found under second controller\n",   /* GRPNOTIN2NDCTL */
-       " group not found under first controller\n",    /* GRPNOTIN1STCTL */
-       " group modified under both controllers\n",     /* GRPMODINBOTHCTLS */
-       " group not modified under second controller\n",/* GRPNOTMODIN2NDCTL */
-       " group not modified under any controller\n",   /* GRPNOTMODINANYCTL */
-       " Group deleted from filesystem\n",             /* GRPDELETEDINFS */
-       " Group not deleted from filesystem\n",         /* GRPNOTDELETEDINFS */
-       " Group not deleted globally\n",                /* GRPNOTDELETEDGLOBALY */
-       /* In case there is no extra info messages to be printed */
-       "\n",                                           /* NOMESSAGE */
-};
-
-/**
- * Tests the cgroup_init_cgroup() api under different scenarios
- * @param retcode error code in case any error is expected from api
- * @param i the test number
- */
-void test_cgroup_init(int retcode, int i)
-{
-       int retval;
-
-       retval = cgroup_init();
-       if (retval == retcode)
-               message(i, PASS, "init()\t", retval, info[NOMESSAGE]);
-       else
-               message(i, FAIL, "init()",  retval, info[NOMESSAGE]);
-}
-
-/**
- * Tests the cgroup_attach_cgroup() api under different scenarios
- * @param retcode error code in case any error is expected from api
- * @param cgrp the group to assign the task to
- * @param group1 the name of the group under first (single) mountpoint
- * @param group2 the name of the group under 2nd moutpoint for multimount
- * @param i the test number
- * @param k the message enum number to print the useful message
- */
-void test_cgroup_attach_task(int retcode, struct cgroup *cgrp,
-        const char *group1, const char *group2, pid_t pid, int k, int i)
-{
-       int retval;
-       char tasksfile[FILENAME_MAX], tasksfile2[FILENAME_MAX];
-       /* Check, In case some error is expected due to a negative scenario */
-       if (retcode) {
-               if (pid)
-                       retval = cgroup_attach_task_pid(cgrp, pid);
-               else
-                       retval = cgroup_attach_task(cgrp);
-
-               if (retval == retcode)
-                       message(i, PASS, "attach_task()", retval, info[k]);
-               else
-                       message(i, FAIL, "attach_task()", retval, info[k]);
-
-               return;
-       }
-
-       /* Now there is no error and it is a genuine call */
-       if (pid)
-               retval = cgroup_attach_task_pid(cgrp, pid);
-       else
-               retval = cgroup_attach_task(cgrp);
-
-       /* API returned success, so perform check */
-       if (retval == 0) {
-               build_path(tasksfile, mountpoint,
-                                        group1, "tasks");
-
-               if (check_task(tasksfile, 0)) {
-                       if (fs_mounted == 2) {
-                               /* multiple mounts */
-                               build_path(tasksfile2, mountpoint2,
-                                                        group2, "tasks");
-                               if (check_task(tasksfile2, 0)) {
-                                       message(i, PASS, "attach_task()",
-                                                retval, info[TASKINGRP]);
-                               } else {
-                                       message(i, FAIL, "attach_task()",
-                                                retval, info[TASKNOTINANYGRP]);
-                               }
-                       } else {
-                               /* single mount */
-                               message(i, PASS, "attach_task()",
-                                                retval, info[TASKINGRP]);
-                       }
-               } else {
-                       message(i, FAIL, "attach_task()", retval,
-                                                        info[TASKNOTINGRP]);
-               }
-       } else {
-               message(i, FAIL, "attach_task()", retval, (char *)"\n");
-       }
-}
-
-/**
- * This function creates a cgroup data structure
- * This function is a bit ugly for now and need to be changed
- * @param ctl the controller under which group is to be created
- * @param grpname the name of the group
- * @param value_type which value out of four types
- * @param struct cval the control value structure
- * @param struct ids the permissions struct
- * @param the test number
- */
-struct cgroup *create_new_cgroup_ds(int ctl, const char *grpname,
-        int value_type, struct cntl_val_t cval, struct uid_gid_t ids, int i)
-{
-       int retval;
-       char group[FILENAME_MAX];
-       char controller_name[FILENAME_MAX], control_file[FILENAME_MAX];
-
-       strncpy(group, grpname, sizeof(group) - 1);
-       retval = set_controller(ctl, controller_name, control_file);
-       if (retval) {
-               fprintf(stderr, "Setting controller failled\n");
-               return NULL;
-       }
-
-       switch (ctl) {
-               /* control values are controller specific, so will be set
-                * accordingly from the config file */
-       case CPU:
-               strncpy(cval.val_string, "260000", sizeof(cval.val_string));
-               break;
-
-       case MEMORY:
-               strncpy(cval.val_string, "7000064", sizeof(cval.val_string));
-               break;
-
-       /* To be added for other controllers */
-       default:
-               printf("Invalid controller name passed. Setting control value"
-                                       " failed. Dependent tests may fail\n");
-               return NULL;
-               break;
-       }
-
-       return new_cgroup(group, controller_name, control_file,
-                                                value_type, cval, ids, i);
-}
-
-/**
- * Tests the cgroup_create_cgroup() api under different scenarios
- * @param retcode error code in case any error is expected from api
- * @param cgrp the group to be created
- * @param name the name of the group
- * @param common to test if group will be created under one or both mountpoints
- * @param mpnt to test if group under mountpoint or mountpoint2
- * @param ign parameter for api if to ignore the ownership
- * @param the test number
- */
-void test_cgroup_create_cgroup(int retcode, struct cgroup *cgrp,
-                        const char *name, int common, int mpnt, int ign, int i)
-{
-       int retval;
-       char path1_group[FILENAME_MAX], path2_group[FILENAME_MAX];
-       /* Check, In case some error is expected due to a negative scenario */
-       if (retcode) {
-               retval = cgroup_create_cgroup(cgrp, ign);
-               if (retval == retcode)
-                       message(i, PASS, "create_cgroup()", retval,
-                                                        info[NOMESSAGE]);
-               else
-                       message(i, FAIL, "create_cgroup()", retval,
-                                                        info[NOMESSAGE]);
-
-               return;
-       }
-
-       /* Now there is no error and it is a genuine call */
-       retval = cgroup_create_cgroup(cgrp, ign);
-       if (retval) {
-               message(i, FAIL, "create_cgroup()", retval,  info[NOMESSAGE]);
-               return;
-       }
-
-       /* Let us now check if the group exist in file system */
-       if (!common) {
-               /* group only under one mountpoint */
-               if (mpnt == 1)
-                       /* group under mountpoint */
-                       build_path(path1_group, mountpoint, name, NULL);
-               else
-                       /* group under mountpoint2 */
-                       build_path(path1_group, mountpoint2, name, NULL);
-
-               if (group_exist(path1_group) == 0)
-                       message(i, PASS, "create_cgroup()", retval,
-                                                        info[GRPINFS]);
-               else
-                       message(i, FAIL, "create_cgroup()", retval,
-                                                        info[GRPNOTINFS]);
-
-        /* group under both mountpoints */
-       } else {
-               /* check if the group exists under both controllers */
-               build_path(path1_group, mountpoint, name, NULL);
-               if (group_exist(path1_group) == 0) {
-                       build_path(path2_group, mountpoint2, name, NULL);
-
-                       if (group_exist(path2_group) == 0)
-                               message(i, PASS, "create_cgroup()",
-                                                retval, info[GRPINBOTHCTLS]);
-                       else
-                               message(i, FAIL, "create_cgroup()",
-                                                retval, info[GRPNOTIN2NDCTL]);
-               } else {
-                       message(i, FAIL, "create_cgroup()", retval,
-                                                        info[GRPNOTIN1STCTL]);
-               }
-       }
-
-       return;
-}
-
-/**
- * Tests the cgroup_delete_cgroup() api under different scenarios
- * @param retcode error code in case any error is expected from api
- * @param cgrp the group to be deleted
- * @param name the name of the group
- * @param common to test if group was created under one or both mountpoints
- * @param mpnt to test if group under mountpoint or mountpoint2
- * @param ign parameter for api if to ignore the ownership
- * @param the test number
- */
-void test_cgroup_delete_cgroup(int retcode, struct cgroup *cgrp,
-                        const char *name, int common, int mpnt, int ign, int i)
-{
-       int retval;
-       char path1_group[FILENAME_MAX], path2_group[FILENAME_MAX];
-       /* Check, In case some error is expected due to a negative scenario */
-       if (retcode) {
-               retval = cgroup_delete_cgroup(cgrp, ign);
-               if (retval == retcode)
-                       message(i, PASS, "delete_cgroup()", retval,
-                                                        info[NOMESSAGE]);
-               else
-                       message(i, FAIL, "delete_cgroup()", retval,
-                                                        info[NOMESSAGE]);
-
-               return;
-       }
-
-       /* Now there is no error and it is a genuine call */
-       retval = cgroup_delete_cgroup(cgrp, ign);
-       if (retval) {
-               message(i, FAIL, "delete_cgroup()", retval,  info[NOMESSAGE]);
-               return;
-       }
-
-       /* Let us now check if the group has been deleted from file system */
-       if (!common) {
-               /* check only under one mountpoint */
-               if (mpnt == 1)
-                       /* check group under mountpoint */
-                       build_path(path1_group, mountpoint, name, NULL);
-               else
-                       /* check group under mountpoint2 */
-                       build_path(path1_group, mountpoint2, name, NULL);
-
-               if (group_exist(path1_group) == ENOENT)
-                       message(i, PASS, "delete_cgroup()", retval,
-                                                info[GRPDELETEDINFS]);
-               else
-                       message(i, FAIL, "delete_cgroup()", retval,
-                                                info[GRPNOTDELETEDINFS]);
-
-       } else {
-               /* check group under both mountpoints */
-               /* Check if the group deleted under both mountpoints */
-               build_path(path1_group, mountpoint, name, NULL);
-               if (group_exist(path1_group) == ENOENT) {
-                       build_path(path2_group, mountpoint2, name, NULL);
-
-                       if (group_exist(path2_group) == ENOENT)
-                               message(i, PASS, "delete_cgroup()",
-                                                retval, info[GRPDELETEDINFS]);
-                       else
-                               message(i, FAIL, "delete_cgroup()",
-                                        retval, info[GRPNOTDELETEDGLOBALY]);
-               } else {
-                       message(i, FAIL, "delete_cgroup()", retval,
-                                                info[GRPNOTDELETEDINFS]);
-               }
-       }
-
-}
-
-/**
- * The function tests if the given controller is enabled in kernel
- * @param name the name of the controller to be checked
- * @param exist set to 1 if the controller exists
- */
-void is_subsystem_enabled(const char *name, int *exist)
-{
-       int hierarchy, num_cgroups, enabled;
-       FILE *fd;
-       char subsys_name[FILENAME_MAX];
-
-       fd = fopen("/proc/cgroups", "r");
-       if (!fd)
-               return;
-
-       while (!feof(fd)) {
-               fscanf(fd, "%s, %d, %d, %d", subsys_name,
-                                        &hierarchy, &num_cgroups, &enabled);
-               if (strncmp(name, subsys_name, sizeof(*name)) == 0)
-                       *exist = 1;
-       }
-
-       fclose(fd);
-}
-
-/**
- * This function tests if the given group exists in filesystem
- * @param path_group path to the group to be tested for existence
- */
-int group_exist(char *path_group)
-{
-       struct stat statbuf;
-       if (stat(path_group, &statbuf) == -1) {
-               /* Group deleted. OK */
-               if (errno == ENOENT)
-                       return ENOENT;
-               /* There is some other failure */
-               printf("stat failed, return code is %d\n", errno);
-               return -1;
-       }
-
-       if (S_ISDIR(statbuf.st_mode))
-               return 0;
-       else
-               return -1;
-}
-
-/**
- * Sets the controller name and control file name
- * @param controller the enum for the name of the controller
- * @param controller_name name of the controller
- * @param control_file corresponding control file
- */
-int set_controller(int controller, char *controller_name, char *control_file)
-{
-       switch (controller) {
-       case MEMORY:
-               if (memory == 0)
-                       return 1;
-
-               strncpy(controller_name, "memory", FILENAME_MAX);
-               strncpy(control_file, "memory.limit_in_bytes", FILENAME_MAX);
-               return 0;
-               break;
-
-       case CPU:
-               if (cpu == 0)
-                       return 1;
-
-               strncpy(controller_name, "cpu", FILENAME_MAX);
-               strncpy(control_file, "cpu.shares", FILENAME_MAX);
-               return 0;
-               break;
-
-       case CPUSET:
-               strncpy(controller_name, "cpuset", FILENAME_MAX);
-               strncpy(control_file, "cpuset.cpus", FILENAME_MAX);
-               return 0;
-               break;
-               /* Future controllers can be added here */
-
-       default:
-               printf("Invalid controller name passed. Setting controller"
-                                       " failed. Dependent tests may fail\n");
-               return 1;
-               break;
-       }
-}
-
-/**
- * Tests if a group has been modified
- * @param path_control_file path to the control file of the controller
- * @param value_type which value out of four types
- * @param struct cval the control value structure
- */
-int group_modified(char *path_control_file, int value_type,
-                                                struct cntl_val_t cval)
-{
-       bool bool_val;
-       int64_t int64_val;
-       u_int64_t uint64_val;
-       /* 100 char looks ok for a control value as string */
-       char string_val[100];
-       FILE *fd;
-       int error = 1;
-       int aux;
-
-       fd = fopen(path_control_file, "r");
-       if (!fd) {
-               fprintf(stderr, "Error in opening %s\n", path_control_file);
-               fprintf(stderr, "Skipping modified values check....\n");
-               return 1;
-       }
-
-       switch (value_type) {
-
-       case BOOL:
-               fscanf(fd, "%d", &aux);
-               bool_val = aux;
-               if (bool_val == cval.val_bool)
-                       error = 0;
-               break;
-       case INT64:
-               fscanf(fd, "%" SCNi64, &int64_val);
-               if (int64_val == cval.val_int64)
-                       error = 0;
-               break;
-       case UINT64:
-               fscanf(fd, "%" SCNu64, &uint64_val);
-               if (uint64_val == cval.val_uint64)
-                       error = 0;
-               break;
-       case STRING:
-               fscanf(fd, "%s", string_val);
-               if (!strncmp(string_val, cval.val_string, strlen(string_val)))
-                       error = 0;
-               break;
-       default:
-               fprintf(stderr, "Wrong value_type passed "
-                                               "in group_modified()\n");
-               fprintf(stderr, "Skipping modified values check....\n");
-               /* Can not report test result as failure */
-               error = 0;
-               break;
-       }
-
-       fclose(fd);
-       return error;
-}
-
-/**
- * Adds the control value to a controller using wrapper apis
- * @param newcontroller the controller to be added the value to
- * @param control_file name of the control file of the controller
- * @param wr the name of wrapper api
- * @param value_type which value out of four types
- * @param struct cval the control value structure
- */
-int add_control_value(struct cgroup_controller *newcontroller,
-        char *control_file, char *wr, int value_type, struct cntl_val_t cval)
-{
-       int retval;
-
-       switch (value_type) {
-
-       case BOOL:
-               retval = cgroup_add_value_bool(newcontroller,
-                                        control_file, cval.val_bool);
-               snprintf(wr, SIZE, "add_value_bool()");
-               break;
-       case INT64:
-               retval = cgroup_add_value_int64(newcontroller,
-                                        control_file, cval.val_int64);
-               snprintf(wr, SIZE, "add_value_int64()");
-               break;
-       case UINT64:
-               retval = cgroup_add_value_uint64(newcontroller,
-                                        control_file, cval.val_uint64);
-               snprintf(wr, SIZE, "add_value_uint64()");
-               break;
-       case STRING:
-               retval = cgroup_add_value_string(newcontroller,
-                                        control_file, cval.val_string);
-               snprintf(wr, SIZE, "add_value_string()");
-               break;
-       default:
-               printf("ERROR: wrong value in add_control_value()\n");
-               return 1;
-               break;
-       }
-       return retval;
-}
-
-/**
- * This function creates and returns a cgroup data structure
- * @param group the name of the group
- * @param controller_name the name of the controller to be added to the group
- * @param control_file name of the control file of the controller
- * @param value_type which value out of four types
- * @param struct cval the control value structure
- * @param struct ids the permissions struct
- * @param the test number
- */
-struct cgroup *new_cgroup(char *group, char *controller_name,
-                        char *control_file, int value_type,
-                        struct cntl_val_t cval, struct uid_gid_t ids, int i)
-{
-       int retval;
-       /* Names of wrapper apis */
-       char wr[SIZE];
-       struct cgroup *newcgroup;
-       struct cgroup_controller *newcontroller;
-
-       newcgroup = cgroup_new_cgroup(group);
-
-       if (newcgroup) {
-               retval = cgroup_set_uid_gid(newcgroup, ids.tasks_uid,
-                        ids.tasks_gid, ids.control_uid, ids.control_gid);
-
-               if (retval) {
-                       snprintf(wr, SIZE, "set_uid_gid()");
-                       message(i++, FAIL, wr, retval, info[NOMESSAGE]);
-               }
-
-               newcontroller = cgroup_add_controller(newcgroup,
-                                                        controller_name);
-               if (newcontroller) {
-                       retval =  add_control_value(newcontroller,
-                                        control_file, wr, value_type, cval);
-
-                       if (!retval) {
-                               message(i++, PASS, "new_cgroup()",
-                                                retval, info[NOMESSAGE]);
-                       } else {
-                               message(i++, FAIL, wr, retval ,
-                                                        info[NOMESSAGE]);
-                               cgroup_free(&newcgroup);
-                               return NULL;
-                       }
-                } else {
-                       /* Since these wrappers do not return an int so -1 */
-                       message(i++, FAIL, "add_controller", -1,
-                                                        info[NOMESSAGE]);
-                       cgroup_free(&newcgroup);
-                       return NULL;
-               }
-       } else {
-               message(i++, FAIL, "new_cgroup", -1, info[NOMESSAGE]);
-               return NULL;
-       }
-       return newcgroup;
-}
-
-/**
- * Checks if the cgroup filesystem has been mounted
- * @param multimnt to decide if check is for single mount or multimount
- */
-int check_fsmounted(int multimnt)
-{
-       int count = 0;
-       int ret = 1;
-       struct mntent *entry = NULL, *tmp_entry = NULL;
-       /* Need a better mechanism to decide memory allocation size here */
-       char entry_buffer[FILENAME_MAX * 4];
-       FILE *proc_file = NULL;
-
-       tmp_entry = (struct mntent *) malloc(sizeof(struct mntent));
-       if (!tmp_entry) {
-               perror("Error: failled to mallloc for mntent\n");
-               ret = errno;
-               goto error;
-       }
-
-       proc_file = fopen("/proc/mounts", "r");
-       if (!proc_file) {
-               printf("Error in opening /proc/mounts.\n");
-               ret = errno;
-               goto error;
-       }
-       while ((entry = getmntent_r(proc_file, tmp_entry, entry_buffer,
-                                                FILENAME_MAX*4)) != NULL) {
-               if (!strncmp(entry->mnt_type, "cgroup", strlen("cgroup"))) {
-                       count++;
-                       if (multimnt) {
-                               if (count >= 2) {
-                                       printf("sanity check pass. %s\n",
-                                                        entry->mnt_type);
-                                       ret = 0;
-                                       goto error;
-                               }
-                       } else {
-                               printf("sanity check pass. %s\n",
-                                                        entry->mnt_type);
-                               ret = 0;
-                               goto error;
-                       }
-               }
-       }
-error:
-       if (tmp_entry)
-               free(tmp_entry);
-       if (proc_file)
-               fclose(proc_file);
-       return ret;
-}
-
-/**
- * Checks if the current task belongs to the given tasks file
- * @param tasksfile the task file to be tested for the task
- */
-int check_task(char *tasksfile, pid_t pid)
-{
-       FILE *file;
-       pid_t curr_tid, tid;
-       int pass = 0;
-
-       file = fopen(tasksfile, "r");
-       if (!file) {
-               printf("ERROR: in opening %s\n", tasksfile);
-               printf("Exiting without running other testcases in this set\n");
-               exit(1);
-       }
-
-       if (pid)
-               curr_tid = pid;
-       else
-               curr_tid = cgrouptest_gettid();
-
-       while (!feof(file)) {
-               fscanf(file, "%u", &tid);
-               if (tid == curr_tid) {
-                       pass = 1;
-                       break;
-               }
-       }
-       fclose(file);
-
-       return pass;
-}
-
-/**
- * Prints the test result in a readable format with some verbose messages
- * @param num the test number
- * @param pass test passed or failed
- * @param api the name of the api tested
- * @param retval the return value of the api
- * @param extra the extra message to the user about the scenario tested
- */
-void message(int num, int pass, const char *api, int retval, char *extra)
-{
-       char res[10];
-       char buf[2*SIZE];
-       if (pass)
-               strncpy(res, "PASS :", 10);
-       else
-               strncpy(res, "FAIL :", 10);
-
-       /* Populate message buffer for the api */
-       snprintf(buf, sizeof(buf), "cgroup_%s\t\t Ret Value = ", api);
-       fprintf(stdout, "TEST%2d:%s %s%d\t%s", num, res, buf, retval, extra);
-}
-
-/**
- * Builds the path to target file/group
- * @param target to write the built path to
- * @param mountpoint for which mountpoint the path to be built
- * @param group the name of the group (directory)
- * @param file what file under the group
- */
-void
-build_path(char *target, char *mountpoint, const char *group, const char *file)
-{
-       if (!target)
-               return;
-
-       strncpy(target, mountpoint, FILENAME_MAX);
-
-       if (group) {
-               strncat(target, "/", FILENAME_MAX - strlen(target));
-               strncat(target, group, FILENAME_MAX - strlen(target));
-       }
-
-       if (file) {
-               strncat(target, "/", FILENAME_MAX - strlen(target));
-               strncat(target, file, FILENAME_MAX - strlen(target));
-       }
-}
-
-/**
- * Tests the cgroup_compare_cgroup() api under different scenarios
- * @param ctl1 controller 1 to be used for testing
- * @param ctl2 controller 1 to be used for testing
- * @param the test number
- */
-void test_cgroup_compare_cgroup(int ctl1, int ctl2, int i)
-{
-       int retval;
-
-       struct cntl_val_t cval;
-       cval.val_int64 = 0;
-       cval.val_uint64 = 0;
-       cval.val_bool = 0;
-       strcpy(cval.val_string, "5000");
-
-       struct cgroup *cgroup1 = NULL, *cgroup2 = NULL;
-       struct cgroup_controller *controller = NULL;
-       char controller_name[FILENAME_MAX], control_file[FILENAME_MAX];
-       char wr[SIZE], extra[] = "in cgroup_compare_cgroup";
-
-       retval = cgroup_compare_cgroup(NULL, NULL);
-       if (retval)
-               message(i++, PASS, "compare_cgroup()", retval, info[NULLGRP]);
-       else
-               message(i++, FAIL, "compare_cgroup()", retval, info[NULLGRP]);
-
-       cgroup1 = cgroup_new_cgroup("testgroup");
-       cgroup2 = cgroup_new_cgroup("testgroup");
-       cgroup_set_uid_gid(cgroup1, 0, 0, 0, 0);
-       cgroup_set_uid_gid(cgroup2, 0, 0, 0, 0);
-
-       retval = set_controller(ctl1, controller_name, control_file);
-
-       controller = cgroup_add_controller(cgroup1, controller_name);
-       if (controller) {
-               retval =  add_control_value(controller,
-                                        control_file, wr, STRING, cval);
-               if (retval)
-                       message(i++, FAIL, wr, retval, extra);
-       }
-
-       controller = cgroup_add_controller(cgroup2, controller_name);
-       if (controller) {
-               retval =  add_control_value(controller,
-                                        control_file, wr, STRING, cval);
-               if (retval)
-                       message(i++, FAIL, wr, retval, extra);
-       }
-
-       retval = cgroup_compare_cgroup(cgroup1, cgroup2);
-       if (retval)
-               message(i++, FAIL, "compare_cgroup()", retval, info[NOMESSAGE]);
-       else
-               message(i++, PASS, "compare_cgroup()", retval, info[NOMESSAGE]);
-
-       /* Test the api by putting diff number of controllers in cgroups */
-       retval = set_controller(ctl2, controller_name, control_file);
-       controller = cgroup_add_controller(cgroup2, controller_name);
-       if (controller) {
-               retval =  add_control_value(controller,
-                                        control_file, wr, STRING, cval);
-               if (retval)
-                       message(i++, FAIL, wr, retval, extra);
-       }
-
-       retval = cgroup_compare_cgroup(cgroup1, cgroup2);
-       if (retval == ECGROUPNOTEQUAL)
-               message(i++, PASS, "compare_cgroup()", retval, info[NOMESSAGE]);
-       else
-               message(i++, FAIL, "compare_cgroup()", retval, info[NOMESSAGE]);
-
-       cgroup_free(&cgroup1);
-       cgroup_free(&cgroup2);
-}
-
-/**
- * Tests the cgroup_get_cgroup() api under different scenarios
- * @param ctl1 controller 1 to be used for testing
- * @param ctl2 controller 1 to be used for testing
- * @param struct ids the permissions struct
- * @param the test number
- */
-void test_cgroup_get_cgroup(int ctl1, int ctl2, struct uid_gid_t ids, int i)
-{
-       struct cgroup *cgroup_filled = NULL, *cgroup_a = NULL, *cgroup_b = NULL;
-       struct cgroup_controller *controller = NULL;
-       char controller_name[FILENAME_MAX], control_file[FILENAME_MAX];
-       struct cntl_val_t cval = {0, 0, 0, "5000"};
-       int ret;
-
-       /*
-        * No need to test the next 3 scenarios separately for Multimnt
-        * so testing them only under single mount
-        */
-       if (fs_mounted == FS_MOUNTED) {
-               /* 1. Test with nullcgroup first */
-               ret = cgroup_get_cgroup(NULL);
-               if (ret == ECGROUPNOTALLOWED)
-                       message(i++, PASS, "get_cgroup()", ret, info[NULLGRP]);
-               else
-                       message(i++, FAIL, "get_cgroup()", ret, info[NULLGRP]);
-
-               /* 2. Test with invalid name filled cgroup(non existing) */
-               cgroup_filled = cgroup_new_cgroup("nogroup");
-               if (!cgroup_filled)
-                       message(i++, FAIL, "new_cgroup()", 0, info[NOMESSAGE]);
-
-               ret = cgroup_get_cgroup(cgroup_filled);
-               if (ret)
-                       message(i++, PASS, "get_cgroup()", ret,
-                                                        info[NOTCRTDGRP]);
-               else
-                       message(i++, FAIL, "get_cgroup()", ret,
-                                                        info[NOTCRTDGRP]);
-               /* Free the allocated cgroup before reallocation */
-               cgroup_free(&cgroup_filled);
-
-               /* 3.
-                * Test with name filled cgroup. Ensure the group group1 exists
-                * in the filesystem before calling this test function
-                */
-               cgroup_filled = cgroup_new_cgroup("group1");
-               if (!cgroup_filled)
-                       message(i++, FAIL, "new_cgroup()", 0, info[NOMESSAGE]);
-
-               ret = cgroup_get_cgroup(cgroup_filled);
-               if (!ret)
-                       message(i++, PASS, "get_cgroup()", ret,
-                                                        info[NOMESSAGE]);
-               else
-                       message(i++, FAIL, "get_cgroup()", ret,
-                                                        info[NOMESSAGE]);
-       }
-
-       /* SINGLE & MULTI MOUNT: Create, get and compare a cgroup */
-
-       /* get cgroup_a ds and create group_a in filesystem */
-       cgroup_a = create_new_cgroup_ds(ctl1, "group_a", STRING, cval, ids, 0);
-       if (fs_mounted == FS_MULTI_MOUNTED) {
-               /* Create under another controller also */
-               ret = set_controller(ctl2, controller_name, control_file);
-               controller = cgroup_add_controller(cgroup_a, controller_name);
-               if (controller)
-                       message(i++, PASS, "cgroup_add_controller()",
-                                       0, info[NOMESSAGE]);
-               else
-                       message(i++, FAIL, "cgroup_add_controller()",
-                                       -1, info[NOMESSAGE]);
-       }
-       test_cgroup_create_cgroup(0, cgroup_a, "group_a", 0, 1, 1, 00);
-
-       /* create group_b ds to be filled by cgroup_get_cgroup */
-       cgroup_b = cgroup_new_cgroup("group_a");
-       if (!cgroup_b)
-               message(i++, FAIL, "new_cgroup()", 0, info[NOMESSAGE]);
-       /* Fill the ds and compare the two */
-       ret = cgroup_get_cgroup(cgroup_b);
-       if (!ret) {
-               ret = cgroup_compare_cgroup(cgroup_a, cgroup_b);
-               if (ret == 0)
-                       message(i++, PASS, "get_cgroup()", ret, info[SAMEGRP]);
-               else
-                       message(i++, FAIL, "get_cgroup()", ret,
-                                                        info[NOMESSAGE]);
-       } else {
-               message(i++, FAIL, "get_cgroup()", ret, info[NOMESSAGE]);
-       }
-
-       /* Delete this created group from fs to leave fs clean */
-       if (fs_mounted == FS_MULTI_MOUNTED)
-               test_cgroup_delete_cgroup(0, cgroup_a, "group_a", 1, 1, 0, 0);
-       else
-               test_cgroup_delete_cgroup(0, cgroup_a, "group_a", 0, 1, 0, 0);
-
-       cgroup_free(&cgroup_a);
-       cgroup_free(&cgroup_b);
-       cgroup_free(&cgroup_filled);
-}
-
-/**
- * Tests the cgroup_add_controller() and cgroup_free_controller() wrapper
- * apis under different scenarios
- * @param the test number
- */
-void test_cgroup_add_free_controller(int i)
-{
-       struct cgroup *cgroup1 = NULL, *cgroup2 = NULL;
-       struct cgroup_controller *cgctl1, *cgctl2;
-
-       /* Test with a Null cgroup */
-       cgctl1 = cgroup_add_controller(cgroup1, "cpu");
-       if (!cgctl1)
-               message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]);
-       else
-               message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]);
-
-       cgroup1 = cgroup_new_cgroup("testgroup");
-       cgctl1 = cgroup_add_controller(cgroup1, "cpuset");
-       if (cgctl1)
-               message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]);
-       else
-               message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]);
-
-       cgctl2 = cgroup_add_controller(cgroup1, "cpu");
-       if (cgctl2)
-               message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]);
-       else
-               message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]);
-
-       cgroup_free(&cgroup1);
-       cgroup_free_controllers(cgroup2);
-}
-
-/**
- * Returns the tid of the current thread
- */
-pid_t cgrouptest_gettid()
-{
-       return syscall(__NR_gettid);
-}
diff --git a/tests/test_named_hierarchy.c b/tests/test_named_hierarchy.c
deleted file mode 100644 (file)
index 934c875..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <libcgroup.h>
-
-/*
- * Assumes cgroup is mounted at /cgroup using
- *
- * mount -t cgroup -o none,name=test none /cgroup
- */
-int main()
-{
-       int ret;
-       struct cgroup *cgroup;
-       struct cgroup_controller *cgc;
-
-       ret = cgroup_init();
-       if (ret) {
-               printf("FAIL: cgroup_init failed with %s\n", cgroup_strerror(ret));
-               exit(3);
-       }
-
-       cgroup = cgroup_new_cgroup("test");
-       if (!cgroup) {
-               printf("FAIL: cgroup_new_cgroup failed\n");
-               exit(3);
-       }
-
-       cgc = cgroup_add_controller(cgroup, "name=test");
-       if (!cgc) {
-               printf("FAIL: cgroup_add_controller failed\n");
-               exit(3);
-       }
-
-       ret = cgroup_create_cgroup(cgroup, 1);
-       if (ret) {
-               printf("FAIL: cgroup_create_cgroup failed with %s\n", cgroup_strerror(ret));
-               exit(3);
-       }
-
-       if (access("/cgroup/test", F_OK))
-               printf("PASS\n");
-       else
-               printf("Failed to create cgroup\n");
-
-       return 0;
-}
diff --git a/tests/tools/Makefile.am b/tests/tools/Makefile.am
deleted file mode 100644 (file)
index 45c1955..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-SUBDIRS = cgconfigparser cgclassify multimount
-
diff --git a/tests/tools/README b/tests/tools/README
deleted file mode 100644 (file)
index ec4703e..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-libcgroup tools test suite
-==========================
-
-These files should test libcgroup tools, not the libcgroup library itself! All
-the tools use the library so it gets pretty well tested, but that's just a side
-effect, not an intention.
-
-Usage
------
-
-There are few requirements to run this test:
- - !!! YOU MUST RUN THE TESTS AS ROOT !!! - the tests need to mount/unmount
-   stuff. The tests should not destroy anything important, but use a virtual
-   machine if possible, just to be sure.
- - You must have no cgroup mounted (i.e. run cgclear before starting the test
-   suite).
- - The tests require various tools to be present in $PATH or at the specified
-   location, among others:
-   diff, awk, su, /bin/bash, /bin/sleep
- - The tests require that user and group named 'nobody' exists, some processes
-   with be started with its UID/GID.
- - The tests mounts/unmounts cpu, cpuacct, freezer and net_cls controllers.
-   Make sure your kernel supports them.
-
-If you have met all above prerequisites just run 'make check' in this directory
-as root.
-
-Design
-------
-There is very simple testenv.sh script, which contains common functions for all
-tests. It includes also simple example how to write a test.
-
-The tests themselves are just simple shell scripts, which either end with exit
-status 0 (=success) or nonzero (=error). The tests should clean after themselves
-(incl. unmounting all groups and removing all temp. files).
diff --git a/tests/tools/cgclassify/Makefile.am b/tests/tools/cgclassify/Makefile.am
deleted file mode 100644 (file)
index 2adde69..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-EXTRA_DIST = cgclassify cgclassify-rules simple.conf
-
-# The legacy tests have been disabled because they do not successfully run
-# on Travis CI.
-#TESTS = cgclassify cgclassify-rules
diff --git a/tests/tools/cgclassify/cgclassify b/tests/tools/cgclassify/cgclassify
deleted file mode 100755 (executable)
index 9560a15..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/bin/bash
-#
-# Test cgclassify with various arguments, without /etc/cgrules.conf.
-# cglassify is tested with exact destination group, multiple PIDs, groups
-# specified by '*', multiple target groups, lot of PIDs on command line
-# and various error cases.
-
-. `dirname $0`/../testenv.sh
-
-function checkpid()
-{
-       # check that given process is in given groups
-       local PID=$1
-       # delete hierarchy number, ignore systemd
-       cat /proc/$PID/cgroup | sed 's/^[0-9]*://' | grep -v systemd > $TMP/pid-$PID.group
-       printf >$TMP/pid-$PID.expected "$2"
-       diff -u -w $TMP/pid-$PID.group $TMP/pid-$PID.expected
-       return $?
-}
-
-function resetgroup()
-{
-       # move given processes back to root group
-       $TOOLSDIR/cgclassify -g "*:/" $*
-}
-
-# prepare some hierarchy
-$TOOLSDIR/cgconfigparser -l `prepare_config simple.conf` || \
-       die "cannot parse simple.conf"
-
-# start few processes to torture
-/bin/sleep 10000 &
-PID1=$!
-/bin/sleep 10000 &
-PID2=$!
-/bin/sleep 10000 &
-PID3=$!
-
-# STEP1: simple cgclassify to exact groups
-$TOOLSDIR/cgclassify -g net_cls,cpu:common $PID1 || \
-       die "STEP1: cgclassify PID1 failed"
-$TOOLSDIR/cgclassify -g net_cls:net1 $PID2 || \
-       die "STEP1: cgclassify PID2 failed"
-$TOOLSDIR/cgclassify -g cpu:cpu1 $PID3 || \
-       die "STEP1: cgclassify PID3 failed"
-
-checkpid $PID1 "net_cls,freezer:/common\ncpuacct,cpu:/common\n" || \
-       die "STEP1: unexpected group of pid1"
-checkpid $PID2 "net_cls,freezer:/net1\ncpuacct,cpu:/\n" || \
-       die "STEP!: unexpected group of pid2"
-checkpid $PID3 "net_cls,freezer:/\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP!: unexpected group of pid3"
-
-# STEP2: try * and more PIDs
-$TOOLSDIR/cgclassify -g "*:/" $PID1 $PID2 $PID3 || \
-       die "cgclassify 2 failed"
-checkpid $PID1 "net_cls,freezer:/\ncpuacct,cpu:/\n" || \
-       die "STEP2: unexpected group of pid1"
-checkpid $PID2 "net_cls,freezer:/\ncpuacct,cpu:/\n" || \
-       die "STEP2: unexpected group of pid2"
-checkpid $PID3 "net_cls,freezer:/\ncpuacct,cpu:/\n" || \
-       die "STEP2: unexpected group of pid3"
-
-# STEP3: try different groups
-resetgroup $PID1 $PID2 $PID3
-$TOOLSDIR/cgclassify -g cpu:cpu1 -g net_cls:net1 $PID1
-checkpid $PID1 "net_cls,freezer:/net1\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP3: unexpected group of pid1"
-
-# STEP4: different groups multiple times (tha last should win)
-resetgroup $PID1 $PID2 $PID3
-$TOOLSDIR/cgclassify -g "*:/" -g cpu:common -g net_cls:common -g cpu:cpu1 -g net_cls:net1 $PID1 || \
-       die "STEP4: cgclassify pid1 failed"
-checkpid $PID1 "net_cls,freezer:/net1\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP4: unexpected group of pid1"
-$TOOLSDIR/cgclassify -g "*:/" -g cpu:common -g net_cls:common -g cpu:cpu1 $PID2 || \
-       die "STEP4: cgclassify pid2 failed"
-checkpid $PID2 "net_cls,freezer:/common\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP4: unexpected group of pid2"
-
-# STEP5: some error cases
-# group does not exist
-echo "Testing error cases, error messages will appear!"
-$TOOLSDIR/cgclassify -g cpu:invalid_group $PID1 && \
-       die "STEP5: cgclassify with invalig_group succeeded"
-# parameter is not a PID
-$TOOLSDIR/cgclassify -g cpu:/ xxx && \
-       die "STEP5: cgclassify with xxx pid succeeded"
-# let's hope process 1234567 does not exist
-$TOOLSDIR/cgclassify -g cpu:/ 1234567 && \
-       die "STEP5: cgclassify with 1234567 succeeded"
-# not-mounted controller
-$TOOLSDIR/cgclassify -g xxx:/ $PID1 && \
-       die "STEP5: cgclassify with xxx controller succeeded"
-# no -g parameter
-$TOOLSDIR/cgclassify -g  $PID1 && \
-       die "STEP5: cgclassify without -g succeeded"
-# invalid -g format
-$TOOLSDIR/cgclassify -g  cpu/cpu1 $PID1 && \
-       die "STEP5: cgclassify -g cpu/cpu1 succeeded"
-
-# some existing processes among unexisting
-resetgroup $PID1 $PID2 $PID3
-$TOOLSDIR/cgclassify -g cpu,net_cls:common $PID1 1234567 $PID2 1234568 $PID3 && \
-       die "STEP5: cgclassify with mixed processed succeeded"
-checkpid $PID1 "net_cls,freezer:/common\ncpuacct,cpu:/common\n" || \
-       die "STEP5: unexpected group of pid1"
-checkpid $PID2 "net_cls,freezer:/common\ncpuacct,cpu:/common\n" || \
-       die "STEP5: unexpected group of pid2"
-checkpid $PID3 "net_cls,freezer:/common\ncpuacct,cpu:/common\n" || \
-       die "STEP5: unexpected group of pid3"
-
-echo "End of error cases"
-
-# STEP6: *lot of* processes on command line
-echo "Testing lot of arguments, this will take some time"
-COUNT=1000
-echo >$TMP/pids
-(
-       for i in `seq $COUNT`; do
-               sleep 100000 &
-               echo $! >>$TMP/pids
-       done
-) > /dev/null
-$TOOLSDIR/cgclassify -g net_cls,cpu:common `cat $TMP/pids` || \
-       die "STEP6: cgclassify failed"
-
-kill `cat $TMP/pids`
-sleep 1 # to settle down the sleep load - sigterm does not kill sleep immediatelly
-
-kill $PID1 $PID2 $PID3
-$TOOLSDIR/cgclear
-cleanup
-exit 0
diff --git a/tests/tools/cgclassify/cgclassify-rules b/tests/tools/cgclassify/cgclassify-rules
deleted file mode 100755 (executable)
index b2b2cd8..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-#!/bin/bash
-#
-# Test cgclassify with various /etc/cgrules.conf settings, like
-# simple rules, multiple matching rules, using @groups, executable
-# names and default rules.
-# The test relies on testenv.sh to backup/restore /etc/cgrules.conf.
-#
-
-. `dirname $0`/../testenv.sh
-
-# The test need sto start few processes with non-root UID/GID. Which should be
-# used?
-TESTUSER=nobody
-TESTGROUP=nobody
-
-function checkpid()
-{
-       # check that given process is in given groups
-       local PID=$1
-       # delete hierarchy number, ignore systemd
-       cat /proc/$PID/cgroup | sed 's/^[0-9]*://' | grep -v systemd > $TMP/pid-$PID.group
-       printf >$TMP/pid-$PID.expected "$2"
-       diff -u -w $TMP/pid-$PID.group $TMP/pid-$PID.expected
-       return $?
-}
-
-function resetgroup()
-{
-       # move given processes back to root group
-       $TOOLSDIR/cgclassify -g "*:/" $*
-}
-
-# prepare some hierarchy
-$TOOLSDIR/cgconfigparser -l `prepare_config simple.conf` || \
-       die "cannot parse simple.conf"
-
-# prepare specific process names
-ln -s /bin/sleep $TMP/sleep1
-$TMP/sleep1 10000 &
-PID1=$!
-ln -s /bin/sleep $TMP/sleep2
-$TMP/sleep2 10000 &
-PID2=$!
-
-# start some processes as $TESTUSER
-chmod o+rwX $TMP
-su $TESTUSER -s /bin/bash -c "$TMP/sleep1 10000" &
-su $TESTUSER -s /bin/bash -c "$TMP/sleep2 10000" &
-sleep 0.1
-NPID1=`ps h -u $TESTUSER | grep sleep1 | awk  '{ print $1; }' | tail -n 1`
-NPID2=`ps h -u $TESTUSER | grep sleep2 | awk  '{ print $1; }' | tail -n 1`
-
-# STEP1: simple global rule
-cat <<EOF >/etc/cgrules.conf
-unused *       /
-*      *       common
-EOF
-$TOOLSDIR/cgclassify $PID1
-checkpid $PID1 "net_cls,freezer:/common\ncpuacct,cpu:/common\n" || \
-       die "STEP1: unexpected group of pid1"
-resetgroup $PID1
-
-# STEP2: two destination groups
-cat <<EOF >/etc/cgrules.conf
-unused *       /
-*      cpu     cpu1
-%      net_cls net1
-EOF
-$TOOLSDIR/cgclassify $PID1
-checkpid $PID1 "net_cls,freezer:/net1\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP2: unexpected group of pid1"
-resetgroup $PID1
-
-# STEP3: two matching rules, only the first is executed
-cat <<EOF >/etc/cgrules.conf
-unused *       /
-*      cpu     cpu1
-*      net_cls net1
-EOF
-$TOOLSDIR/cgclassify $PID1
-checkpid $PID1 "net_cls,freezer:/\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP3: unexpected group of pid1"
-resetgroup $PID1
-
-# STEP4: process name in a rule
-cat <<EOF >/etc/cgrules.conf
-unused *       /
-*:sleep1       cpu     cpu1
-*:sleep2       net_cls net1
-EOF
-$TOOLSDIR/cgclassify $PID1
-checkpid $PID1 "net_cls,freezer:/\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP4: unexpected group of pid1"
-$TOOLSDIR/cgclassify $PID2
-checkpid $PID2 "net_cls,freezer:/net1\ncpuacct,cpu:/\n" || \
-       die "STEP4: unexpected group of pid2"
-resetgroup $PID1 $PID2
-
-# STEP5: full path
-cat <<EOF >/etc/cgrules.conf
-unused *       /
-*:$TMP/sleep1  cpu     cpu1
-*:$TMP/sleep2  net_cls net1
-EOF
-$TOOLSDIR/cgclassify $PID1
-checkpid $PID1 "net_cls,freezer:/\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP5: unexpected group of pid1"
-$TOOLSDIR/cgclassify $PID2
-checkpid $PID2 "net_cls,freezer:/net1\ncpuacct,cpu:/\n" || \
-       die "STEP5: unexpected group of pid2"
-resetgroup $PID1 $PID2
-
-#STEP6: username
-cat <<EOF >/etc/cgrules.conf
-unused *       /
-$TESTUSER      cpu     cpu1
-*      net_cls net1
-EOF
-$TOOLSDIR/cgclassify $PID1 $NPID1
-checkpid $NPID1 "net_cls,freezer:/\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP6: unexpected group of npid1"
-checkpid $PID1 "net_cls,freezer:/net1\ncpuacct,cpu:/\n" || \
-       die "STEP6: unexpected group of pid1"
-resetgroup $PID1 $NPID1
-
-#STEP7: username + processname
-cat <<EOF >/etc/cgrules.conf
-unused *       /
-$TESTUSER:$TMP/sleep1  cpu     cpu1
-*:$TMP/sleep1  net_cls net1
-EOF
-$TOOLSDIR/cgclassify $PID1 $NPID1
-checkpid $NPID1 "net_cls,freezer:/\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP7: unexpected group of npid1"
-checkpid $PID1 "net_cls,freezer:/net1\ncpuacct,cpu:/\n" || \
-       die "STEP7: unexpected group of pid1"
-resetgroup $PID1 $NPID1
-
-#STEP8: groupname + processname
-cat <<EOF >/etc/cgrules.conf
-unused *       /
-@$TESTGROUP:$TMP/sleep1        cpu     cpu1
-*:$TMP/sleep1  net_cls net1
-EOF
-$TOOLSDIR/cgclassify $PID1 $NPID1
-checkpid $NPID1 "net_cls,freezer:/\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP8: unexpected group of npid1"
-checkpid $PID1 "net_cls,freezer:/net1\ncpuacct,cpu:/\n" || \
-       die "STEP8: unexpected group of pid1"
-resetgroup $PID1 $NPID1
-
-#STEP9: processname + default
-cat <<EOF >/etc/cgrules.conf
-unused *       /
-*:$TMP/sleep1  cpu     cpu1
-*      net_cls net1
-EOF
-$TOOLSDIR/cgclassify $PID1 $PID2
-checkpid $PID1 "net_cls,freezer:/\ncpuacct,cpu:/cpu1\n" || \
-       die "STEP9: unexpected group of pid1"
-checkpid $PID2 "net_cls,freezer:/net1\ncpuacct,cpu:/\n" || \
-       die "STEP9: unexpected group of pid2"
-resetgroup $PID1 $NPID1
-
-kill -9 $PID1 $PID2 $NPID1 $NPID2
-
-sleep 0.1
-$TOOLSDIR/cgclear
-
-cleanup
-exit 0
diff --git a/tests/tools/cgclassify/simple.conf b/tests/tools/cgclassify/simple.conf
deleted file mode 100644 (file)
index 07f8ccd..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# Two hierarchies, two controllers each:
-
-mount {
-    cpu = TMP/cgroup/cpu;
-    cpuacct = TMP/cgroup/cpu;
-    net_cls = TMP/cgroup/net;
-    freezer = TMP/cgroup/net;
-}
-
-# One group common for all hierarchies:
-
-group common {
-    cpu {}
-    net_cls {}
-}
-
-# Two separate groups:
-group net1 {
-    net_cls{}
-}
-
-group cpu1 {
-    cpu {}
-}
diff --git a/tests/tools/cgconfigparser/Makefile.am b/tests/tools/cgconfigparser/Makefile.am
deleted file mode 100644 (file)
index fd28516..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-EXTRA_DIST = cgconfigparser_simple \
-             cgconfigparser_conf_files_tests \
-             cgconfigparser_conf_files/cgconfig.conf.5.ex1 \
-             cgconfigparser_conf_files/cgconfig.conf.5.ex2 \
-             cgconfigparser_conf_files/cgconfig.conf.5.ex3 \
-             cgconfigparser_conf_files/cgconfig.conf.5.ex4 \
-             cgconfigparser_conf_files/permissions.conf \
-            cgconfigparser_multiconfig \
-            cgclear_config_multi \
-            cgclear_config_one \
-            permissions \
-            cgconfigparser_conf_files/permissions_default1.conf \
-            cgconfigparser_conf_files/permissions_default2.conf \
-            cgconfigparser_conf_files/permissions_default3.conf \
-            cgconfigparser_conf_files/permissions_default4.conf \
-            multiconfig/1.conf \
-            multiconfig/2.conf \
-            multiconfig/3.conf \
-            multiconfig/4.conf \
-            multiconfig/5.conf \
-            cgclear/cgclear_config_multi_1.conf \
-            cgclear/cgclear_config_multi_2.conf \
-            cgclear/cgclear_config_multi_3.conf \
-            cgclear/cgclear_config_one.conf
-
-# The legacy tests have been disabled because they do not successfully run
-# on Travis CI.
-#TESTS = cgconfigparser_simple cgconfigparser_conf_files_tests permissions \
-#      cgconfigparser_multiconfig cgclear_config_multi cgclear_config_one
-
diff --git a/tests/tools/cgconfigparser/cgclear/cgclear_config_multi_1.conf b/tests/tools/cgconfigparser/cgclear/cgclear_config_multi_1.conf
deleted file mode 100644 (file)
index 106be83..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-mount {
-    cpu = /TMP/cgroups/cpu;
-    cpuacct = /TMP/cgroups/cpu;
-}
-
-group 1 {
-    cpu { }
-}
-
-group 1/1 {
-    cpu { }
-}
diff --git a/tests/tools/cgconfigparser/cgclear/cgclear_config_multi_2.conf b/tests/tools/cgconfigparser/cgclear/cgclear_config_multi_2.conf
deleted file mode 100644 (file)
index 67d1d5a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-group 2 {
-    cpu { }
-}
-
-group 1/2 {
-    cpu { }
-}
-
-group 1/2/2 {
-    cpu { }
-}
diff --git a/tests/tools/cgconfigparser/cgclear/cgclear_config_multi_3.conf b/tests/tools/cgconfigparser/cgclear/cgclear_config_multi_3.conf
deleted file mode 100644 (file)
index 48c5f29..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-group 3 {
-    cpu { }
-}
-
-group 1/2/3 {
-    cpu { }
-}
-
-group 1/2/2/3 {
-    cpu { }
-}
-
-group 1/3 {
-    cpu { }
-}
-
-group 2/3 {
-    cpu { }
-}
diff --git a/tests/tools/cgconfigparser/cgclear/cgclear_config_one.conf b/tests/tools/cgconfigparser/cgclear/cgclear_config_one.conf
deleted file mode 100644 (file)
index 37b32f1..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-mount {
-    cpu = /TMP/cgroups/cpu;
-    cpuacct = /TMP/cgroups/cpu;
-}
-
-group first {
-    cpu { }
-}
-
-group first/subgroup {
-    cpu { }
-}
-
-group second {
-    cpu { }
-}
diff --git a/tests/tools/cgconfigparser/cgclear_config_multi b/tests/tools/cgconfigparser/cgclear_config_multi
deleted file mode 100755 (executable)
index 964c61d..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-# test cgclear with multiple config files
-
-. `dirname $0`/../testenv.sh
-
-# start a process to torture
-/bin/sleep 10000 &
-PID=$!
-
-# STEP1: parse three config files and cgclear them at once (in reverse order!)
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_1.conf` \
-       || die "STEP1: cgconfigparser multi_1 failed"
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_2.conf` \
-       || die "STEP1: cgconfigparser multi_2 failed"
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_3.conf` \
-       || die "STEP1: cgconfigparser multi_3 failed"
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep 1/2/3 <$TMP/groups.log >/dev/null \
-       || die "STEP1: cannot find group '1/2/3'"
-
-# clear it all
-$TOOLSDIR/cgclear -e -l `prepare_config cgclear/cgclear_config_multi_1.conf` \
-       -l `prepare_config cgclear/cgclear_config_multi_2.conf` \
-       -l `prepare_config cgclear/cgclear_config_multi_3.conf` \
-       || die "STEP1: cgclear failed"
-
-# check all is gone
-$TOOLSDIR/lscgroup 2>/dev/null \
-       && die "STEP1: something is mounted after cgclear"
-
-
-# STEP2: same as step1, but in wrong order - cgclear should fail
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_1.conf` \
-       || die "STEP2: cgconfigparser multi_1 failed"
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_2.conf` \
-       || die "STEP2: cgconfigparser multi_2 failed"
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_multi_3.conf` \
-       || die "STEP2: cgconfigparser multi_3 failed"
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep 1/2/3 <$TMP/groups.log >/dev/null \
-       || die "STEP2: cannot find group '1/2/3'"
-
-# clear it all
-$TOOLSDIR/cgclear -e -l `prepare_config cgclear/cgclear_config_multi_3.conf` \
-       -l `prepare_config cgclear/cgclear_config_multi_2.conf` \
-       -l `prepare_config cgclear/cgclear_config_multi_1.conf` \
-       || die "STEP2: cgclear failed"
-
-# check that cpu,cpuacct:/1/2 still exists
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep 1/2 <$TMP/groups.log >/dev/null \
-       || die "STEP2: cannot find group '1/2 after cgclear"
-
-$TOOLSDIR/cgclear
-
-
-cleanup
-kill -9 $PID
-exit 0
diff --git a/tests/tools/cgconfigparser/cgclear_config_one b/tests/tools/cgconfigparser/cgclear_config_one
deleted file mode 100755 (executable)
index e673917..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/bin/bash
-# test cgclear with one config file
-
-. `dirname $0`/../testenv.sh
-
-# start a process to torture
-/bin/sleep 10000 &
-PID=$!
-
-# STEP1: parse one simple config with mount and cgclear it (incl. unmount)
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_one.conf` \
-       || die "STEP1: cgconfigparser failed"
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep first <$TMP/groups.log >/dev/null \
-       || die "STEP1: cannot find group 'first'"
-
-# unmount it
-$TOOLSDIR/cgclear -l `prepare_config cgclear/cgclear_config_one.conf` \
-       || die "STEP1: cgclear failed"
-
-# check all is gone
-$TOOLSDIR/lscgroup 2>/dev/null \
-       && die "STEP1: something is mounted after cgclear"
-
-
-# STEP2: create a cgroup out of config's tree - it must survive cgclear
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_one.conf` \
-       || die "STEP2: cgconfigparser failed"
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep first <$TMP/groups.log >/dev/null \
-       || die "STEP2: cannot find group 'first'"
-
-$TOOLSDIR/cgcreate -g cpu:/evil \
-       || die "STEP2: cgcreate failed"
-
-# clear it - 'evil' should survive
-$TOOLSDIR/cgclear -l `prepare_config cgclear/cgclear_config_one.conf` \
-       || die "STEP2: cgclear1 failed"
-
-# check evil is there
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep evil <$TMP/groups.log >/dev/null \
-       || die "STEP2: evil not found"
-
-# clear everything
-$TOOLSDIR/cgclear || die "STEP2: cgclear2 failed"
-$TOOLSDIR/lscgroup 2>/dev/null \
-       && die "STEP2: something is mounted after cgclear"
-
-
-# STEP3: leave a process and a subgroup somewhere and check cgclear *without* -e clears it
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_one.conf` \
-       || die "STEP3: cgconfigparser failed"
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep first <$TMP/groups.log >/dev/null \
-       || die "STEP3: cannot find group 'first'"
-
-$TOOLSDIR/cgclassify -g cpu:first $PID \
-       || die "STEP3: cgclassify failed"
-$TOOLSDIR/cgcreate -g cpu:first/evil \
-       || die "STEP3: cgcreate failed"
-
-# unmount it
-$TOOLSDIR/cgclear -l `prepare_config cgclear/cgclear_config_one.conf` \
-       || die "STEP3: cgclear failed"
-
-# check all is gone
-$TOOLSDIR/lscgroup 2>/dev/null \
-       && die "STEP3: something is mounted after cgclear"
-
-
-
-# STEP4: leave a process somewhere and check cgclear with -e doesn't clear it
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_one.conf` \
-       || die "STEP4: cgconfigparser failed"
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep first <$TMP/groups.log >/dev/null \
-       || die "STEP4: cannot find group 'first'"
-
-$TOOLSDIR/cgclassify -g cpu:first $PID \
-       || die "STEP4: cgclassify failed"
-
-# try to clear it - cgclear should not fail and the group should survive
-$TOOLSDIR/cgclear -e -l `prepare_config cgclear/cgclear_config_one.conf` \
-       || die "STEP4: cgclear failed"
-$TOOLSDIR/lscgroup > $TMP/groups2.log
-grep first <$TMP/groups2.log >/dev/null \
-       || die "STEP4: cannot find group 'first' after cgclear"
-
-# cpu:first should survive
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep first <$TMP/groups.log >/dev/null \
-       || die "STEP4: cannot find group 'first'"
-# cpu:second should *not* survive
-grep second <$TMP/groups.log >/dev/null \
-       && die "STEP4: unexpected group 'second' found"
-# cpu:first/subgroup should *not* survive
-grep first/subgroup  <$TMP/groups.log >/dev/null \
-       && die "STEP4: unexpected group 'first/subgroup' found"
-
-$TOOLSDIR/cgclear
-
-# check all is gone
-$TOOLSDIR/lscgroup 2>/dev/null \
-       && die "STEP4: something is mounted after cgclear"
-
-
-
-# STEP5: leave a subgroup somewhere and check cgclear with -e doesn't clear it
-$TOOLSDIR/cgconfigparser -l `prepare_config cgclear/cgclear_config_one.conf` \
-       || die "STEP5: cgconfigparser failed"
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep first <$TMP/groups.log >/dev/null \
-       || die "STEP5: cannot find group 'first'"
-
-$TOOLSDIR/cgcreate -g cpu:first/evil \
-       || die "STEP5: cgcreate failed"
-
-# try to clear it - cgclear should not fail, the group should survive
-$TOOLSDIR/cgclear -e -l `prepare_config cgclear/cgclear_config_one.conf` \
-       || die "STEP5: cgclear failed"
-$TOOLSDIR/lscgroup > $TMP/groups2.log
-grep first <$TMP/groups2.log >/dev/null \
-       || die "STEP5: cannot find group 'first' after clear"
-
-# cpu:first/evil should survive
-$TOOLSDIR/lscgroup > $TMP/groups.log
-grep first/evil <$TMP/groups.log >/dev/null \
-       || die "STEP5: cannot find group 'first/evil'"
-# cpu:second should *not* survive
-grep second <$TMP/groups.log >/dev/null \
-       && die "STEP5: unexpected group 'second' found"
-# cpu:first/subgroup should *not* survive
-grep first/subgroup  <$TMP/groups.log >/dev/null \
-       && die "STEP5: unexpected group 'first/subgroup' found"
-
-$TOOLSDIR/cgclear
-
-# check all is gone
-$TOOLSDIR/lscgroup 2>/dev/null \
-       && die "STEP4: something is mounted after cgclear"
-
-kill -9 $PID
-
-cleanup
-exit 0
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex1 b/tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex1
deleted file mode 100644 (file)
index b8bb9f1..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-              mount {
-                     cpu = /TMP/cgroups/cpu;
-                     cpuacct = /TMP/cgroups/cpu;
-              }
-
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex2 b/tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex2
deleted file mode 100644 (file)
index 182290c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-              mount {
-                     cpu = /TMP/cgroups/cpu;
-                     cpuacct = /TMP/cgroups/cpu;
-              }
-
-              group daemons/www {
-                     perm {
-                            task {
-                                   uid = root;
-                                   gid = nobody;
-                            }
-                            admin {
-                                   uid = root;
-                                   gid = root;
-                            }
-                     }
-                     cpu {
-                            cpu.shares = "1000";
-                     }
-              }
-
-              group daemons/ftp {
-                     perm {
-                            task {
-                                   uid = root;
-                                   gid = nobody;
-                            }
-                            admin {
-                                   uid = root;
-                                   gid = root;
-                            }
-                     }
-                     cpu {
-                            cpu.shares = "500";
-                     }
-              }
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex3 b/tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex3
deleted file mode 100644 (file)
index f733f57..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-              mount {
-                     cpu = /TMP/cgroups/cpu;
-                     cpuacct = /TMP/cgroups/cpuacct;
-              }
-
-              group daemons {
-                     cpuacct{
-                     }
-                     cpu {
-                     }
-              }
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex4 b/tests/tools/cgconfigparser/cgconfigparser_conf_files/cgconfig.conf.5.ex4
deleted file mode 100644 (file)
index 16eb5f4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-              mount {
-                     cpu = /TMP/cgroups/cpu;
-                     cpuacct = /TMP/cgroups/cpuacct;
-              }
-
-              group daemons {
-                     cpuacct{
-                     }
-              }
-
-              group daemons/www {
-                     cpu {
-                            cpu.shares = "1000";
-                     }
-              }
-
-              group daemons/ftp {
-                     cpu {
-                            cpu.shares = "500";
-                     }
-              }
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions.conf b/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions.conf
deleted file mode 100644 (file)
index e61f4e1..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-              mount {
-                     cpu = /TMP/cgroups/cpu;
-                     cpuacct = /TMP/cgroups/cpu;
-              }
-
-              group daemons/www {
-                     perm {
-                            task {
-                                   uid = root;
-                                   gid = nobody;
-                                   fperm = 750;
-                            }
-                            admin {
-                                   uid = root;
-                                   gid = root;
-                                   dperm = 770;
-                                   fperm = 777;
-                            }
-                     }
-                     cpu {
-                            cpu.shares = "1000";
-                     }
-              }
-
-              group daemons/ftp {
-                     perm {
-                            task {
-                                   uid = root;
-                                   gid = nobody;
-                                   fperm = 274;
-                            }
-                            admin {
-                                   uid = root;
-                                   gid = root;
-                                   dperm = 742;
-                                   fperm = 427;
-                            }
-                     }
-                     cpu {
-                            cpu.shares = "500";
-                     }
-              }
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default1.conf b/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default1.conf
deleted file mode 100644 (file)
index 3138d11..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-mount {
-       cpu = /TMP/cgroups/cpu;
-       cpuacct = /TMP/cgroups/cpu;
-}
-
-default {
-       perm {
-               task {
-                       uid=nobody;
-                       gid=nobody;
-                       fperm=757;
-               }
-               admin {
-                       uid = nobody;
-                       gid = nobody;
-                       dperm = 757;
-                       fperm = 757;
-               }
-       }
-}
-
-# inherit default
-group daemons/www {
-       cpu {
-               cpu.shares = "1000";
-       }
-}
-
-#override default
-group daemons/ftp {
-       perm {
-               task {
-                       uid = root;
-                       gid = root;
-                       fperm = 274;
-               }
-               admin {
-                       uid = root;
-                       gid = root;
-                       dperm = 742;
-                       fperm = 427;
-               }
-       }
-       cpu {
-               cpu.shares = "500";
-       }
-}
-
-# override some default
-group daemons/ssh {
-       perm {
-               task {
-                       uid = root;
-                       fperm = 274;
-               }
-               admin {
-                       uid = root;
-                       fperm = 427;
-               }
-       }
-       cpu {
-               cpu.shares = "500";
-       }
-}
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default2.conf b/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default2.conf
deleted file mode 100644 (file)
index b8021ea..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-mount {
-       cpu = /TMP/cgroups/cpu;
-       cpuacct = /TMP/cgroups/cpu;
-}
-
-default {
-       perm {
-               task {
-                       uid=root;
-                       gid=root;
-                       fperm=700;
-               }
-               admin {
-                       uid = root;
-                       gid = root;
-                       dperm = 700;
-                       fperm = 700;
-               }
-       }
-}
-
-
-# inherit default
-group daemons/www {
-       cpu {
-               cpu.shares = "1000";
-       }
-}
-
-#override default
-group daemons/ftp {
-       perm {
-               task {
-                       uid = root;
-                       gid = root;
-                       fperm = 274;
-               }
-               admin {
-                       uid = root;
-                       gid = root;
-                       dperm = 742;
-                       fperm = 427;
-               }
-       }
-       cpu {
-               cpu.shares = "500";
-       }
-}
-
-# override some default
-group daemons/ssh {
-       perm {
-               task {
-                       uid = root;
-                       fperm = 274;
-               }
-               admin {
-                       uid = root;
-                       fperm = 427;
-               }
-       }
-       cpu {
-               cpu.shares = "500";
-       }
-}
-
-# second default, wins
-default {
-       perm {
-               task {
-                       uid=nobody;
-                       gid=nobody;
-                       fperm=757;
-               }
-               admin {
-                       uid = nobody;
-                       gid = nobody;
-                       dperm = 757;
-                       fperm = 757;
-               }
-       }
-}
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default3.conf b/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default3.conf
deleted file mode 100644 (file)
index 99465a5..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-mount {
-       cpu = /TMP/cgroups/cpu;
-       cpuacct = /TMP/cgroups/cpu;
-}
-
-default {
-       perm {
-               task {
-                       uid=nobody;
-                       gid=nobody;
-                       fperm=1757;
-               }
-               admin {
-                       uid = nobody;
-                       gid = nobody;
-                       dperm = 2757;
-                       fperm = 7757;
-               }
-       }
-}
-
-# inherit default
-group daemons/www {
-       cpu {
-               cpu.shares = "1000";
-       }
-}
-
-#override default
-group daemons/ftp {
-       perm {
-               task {
-                       uid = root;
-                       gid = root;
-                       fperm = 274;
-               }
-               admin {
-                       uid = root;
-                       gid = root;
-                       dperm = 742;
-                       fperm = 427;
-               }
-       }
-       cpu {
-               cpu.shares = "500";
-       }
-}
-
-# override some default
-group daemons/ssh {
-       perm {
-               task {
-                       uid = root;
-                       fperm = 274;
-               }
-               admin {
-                       uid = root;
-                       fperm = 427;
-               }
-       }
-       cpu {
-               cpu.shares = "500";
-       }
-}
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default4.conf b/tests/tools/cgconfigparser/cgconfigparser_conf_files/permissions_default4.conf
deleted file mode 100644 (file)
index 97d36f9..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-mount {
-       cpu = /TMP/cgroups/cpu;
-       cpuacct = /TMP/cgroups/cpu;
-}
-
-# inherit default
-group daemons/www {
-       cpu {
-               cpu.shares = "1000";
-       }
-}
-
-#override default
-group daemons/ftp {
-       perm {
-               task {
-                       uid = root;
-                       gid = root;
-                       fperm = 274;
-               }
-               admin {
-                       uid = root;
-                       gid = root;
-                       dperm = 742;
-                       fperm = 427;
-               }
-       }
-       cpu {
-               cpu.shares = "500";
-       }
-}
-
-# override some default
-group daemons/ssh {
-       perm {
-               task {
-                       uid = root;
-                       fperm = 274;
-               }
-               admin {
-                       uid = root;
-                       fperm = 427;
-               }
-       }
-       cpu {
-               cpu.shares = "500";
-       }
-}
diff --git a/tests/tools/cgconfigparser/cgconfigparser_conf_files_tests b/tests/tools/cgconfigparser/cgconfigparser_conf_files_tests
deleted file mode 100755 (executable)
index 858bc14..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-#!/bin/bash
-# this script tests the examples 1-4 from cgconfig.conf man pages
-# - for each one tests whether the configuration which is created using described configuration
-# file is identical with the example described below
-# TODO: Example 5 is missing now
-
-
-. `dirname $0`/../testenv.sh
-
-CONFDIR=$TESTDIR/tools/cgconfigparser/cgconfigparser_conf_files
-
-# all mount points are in /$TMP/cgroups
-mkdir /$TMP/cgroups/ 2>/dev/null
-#-----------------------------------------------------------------------------
-# EXAMPLE 1
-#-----------------------------------------------------------------------------
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/cgconfig.conf.5.ex1` || \
-       die "cgconfigparser -l $CONFDIR/cgconfig.conf.5.ex1 failed"
-
-$TOOLSDIR/cgsnapshot  -b $CONFIGDIR/cgsnapshot_blacklist.conf -s \
-        >/$TMP/temp.conf || die "example1 cgsnapshot failed"
-
-lssubsys_1=`$TOOLSDIR/lssubsys -m`
-
-$TOOLSDIR/cgclear || \
-       die "example1 1st cgclear failed"
-
-# cgsnapshot sanity test
-$TOOLSDIR/cgconfigparser -l /$TMP/temp.conf || \
-       die "example1 cgconfigparser failed"
-
-lssubsys_2=`$TOOLSDIR/lssubsys -m`
-
-$TOOLSDIR/cgclear || \
-       die "example1 2st cgclear failed"
-
-if [ "$lssubsys_1" != "$lssubsys_2" ]; then
-    echo "ERROR(example1): lssubsys_1='$lssubsys_1', lssubsys_2='$lssubsys_2'"
-    die "example1 failed"
-fi
-
-# cgconfigparser test
-mkdir /$TMP/cgroups/cpu 2>/dev/null
-mount -t cgroup -o cpu,cpuacct cpu $TMP/cgroups/cpu || die "example1 Mount failed"
-lssubsys_3=`lssubsys -m`
-$TOOLSDIR/cgclear || die "example1 3rd cgclear failed"
-
-if [ "$lssubsys_1" != "$lssubsys_3" ]; then
-    echo "ERROR(example1): lssubsys_1='$lssubsys_1', lssubsys_3='$lssubsys_3'"
-    die "example1 failed"
-fi
-
-#-----------------------------------------------------------------------------
-# EXAMPLE 2
-#-----------------------------------------------------------------------------
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/cgconfig.conf.5.ex2` || \
-    die "cgconfigparser -l $CONFDIR/cgconfig.conf.5.ex2 failed"
-
-val1=`$TOOLSDIR/cgget -nv -r cpu.shares daemons/ftp`;
-val2=`$TOOLSDIR/cgget -nv -r cpu.shares daemons/www`;
-
-
-if [ $val1 -ne 500 ]; then
-    echo "ERROR(example2): bogus variable setting daemons/ftp/cpu.shares $val1 "\
-        "(should be 500)"
-    die "example2 failed"
-fi
-
-if [ $val2 -ne 1000 ]; then
-    echo "ERROR(example2): bogus variable setting daemons/www/cpu.shares $val2 "\
-        "(should be 1000)"
-    die "example2 failed"
-fi
-
-$TOOLSDIR/cgsnapshot  -b $CONFIGDIR/cgsnapshot_blacklist.conf -s >\
-       /$TMP/temp.conf || die "example2 cgsnapshot failed"
-
-lssubsys_1=`$TOOLSDIR/lssubsys -m`
-$TOOLSDIR/cgclear || die "example2 1st cgclear failed"
-
-
-# cgsnapshot sanity test
-$TOOLSDIR/cgconfigparser -l /$TMP/temp.conf || \
-       die "example2 cgconfigparser of cgsnapshot file failed"
-
-lssubsys_2=`$TOOLSDIR/lssubsys -m`
-val1=`$TOOLSDIR/cgget -nv -r cpu.shares daemons/ftp`;
-val2=`$TOOLSDIR/cgget -nv -r cpu.shares daemons/www`;
-$TOOLSDIR/cgclear || die "example2 2st cgclear failed"
-
-if [ "$lssubsys_1" != "$lssubsys_2" ]; then
-    echo "ERROR(example2): lssubsys_1='$lssubsys_1', lssubsys_2='$lssubsys_2'"
-    die "example2 failed"
-fi
-
-
-if [ $val1 -ne 500 ]; then
-    echo "ERROR(example2): bogus variable setting daemons/ftp/cpu.shares $val1 "\
-    "(should be 500)"
-   die "example2 failed"
-fi
-
-if [ $val2 -ne 1000 ]; then
-    echo "ERROR(example2): bogus variable setting daemons/www/cpu.shares $val2 "\
-    "(should be 1000)"
-    die "example2 failed"
-fi
-
-# cgconfigparser test
-mkdir /$TMP/cgroups/cpu 2>/dev/null
-mount -t cgroup -o cpu,cpuacct cpu /$TMP/cgroups/cpu ||
-    die "example2 mount failed"
-mkdir /$TMP/cgroups/cpu/daemons 2>/dev/null
-
-mkdir /$TMP/cgroups/cpu/daemons/www 2>/dev/null
-echo 1000 > /$TMP/cgroups/cpu/daemons/www/cpu.shares ||
-    die "example2 var.setting failed"
-
-mkdir /$TMP/cgroups/cpu/daemons/ftp 2>/dev/null
-echo 500 > /$TMP/cgroups/cpu/daemons/ftp/cpu.shares ||
-    die "example2 var.setting failed"
-
-lssubsys_3=`$TOOLSDIR/lssubsys -m`
-$TOOLSDIR/cgclear || die "example2 3rd cgclear failed"
-
-
-if [ "$lssubsys_1" != "$lssubsys_3" ]; then
-    echo "ERROR(example1): lssubsys_1='$lssubsys_1', lssubsys_3='lssubsys_3'"
-    die "example2 failed"
-fi
-
-#-----------------------------------------------------------------------------
-# EXAMPLE 3
-#-----------------------------------------------------------------------------
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/cgconfig.conf.5.ex3` || \
-    die "cgconfigparser -l $CONFDIR/cgconfig.conf.5.ex3 failed"
-
-$TOOLSDIR/cgsnapshot -b $CONFIGDIR/cgsnapshot_blacklist.conf  \
-    -s >/$TMP/temp.conf || die "example3 cgsnapshot failed"
-lssubsys_1=`$TOOLSDIR/lssubsys -m`
-lscg1=`$TOOLSDIR/lscgroup`
-$TOOLSDIR/cgclear || die "example3 1st cgclear failed"
-
-# cgsnapshot sanity test
-$TOOLSDIR/cgconfigparser -l /$TMP/temp.conf || die "example3 cgconfigparser failed"
-lssubsys_2=`$TOOLSDIR/lssubsys -m`
-lscg2=`$TOOLSDIR/lscgroup`
-$TOOLSDIR/cgclear || die "example3 2st cgclear failed"
-
-if [ "$lssubsys_1" != "$lssubsys_2" ]; then
-    echo "ERROR(example3): lssubsys_1='$lssubsys_1', lssubsys_='$lssubsys_2'"
-    die "example3 failed"
-fi
-
-
-if [ "$lscg1" != "$lscg2" ]; then
-    echo "ERROR(example3): lscg1='$lscg1', lscg2='$lscg2'"
-    die "example3 failed"
-fi
-
-# cgconfigparser test
-mkdir /$TMP/cgroups/cpu 2>/dev/null
-mkdir /$TMP/cgroups/cpuacct 2>/dev/null
-mount -t cgroup -o cpu cpu /$TMP/cgroups/cpu || die "example3 Mount1 failed"
-mount -t cgroup -o cpuacct cpuacct /$TMP/cgroups/cpuacct || die "example3 Mount2 failed"
-
-mkdir /$TMP/cgroups/cpu/daemons 2>/dev/null
-mkdir /$TMP/cgroups/cpuacct/daemons 2>/dev/null
-
-lssubsys_3=`$TOOLSDIR/lssubsys -m`
-lscg3=`$TOOLSDIR/lscgroup`
-$TOOLSDIR/cgclear || die "example3 3rd cgclear failed"
-
-if [ "$lssubsys_1" != "$lssubsys_3" ]; then
-    echo "ERROR(example3): lssubsys_1='$lssubsys_1', lssubsys_3='$lssubsys_3'"
-    die "example3 failed"
-fi
-
-if [ "$lscg1" != "$lscg3" ]; then
-    echo "ERROR(example3): lscg1='$lscg1', lscg3='$lscg3'"
-    die "example3 failed"
-fi
-
-#-----------------------------------------------------------------------------
-# EXAMPLE 4
-#-----------------------------------------------------------------------------
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/cgconfig.conf.5.ex4` || \
-    die "cgconfigparser -l $CONFDIR/cgconfig.conf.5.ex4 failed"
-
-$TOOLSDIR/cgsnapshot -b $CONFIGDIR/cgsnapshot_blacklist.conf -s \
-    >/$TMP/temp.conf || die "example4 cgsnapshot failed"
-lssubsys_1=`$TOOLSDIR/lssubsys -m`
-lscg1=`$TOOLSDIR/lscgroup | sort`
-$TOOLSDIR/cgclear || die "example4 1st cgclear failed"
-
-# cgsnapshot sanity test
-$TOOLSDIR/cgconfigparser -l /$TMP/temp.conf || die "example4 cgconfigparser failed"
-lssubsys_2=`$TOOLSDIR/lssubsys -m`
-lscg2=`$TOOLSDIR/lscgroup| sort`
-$TOOLSDIR/cgclear || die "example4 2st cgclear failed"
-
-if [ "$lssubsys_1" != "$lssubsys_2" ]; then
-    echo "ERROR(example4): lssubsys_1='$lssubsys_1', lssubsys_2='$lssubsys_2'"
-    die "example4 failed"
-fi
-
-if [ "$lscg1" != "$lscg2" ]; then
-    echo "ERROR(example4): lscg1='$lscg1', lscg2='$lscg2'"
-    die "example4 failed"
-fi
-
-# cgconfigparser test
-mkdir /$TMP/cgroups/cpu 2>/dev/null
-mkdir /$TMP/cgroups/cpuacct 2>/dev/null
-mount -t cgroup -o cpu cpu /$TMP/cgroups/cpu || die "example4 Mount1 failed"
-mount -t cgroup -o cpuacct cpuacct /$TMP/cgroups/cpuacct || die "example4 Mount2 failed"
-
-mkdir /$TMP/cgroups/cpuacct/daemons 2>/dev/null
-mkdir /$TMP/cgroups/cpu/daemons 2>/dev/null
-mkdir /$TMP/cgroups/cpu/daemons/www 2>/dev/null
-mkdir /$TMP/cgroups/cpu/daemons/ftp 2>/dev/null
-
-lssubsys_3=`$TOOLSDIR/lssubsys -m`
-lscg3=`$TOOLSDIR/lscgroup | sort`
-cgclear || die "example3 3rd cgclear failed"
-
-
-if [ "$lssubsys_1" != "$lssubsys_3" ]; then
-    echo "ERROR(example4): lssubsys_1='$lssubsys_1', lssubsys_3='$lssubsys_3'"
-    die "example4 failed"
-fi
-
-if [ "$lscg1" != "$lscg3" ]; then
-    echo "ERROR(example4): lscg1='$lscg1', lscg3='$lscg3'"
-    die "example4 failed"
-fi
-
-
-cleanup
-exit 0
\ No newline at end of file
diff --git a/tests/tools/cgconfigparser/cgconfigparser_multiconfig b/tests/tools/cgconfigparser/cgconfigparser_multiconfig
deleted file mode 100755 (executable)
index 9a06229..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-# test cgconfigparser with multiple config files
-
-. `dirname $0`/../testenv.sh
-
-# prepare config files in a temporary directory
-mkdir -p $TMP/conf.d
-for i in $TESTDIR/tools/cgconfigparser/multiconfig/*.conf; do
-       mv `prepare_config $i` $TMP/conf.d/
-done
-
-$TOOLSDIR/cgconfigparser -L $TMP/conf.d/ \
-       || die "cgconfigparser failed"
-
-# check that all expected groups exist
-$TOOLSDIR/lscgroup > $TMP/groups.out
-grep "cpu,cpuacct:/1$" <$TMP/groups.out >/dev/null \
-       || die "cannot find group 1"
-grep "freezer:/22$" <$TMP/groups.out >/dev/null \
-       || die "cannot find group 2"
-grep "net_cls:/333$" <$TMP/groups.out >/dev/null \
-       || die "cannot find group 3"
-grep "cpu,cpuacct:/1/4$" <$TMP/groups.out >/dev/null \
-       || die "cannot find group 1/4"
-grep "freezer:/22/4$" <$TMP/groups.out >/dev/null \
-       || die "cannot find group 22/4"
-grep "net_cls:/333/4$" <$TMP/groups.out >/dev/null \
-       || die "cannot find group 333/4"
-grep "cpu,cpuacct:/5$" <$TMP/groups.out >/dev/null \
-       || die "cannot find group 5"
-grep "freezer:/55$" <$TMP/groups.out >/dev/null \
-       || die "cannot find group 55"
-grep "net_cls:/555$" <$TMP/groups.out >/dev/null \
-       || die "cannot find group 555"
-
-# clear it at once
-$TOOLSDIR/cgclear -e -L $TMP/conf.d/ \
-       || die "cgclear failed"
-
-cleanup
-exit 0
diff --git a/tests/tools/cgconfigparser/cgconfigparser_simple b/tests/tools/cgconfigparser/cgconfigparser_simple
deleted file mode 100755 (executable)
index 070bd73..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-# simple sanity test for cgconfigparser, cgsnapshot and cgclear tool
-
-. `dirname $0`/../testenv.sh
-
-
-mkdir -p /$TMP/cgroups/cpu 2>/dev/null
-mount -t cgroup -o cpu,cpuacct cpu /$TMP/cgroups/cpu || die "Mount failed"
-
-$TOOLSDIR/cgsnapshot -b $CONFIGDIR/cgsnapshot_blacklist.conf >/$TMP/temp.conf || die "cgsnapshot failed"
-lss_o1=`$TOOLSDIR/lssubsys -m`
-$TOOLSDIR/cgclear || die "1st cgclear failed"
-
-$TOOLSDIR/cgconfigparser -l /$TMP/temp.conf || die "cgconfigparser failed"
-lss_o2=`$TOOLSDIR/lssubsys -m`
-$TOOLSDIR/cgclear || die "2nd cgclear failed"
-
-if [ "$lss_o1" != "$lss_o2" ]; then
-     echo "ERROR: first lss ouptput:'$lss_o1', second lss output:'$lss_o2'"
-fi
-
-cleanup
-exit 0
diff --git a/tests/tools/cgconfigparser/multiconfig/1.conf b/tests/tools/cgconfigparser/multiconfig/1.conf
deleted file mode 100644 (file)
index dbc16d2..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-mount {
-    cpu = /TMP/cgroups/cpu;
-    cpuacct = /TMP/cgroups/cpu;
-}
-
-group 1 {
-    cpu { }
-}
-
diff --git a/tests/tools/cgconfigparser/multiconfig/2.conf b/tests/tools/cgconfigparser/multiconfig/2.conf
deleted file mode 100644 (file)
index c1039dc..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-mount {
-    freezer = /TMP/cgroups/freezer;
-}
-
-# check that cpu is already mounted
-group 2 {
-    cpu { }
-}
-
-group 22 {
-    freezer { }
-}
diff --git a/tests/tools/cgconfigparser/multiconfig/3.conf b/tests/tools/cgconfigparser/multiconfig/3.conf
deleted file mode 100644 (file)
index 620923b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-mount {
-    net_cls = /TMP/cgroups/net;
-}
-
-# check that cpu is already mounted
-group 3 {
-    cpu { }
-}
-
-# check that freezer is already mounted
-group 33 {
-    freezer { }
-}
-
-group 333 {
-    net_cls { }
-}
diff --git a/tests/tools/cgconfigparser/multiconfig/4.conf b/tests/tools/cgconfigparser/multiconfig/4.conf
deleted file mode 100644 (file)
index d48f12f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# now with a namespace
-namespace {
-    cpu=1;
-    cpuacct=1;
-    freezer=22;
-    net_cls=333;
-}
-group 4 {
-    cpu { }
-    freezer { }
-    net_cls { }
-}
diff --git a/tests/tools/cgconfigparser/multiconfig/5.conf b/tests/tools/cgconfigparser/multiconfig/5.conf
deleted file mode 100644 (file)
index d4dc465..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# now without mount section
-group 5 {
-    cpu { }
-}
-
-group 55 {
-    freezer { }
-}
-
-group 555 {
-    net_cls { }
-}
diff --git a/tests/tools/cgconfigparser/permissions b/tests/tools/cgconfigparser/permissions
deleted file mode 100755 (executable)
index 2d45afc..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/bin/bash
-# this script tests fperm and dperm configuration options
-
-
-. `dirname $0`/../testenv.sh
-
-CONFDIR=$TESTDIR/tools/cgconfigparser/cgconfigparser_conf_files
-
-# permissions test
-function check_perm()
-{
-    STEP=$1
-    FILENAME=$2
-    EXPECTED_PERM=$3
-    EXPECTED_UID=$4
-    EXPECTED_GID=$5
-    REAL_PERM=`stat -c "%a" $FILENAME`
-    REAL_UID=`stat -c "%U" $FILENAME`
-    REAL_GID=`stat -c "%G" $FILENAME`
-    if [ "$EXPECTED_PERM" != "$REAL_PERM" ]; then
-        die "$STEP: Wrong permissions of $FILENAME,"\
-            " expected $EXPECTED_PERM, actual $REAL_PERM"
-    fi
-    if [ "$EXPECTED_UID" != "$REAL_UID" ]; then
-        die "$STEP: Wrong uid of $FILENAME,"\
-            " expected $EXPECTED_UID, actual $REAL_UID"
-    fi
-    if [ "$EXPECTED_GID" != "$REAL_GID" ]; then
-        die "$STEP: Wrong gid of $FILENAME,"\
-            " expected $EXPECTED_GID, actual $REAL_GID"
-    fi
-}
-
-# all mount points are in /$TMP/cgroups
-mkdir /$TMP/cgroups/ 2>/dev/null
-
-# STEP1: simple config file without default section
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/permissions.conf` || \
-    die "STEP1: cgconfigparser -l $CONFDIR/permissions.conf failed"
-check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/www" 770 root root
-check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/www/cpu.shares" 666 root root
-check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/www/tasks" 640 root nobody
-
-check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/ftp" 742 root root
-check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/ftp/cpu.shares" 426 root root
-check_perm "STEP1" "/$TMP/cgroups/cpu/daemons/ftp/tasks" 264 root nobody
-
-$TOOLSDIR/cgclear || die "STEP1: cgclear failed"
-
-# STEP2: config file with one default section
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/permissions_default1.conf` || \
-    die "STEP2: cgconfigparser -l $CONFDIR/permissions_default1.conf failed"
-
-check_perm "STEP2" "/$TMP/cgroups/cpu/daemons/www" 757 nobody nobody
-check_perm "STEP2" "/$TMP/cgroups/cpu/daemons/www/cpu.shares" 646 nobody nobody
-check_perm "STEP2" "/$TMP/cgroups/cpu/daemons/www/tasks" 646 nobody nobody
-
-check_perm "STEP2" "/$TMP/cgroups/cpu/daemons/ftp" 742 root root
-check_perm "STEP2" "/$TMP/cgroups/cpu/daemons/ftp/cpu.shares" 426 root root
-check_perm "STEP2" "/$TMP/cgroups/cpu/daemons/ftp/tasks" 264 root root
-
-check_perm "STEP2" "/$TMP/cgroups/cpu/daemons/ssh" 757 root nobody
-check_perm "STEP2" "/$TMP/cgroups/cpu/daemons/ssh/cpu.shares" 426 root nobody
-check_perm "STEP2" "/$TMP/cgroups/cpu/daemons/ssh/tasks" 264 root nobody
-
-$TOOLSDIR/cgclear || die "cgclear failed"
-
-# STEP3: config file with two default sections - the last wins
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/permissions_default2.conf` || \
-    die "STEP3: cgconfigparser -l $CONFDIR/permissions_default2.conf failed"
-
-check_perm "STEP3" "/$TMP/cgroups/cpu/daemons/www" 757 nobody nobody
-check_perm "STEP3" "/$TMP/cgroups/cpu/daemons/www/cpu.shares" 646 nobody nobody
-check_perm "STEP3" "/$TMP/cgroups/cpu/daemons/www/tasks" 646 nobody nobody
-
-check_perm "STEP3" "/$TMP/cgroups/cpu/daemons/ftp" 742 root root
-check_perm "STEP3" "/$TMP/cgroups/cpu/daemons/ftp/cpu.shares" 426 root root
-check_perm "STEP3" "/$TMP/cgroups/cpu/daemons/ftp/tasks" 264 root root
-
-check_perm "STEP3" "/$TMP/cgroups/cpu/daemons/ssh" 757 root nobody
-check_perm "STEP3" "/$TMP/cgroups/cpu/daemons/ssh/cpu.shares" 426 root nobody
-check_perm "STEP3" "/$TMP/cgroups/cpu/daemons/ssh/tasks" 264 root nobody
-
-$TOOLSDIR/cgclear || die "cgclear failed"
-
-# STEP4: config file with one default section, now with SUID and SGID bits
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/permissions_default3.conf` || \
-    die "STEP4: cgconfigparser -l $CONFDIR/permissions_default3.conf failed"
-
-check_perm "STEP4" "/$TMP/cgroups/cpu/daemons/www" 2757 nobody nobody
-check_perm "STEP4" "/$TMP/cgroups/cpu/daemons/www/cpu.shares" 7646 nobody nobody
-check_perm "STEP4" "/$TMP/cgroups/cpu/daemons/www/tasks" 1646 nobody nobody
-
-check_perm "STEP4" "/$TMP/cgroups/cpu/daemons/ftp" 742 root root
-check_perm "STEP4" "/$TMP/cgroups/cpu/daemons/ftp/cpu.shares" 426 root root
-check_perm "STEP4" "/$TMP/cgroups/cpu/daemons/ftp/tasks" 264 root root
-
-check_perm "STEP4" "/$TMP/cgroups/cpu/daemons/ssh" 2757 root nobody
-check_perm "STEP4" "/$TMP/cgroups/cpu/daemons/ssh/cpu.shares" 426 root nobody
-check_perm "STEP4" "/$TMP/cgroups/cpu/daemons/ssh/tasks" 264 root nobody
-
-$TOOLSDIR/cgclear || die "cgclear failed"
-
-# STEP5: config file without default section, but with -a -t params
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/permissions_default4.conf` -t nobody:nobody -a nobody:nobody -d 757 -f 757 || \
-    die "STEP5: cgconfigparser -l $CONFDIR/permissions_default4.conf failed"
-
-check_perm "STEP5" "/$TMP/cgroups/cpu/daemons/www" 757 nobody nobody
-check_perm "STEP5" "/$TMP/cgroups/cpu/daemons/www/cpu.shares" 646 nobody nobody
-check_perm "STEP5" "/$TMP/cgroups/cpu/daemons/www/tasks" 644 nobody nobody
-
-check_perm "STEP5" "/$TMP/cgroups/cpu/daemons/ftp" 742 root root
-check_perm "STEP5" "/$TMP/cgroups/cpu/daemons/ftp/cpu.shares" 426 root root
-check_perm "STEP5" "/$TMP/cgroups/cpu/daemons/ftp/tasks" 264 root root
-
-check_perm "STEP5" "/$TMP/cgroups/cpu/daemons/ssh" 757 root nobody
-check_perm "STEP5" "/$TMP/cgroups/cpu/daemons/ssh/cpu.shares" 426 root nobody
-check_perm "STEP5" "/$TMP/cgroups/cpu/daemons/ssh/tasks" 264 root nobody
-
-$TOOLSDIR/cgclear || die "cgclear failed"
-
-# STEP6: config file without default section, but with -a -t params and sticky bit
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/permissions_default4.conf` -t nobody:nobody -a nobody:nobody -d 2757 -f 7757 || \
-    die "STEP6: cgconfigparser -l $CONFDIR/permissions_default4.conf failed"
-
-check_perm "STEP6" "/$TMP/cgroups/cpu/daemons/www" 2757 nobody nobody
-check_perm "STEP6" "/$TMP/cgroups/cpu/daemons/www/cpu.shares" 7646 nobody nobody
-check_perm "STEP6" "/$TMP/cgroups/cpu/daemons/www/tasks" 644 nobody nobody
-
-check_perm "STEP6" "/$TMP/cgroups/cpu/daemons/ftp" 742 root root
-check_perm "STEP6" "/$TMP/cgroups/cpu/daemons/ftp/cpu.shares" 426 root root
-check_perm "STEP6" "/$TMP/cgroups/cpu/daemons/ftp/tasks" 264 root root
-
-check_perm "STEP6" "/$TMP/cgroups/cpu/daemons/ssh" 2757 root nobody
-check_perm "STEP6" "/$TMP/cgroups/cpu/daemons/ssh/cpu.shares" 426 root nobody
-check_perm "STEP6" "/$TMP/cgroups/cpu/daemons/ssh/tasks" 264 root nobody
-
-$TOOLSDIR/cgclear || die "cgclear failed"
-
-# STEP7: config file without default section, but with only -d params (=-f is taken from umask)
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/permissions_default4.conf` -t nobody:nobody -a nobody:nobody -d 757 || \
-    die "STEP7: cgconfigparser -l $CONFDIR/permissions_default4.conf failed"
-
-check_perm "STEP7" "/$TMP/cgroups/cpu/daemons/www" 757 nobody nobody
-check_perm "STEP7" "/$TMP/cgroups/cpu/daemons/www/cpu.shares" 644 nobody nobody
-check_perm "STEP7" "/$TMP/cgroups/cpu/daemons/www/tasks" 644 nobody nobody
-
-check_perm "STEP7" "/$TMP/cgroups/cpu/daemons/ftp" 742 root root
-check_perm "STEP7" "/$TMP/cgroups/cpu/daemons/ftp/cpu.shares" 426 root root
-check_perm "STEP7" "/$TMP/cgroups/cpu/daemons/ftp/tasks" 264 root root
-
-check_perm "STEP7" "/$TMP/cgroups/cpu/daemons/ssh" 757 root nobody
-check_perm "STEP7" "/$TMP/cgroups/cpu/daemons/ssh/cpu.shares" 426 root nobody
-check_perm "STEP7" "/$TMP/cgroups/cpu/daemons/ssh/tasks" 264 root nobody
-
-$TOOLSDIR/cgclear || die "cgclear failed"
-
-# STEP8: config file without default section, but with -f, -d and -t
-$TOOLSDIR/cgconfigparser -l `prepare_config $CONFDIR/permissions_default4.conf` -t nobody:nobody -a nobody:nobody -d 757 -f 757 -s 7247 || \
-    die "STEP8: cgconfigparser -l $CONFDIR/permissions_default4.conf failed"
-
-check_perm "STEP8" "/$TMP/cgroups/cpu/daemons/www" 757 nobody nobody
-check_perm "STEP8" "/$TMP/cgroups/cpu/daemons/www/cpu.shares" 646 nobody nobody
-check_perm "STEP8" "/$TMP/cgroups/cpu/daemons/www/tasks" 7246 nobody nobody
-
-check_perm "STEP8" "/$TMP/cgroups/cpu/daemons/ftp" 742 root root
-check_perm "STEP8" "/$TMP/cgroups/cpu/daemons/ftp/cpu.shares" 426 root root
-check_perm "STEP8" "/$TMP/cgroups/cpu/daemons/ftp/tasks" 264 root root
-
-check_perm "STEP8" "/$TMP/cgroups/cpu/daemons/ssh" 757 root nobody
-check_perm "STEP8" "/$TMP/cgroups/cpu/daemons/ssh/cpu.shares" 426 root nobody
-check_perm "STEP8" "/$TMP/cgroups/cpu/daemons/ssh/tasks" 264 root nobody
-
-$TOOLSDIR/cgclear || die "cgclear failed"
-
-cleanup
-exit 0
diff --git a/tests/tools/multimount/Makefile.am b/tests/tools/multimount/Makefile.am
deleted file mode 100644 (file)
index 85fa7f4..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-EXTRA_DIST = many_mp many_named
-
-# The legacy tests have been disabled because they do not successfully run
-# on Travis CI.
-#TESTS = many_mp  many_named
diff --git a/tests/tools/multimount/many_mp b/tests/tools/multimount/many_mp
deleted file mode 100755 (executable)
index 04659c1..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/bash
-# Test hierarchies mounted multiple times (one hierarchy mounted 99 times)
-# - cgsnapshot
-# - cgconfigparser
-# - lssubsys
-
-. `dirname $0`/../testenv.sh
-
-# cgconfigparser cannot handle more than 100 mount points :-(
-COUNT=99
-
-function check_config()
-{
-       CONFIG=$1
-       # check basic sanity of generatet cgconfig.conf file
-       #  - it has expected number of mount points
-       if [ `grep '=' < $CONFIG | wc -l` -ne $(($COUNT*4)) ]; then
-               die "wrong number of mount points in $CONFIG"
-       fi
-
-       #  - it has mount section
-       grep "mount" >/dev/null <$CONFIG \
-               || die "cgsnapshot failed, no mount section found in $CONFIG"
-
-       #  - it has 99 different mount points
-       for i in `seq $COUNT`; do
-               grep "cpuacct$i" >/dev/null <$CONFIG \
-                       || die "cgsnapshot failed, no cpuacct$i found in $CONFIG"
-       done
-}
-
-for i in `seq $COUNT`; do
-       mkdir -p $TMP/cgroups/cpuacct$i 2>/dev/null
-       mount -t cgroup -o cpuacct,cpuset,memory,freezer cpuacct$i \
-                       $TMP/cgroups/cpuacct$i \
-               || die "Mount $i failed"
-done
-
-# check lssubsys
-# plain lssubsys - only one line with 4 controllers is expected
-$TOOLSDIR/lssubsys >$TMP/subsys1.out \
-       || die "plain lssubsys failed"
-[ `wc -l <$TMP/subsys1.out` -eq 1 ] \
-       || die "unexpected output of plan lssubsys"
-
-# lssubsys -m - first mount point is returned
-$TOOLSDIR/lssubsys -m >$TMP/subsys2.out \
-       || die "lssubsys -m failed"
-[ `wc -l <$TMP/subsys2.out` -eq 1 ] \
-       || die "unexpected output of lssubsys -m"
-grep <$TMP/subsys2.out cpuacct1 >/dev/null \
-       || die "lssubsys -m does not show the first mount point"
-
-# lssubsys -M - all mount points are returned
-$TOOLSDIR/lssubsys -M >$TMP/subsys3.out \
-       || die "lssubsys -M failed"
-[ `wc -l <$TMP/subsys3.out` -eq $COUNT ] \
-       || die "unexpected output of lssubsys -M"
-for i in `seq $COUNT`; do
-       grep <$TMP/subsys3.out cpuacct$i >/dev/null \
-               || die "lssubsys -m does not show cpuacct$i"
-done
-
-# check cgsnapshot
-$TOOLSDIR/cgsnapshot -b $CONFIGDIR/cgsnapshot_blacklist.conf >$TMP/snapshot.conf \
-       || die "cgsnapshot failed"
-
-check_config $TMP/snapshot.conf
-
-$TOOLSDIR/cgclear || die "cgclear 1 failed"
-
-# check cgconfigparser - try to parse the generated config
-$TOOLSDIR/cgconfigparser -l $TMP/snapshot.conf \
-       || die "cgconfigparser failed to parse the snapshot"
-
-# and make its snapshot again
-$TOOLSDIR/cgsnapshot -b $CONFIGDIR/cgsnapshot_blacklist.conf >$TMP/snapshot2.conf \
-       || die "cgsnapshot2 failed"
-
-check_config $TMP/snapshot2.conf
-
-$TOOLSDIR/cgclear
-
-cleanup
-exit 0
diff --git a/tests/tools/multimount/many_named b/tests/tools/multimount/many_named
deleted file mode 100755 (executable)
index fa27aa5..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/bash
-# Tests named hierarchies, mouted several times
-# - cgsnapshot
-# - cgconfigparser
-# - lssubsys
-
-. `dirname $0`/../testenv.sh
-
-# 10 named hierarchies, each mounted 8 times
-HIERARCHIES=10
-COUNT=8
-
-function check_config()
-{
-       # check basic sanity of the generated file
-       CONFIG=$1
-
-       # it has expected nr. of mount points
-       if [ `grep '=' <$CONFIG | wc -l` -ne $(($COUNT*$HIERARCHIES+3)) ];then
-               die "wrong number of mount points displayed in $CONFIG"
-       fi
-       # it has mount section
-       grep "mount" >/dev/null <$CONFIG \
-               || die "cgsnapshot failed, no mount section found in $CONFIG"
-       # it has every hierarchy at least once
-       for i in `seq $HIERARCHIES`; do
-               grep "name=$i" >/dev/null <$CONFIG \
-                       || die "cgsnapshot failed, no name=$i found in $CONFIG"
-       done
-       # it has cpuacct,cpuset,name=cputest mount
-       grep "name=cputest" >/dev/null <$CONFIG \
-               || die "cannot find name=cputest in $CONFIG"
-       grep "cpuacct" >/dev/null <$CONFIG \
-               || die "cannot find cpuacct in $CONFIG"
-}
-
-for i in `seq $HIERARCHIES`; do
-       for j in `seq $COUNT`; do
-               mkdir -p $TMP/cgroups/named$i-$j 2>/dev/null
-               mount -t cgroup -o none,name=$i named$i \
-                       $TMP/cgroups/named$i-$j \
-                       || die "Mount $i_$j failed"
-       done
-done
-
-# add one named mount point with other controllers
-mkdir -p $TMP/cgroups/cpu 2>/dev/null
-mount -t cgroup -o cpuset,cpuacct,name=cputest test $TMP/cgroups/cpu \
-               || die "Mount cpu failed"
-
-# !!! lssubsys does NOT support named hierarchies now !!!
-# check lssubsys
-# plain lssubsys - every hierarchy only once
-#$TOOLSDIR/lssubsys >$TMP/subsys1.out \
-#      || die "plain lssubsys failed"
-#[ `wc -l <$TMP/subsys1.out` -eq $(( $HIERARCHIES+1 )) ] \
-#      || die "unexpected output of plain lssubsys"
-
-# lssubsys -m - first mount point is returned
-#$TOOLSDIR/lssubsys -m >$TMP/subsys2.out \
-#      || die "lssubsys -m failed"
-#[ `wc -l <$TMP/subsys2.out` -eq $(( $HIERARCHIES+1 )) ] \
-#      || die "unexpected output of lssubsys -m"
-#grep <$TMP/subsys2.out cgroups/cpu >/dev/null \
-#      || die "lssubsys -m does not show the first mount point for cputest"
-#for i in `seq $HIERARCHIES`; do
-#      grep <$TMP/subsys2.out cgroups/named$i-1 >/dev/null \
-#              || die "lssubsys -m does not show cgroups/named$i-1"
-#done
-
-# lssubsys -M - all mount points are returned
-#$TOOLSDIR/lssubsys -M >$TMP/subsys3.out \
-#      || die "lssubsys -M failed"
-#[ `wc -l <$TMP/subsys3.out` -eq $(( $COUNT*$HIERARCHIES+1)) ] \
-#      || die "unexpected output of lssubsys -M"
-#for i in `seq $HIERARCHIES`; do
-#      for j in `seq $COUNT`; do
-#              grep <$TMP/subsys3.out cgroups/named$i-$j >/dev/null \
-#              || die "lssubsys -m does not show cgroups/named$i-$j"
-#      done
-#done
-
-$TOOLSDIR/cgsnapshot -b $CONFIGDIR/cgsnapshot_blacklist.conf >$TMP/snapshot.conf \
-       || die "cgsnapshot failed"
-
-check_config $TMP/snapshot.conf
-
-$TOOLSDIR/cgclear || die "cgclear 1 failed"
-
-# try to parse the config...
-$TOOLSDIR/cgconfigparser -l $TMP/snapshot.conf \
-       || die "cgconfigparser failed to parse the snapshot"
-# and make its snapshot again
-$TOOLSDIR/cgsnapshot -b $CONFIGDIR/cgsnapshot_blacklist.conf >$TMP/snapshot2.conf \
-       || die "cgsnapshot2 failed"
-
-check_config $TMP/snapshot2.conf
-
-$TOOLSDIR/cgclear
-
-cleanup
-exit 0
diff --git a/tests/tools/testenv.sh.in b/tests/tools/testenv.sh.in
deleted file mode 100644 (file)
index 2b3eca1..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/bash
-
-# Simple test framework for libcgroup.
-# Upon loading it does following:
-#  - sets $TMP, where all temporary files should be stored.
-#  - backs-up /etc/cgrules.conf in the $TMP
-#    (so it does not interfere with tests)
-#
-# Function cleanup() or die() must be called to destroy this temporary
-# directory and restore previous cgrules.conf!
-#
-# Usage:
-# . ./testenv.sh
-# <do some testing>
-# cleanup
-# exit 0
-
-# Print an error message and exit
-# Usage:
-#   cgclear || die "cgclear failed"
-function die()
-{
-       echo $*
-       @abs_top_srcdir@/libtool --mode=execute @abs_top_srcdir@/src/tools/cgclear
-       if [ -e $TMP/cgrules-backup.conf ]; then
-               mv $TMP/cgrules-backup.conf /etc/cgrules.conf &>/dev/null
-       else
-               rm /etc/cgrules.conf &>/dev/null
-       fi
-       rm -rf $TMP
-       unset TMP
-       exit 1
-}
-
-# Clear everything that was created at loading this script, i.e.
-# remove the temporary directory
-# In addition, check that nothing remained mounted.
-# Usage:
-#   cleanup
-function cleanup()
-{
-       RET=0
-       grep -v systemd </proc/mounts >$TMP/mounts
-       if grep "^cgroup" $TMP/mounts &>/dev/null; then
-               echo "Error: cleanup has found mounted cgroup:"
-               grep cgroup /proc/mounts
-               RET=1
-               cgclear
-       fi
-       if [ -e $TMP/cgrules-backup.conf ]; then
-               mv $TMP/cgrules-backup.conf /etc/cgrules.conf &>/dev/null
-       else
-               rm /etc/cgrules.conf &>/dev/null
-       fi
-       rm -rf $TMP
-       unset TMP
-       [ -z $RET ] || exit $RET
-}
-
-# Copies a file to $TMP and replaces all occurrences of TMP in the file with
-# value of $TMP. The function prints the name of the new file to its std.
-# output.
-# Usage:
-#    cgconfigparser -l `prepare_config config/sample.conf`
-function prepare_config()
-{
-       INPUT=$1
-       OUTPUT=$TMP/`basename $INPUT`
-       # echo -n "m4_changequote()" | m4 -P -D "TMP=$TMP" - $FILE >$OUTPUT
-       sed -e "s!\bTMP\b!$TMP!g" <$INPUT >$OUTPUT || (
-               echo "Error: prepare config failed!" >&2; exit 1
-       )
-       echo $OUTPUT
-}
-
-export TMP=`mktemp --tmpdir -d libcgroup-tmp-XXXXXXX`
-# store the rules on safe place, we don't want them to mess up the tests
-mv /etc/cgrules.conf $TMP/cgrules-backup.conf &>/dev/null
-# tools directory
-export TOOLSDIR="@abs_top_srcdir@/libtool --mode=execute @abs_top_srcdir@/src/tools/"
-# config files directory
-export CONFIGDIR="@abs_top_srcdir@/samples"
-# test directory
-export TESTDIR="@abs_top_srcdir@/tests"
diff --git a/tests/walk_task.c b/tests/walk_task.c
deleted file mode 100644 (file)
index 42ef32d..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <stdio.h>
-#include <libcgroup.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-int main(int argc, char *argv[])
-{
-       int ret, i;
-       char *group = NULL;
-       void *handle;
-
-       if (argc < 2) {
-               printf("No list of groups provided\n");
-               return -1;
-       }
-
-       ret = cgroup_init();
-
-       if (ret) {
-               printf("cgroup_init failed with %s\n", cgroup_strerror(ret));
-               return -1;
-       }
-
-       for (i = 1; i < argc; i++) {
-               pid_t pid;
-               group = strdup(argv[i]);
-               printf("Printing the details of groups %s\n", group);
-               ret = cgroup_get_task_begin(group, "cpu", &handle, &pid);
-               while (!ret) {
-                       printf("Pid is %u\n", pid);
-                       ret = cgroup_get_task_next(&handle, &pid);
-                       if (ret && ret != ECGEOF) {
-                               printf("cgroup_get_task_next failed with %s\n",
-                                                       cgroup_strerror(ret));
-                               if (ret == ECGOTHER)
-                                       printf("failure with %s\n",
-                                                       strerror(errno));
-                               return -1;
-                       }
-               }
-               free(group);
-               group = NULL;
-               ret = cgroup_get_task_end(&handle);
-       }
-
-       return 0;
-
-}
diff --git a/tests/walk_test.c b/tests/walk_test.c
deleted file mode 100644 (file)
index f3112c5..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include <libcgroup.h>
-
-void visit_node(struct cgroup_file_info *info, char *root)
-{
-       if (info->type == CGROUP_FILE_TYPE_DIR) {
-               printf("path %s, parent %s, relative %s, full %s\n",
-                       info->path, info->parent, info->full_path +
-                               + strlen(root) - 1,
-                               info->full_path);
-       }
-}
-
-int main(int argc, char *argv[])
-{
-       int ret;
-       char *controller;
-       void *handle;
-       struct cgroup_file_info info;
-       char root[FILENAME_MAX];
-       int lvl, i;
-
-       if (argc < 2) {
-               fprintf(stderr, "Usage %s: <controller name>\n",
-                       argv[0]);
-               exit(EXIT_FAILURE);
-       }
-
-       controller = argv[1];
-
-       ret = cgroup_init();
-       if (ret != 0) {
-               fprintf(stderr, "Init failed\n");
-               exit(EXIT_FAILURE);
-       }
-
-       ret = cgroup_walk_tree_begin(controller, "/", 0, &handle, &info, &lvl);
-
-       if (ret != 0) {
-               fprintf(stderr, "Walk failed\n");
-               exit(EXIT_FAILURE);
-       }
-       strcpy(root, info.full_path);
-       printf("Begin pre-order walk\n");
-       printf("root is %s\n", root);
-       visit_node(&info, root);
-       while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) !=
-                       ECGEOF) {
-               visit_node(&info, root);
-       }
-       cgroup_walk_tree_end(&handle);
-
-       printf("pre-order walk finished\n");
-       ret = cgroup_walk_tree_begin(controller, "/", 0, &handle, &info, &lvl);
-
-       if (ret != 0) {
-               fprintf(stderr, "Walk failed\n");
-               exit(EXIT_FAILURE);
-       }
-
-       ret = cgroup_walk_tree_set_flags(&handle, CGROUP_WALK_TYPE_POST_DIR);
-
-       if (ret) {
-               fprintf(stderr, "Walk failed with %s\n", cgroup_strerror(ret));
-               exit(EXIT_FAILURE);
-       }
-
-       strcpy(root, info.full_path);
-       printf("Begin post-order walk\n");
-       printf("root is %s\n", root);
-       visit_node(&info, root);
-       while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) !=
-                       ECGEOF) {
-               visit_node(&info, root);
-       }
-       cgroup_walk_tree_end(&handle);
-       printf("post order walk finished\n");
-
-       ret = cgroup_walk_tree_begin(controller, "/a", 2, &handle, &info, &lvl);
-
-       if (ret != 0) {
-               fprintf(stderr, "Walk failed\n");
-               exit(EXIT_FAILURE);
-       }
-       strcpy(root, info.full_path);
-       printf("root is %s\n", root);
-       visit_node(&info, root);
-       while ((ret = cgroup_walk_tree_next(2, &handle, &info, lvl)) !=
-                       ECGEOF) {
-               visit_node(&info, root);
-       }
-       cgroup_walk_tree_end(&handle);
-
-       /*
-        * Walk only the first five nodes
-        */
-       i = 0;
-       printf("Walking the first 5 nodes\n");
-       ret = cgroup_walk_tree_begin(controller, "/", 0, &handle, &info, &lvl);
-
-       if (ret != 0) {
-               fprintf(stderr, "Walk failed\n");
-               exit(EXIT_FAILURE);
-       }
-       strcpy(root, info.full_path);
-       printf("root is %s\n", root);
-       visit_node(&info, root);
-       i++;
-       while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) !=
-                       ECGEOF) {
-               visit_node(&info, root);
-               if (++i >= 5)
-                       break;
-       }
-       cgroup_walk_tree_end(&handle);
-       return EXIT_SUCCESS;
-}
diff --git a/tests/wrapper_test.c b/tests/wrapper_test.c
deleted file mode 100644 (file)
index 257ece3..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#include <libcgroup.h>
-#include <stdio.h>
-#include <string.h>
-#include "../src/libcgroup-internal.h"
-
-int main()
-{
-       struct cgroup *cgroup;
-       struct cgroup_controller *cgc;
-       int fail = 0;
-
-       cgroup = cgroup_new_cgroup("test");
-       cgc = cgroup_add_controller(cgroup, "cpu");
-
-       cgroup_add_value_int64(cgc, "cpu.shares", 2048);
-       cgroup_add_value_uint64(cgc, "cpu.something", 1000);
-       cgroup_add_value_bool(cgc, "cpu.bool", 1);
-
-       if (!strcmp(cgroup->controller[0]->values[0]->name, "cpu.shares")) {
-               if (strcmp(cgroup->controller[0]->values[0]->value, "2048")) {
-                       printf("FAIL for add_value_int\n");
-                       fail = 1;
-               }
-       }
-
-       if (!strcmp(cgroup->controller[0]->values[1]->name, "cpu.something")) {
-               if (strcmp(cgroup->controller[0]->values[1]->value, "1000")) {
-                       printf("FAIL for add_value_uint\n");
-                       fail = 1;
-               }
-       }
-
-       if (!strcmp(cgroup->controller[0]->values[2]->name, "cpu.bool")) {
-               if (strcmp(cgroup->controller[0]->values[2]->value, "1")) {
-                       printf("FAIL for add_value_bool\n");
-                       fail = 1;
-               }
-       }
-
-       if (!fail)
-               printf("PASS!\n");
-
-       return fail;
-}