[LTP] [PATCH v2] Remove libclone library from containers suite

Andrea Cervesato andrea.cervesato@suse.de
Thu Sep 14 15:42:22 CEST 2023


From: Andrea Cervesato <andrea.cervesato@suse.com>

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/containers/Makefile          |  27 +---
 testcases/kernel/containers/Makefile.inc      |  45 ------
 testcases/kernel/containers/README            |   2 -
 testcases/kernel/containers/libclone/Makefile |  27 ----
 .../kernel/containers/libclone/libclone.c     | 142 ------------------
 .../kernel/containers/libclone/libclone.h     |  81 ----------
 testcases/kernel/containers/netns/Makefile    |   4 +-
 testcases/kernel/containers/pidns/Makefile    |   3 +-
 .../kernel/containers/pidns/pidns_helper.h    |  34 -----
 testcases/kernel/containers/userns/Makefile   |   1 -
 testcases/kernel/containers/utsname/Makefile  |   3 +-
 11 files changed, 5 insertions(+), 364 deletions(-)
 delete mode 100644 testcases/kernel/containers/Makefile.inc
 delete mode 100644 testcases/kernel/containers/libclone/Makefile
 delete mode 100644 testcases/kernel/containers/libclone/libclone.c
 delete mode 100644 testcases/kernel/containers/libclone/libclone.h
 delete mode 100644 testcases/kernel/containers/pidns/pidns_helper.h

diff --git a/testcases/kernel/containers/Makefile b/testcases/kernel/containers/Makefile
index 4285546e7..20d2424a5 100644
--- a/testcases/kernel/containers/Makefile
+++ b/testcases/kernel/containers/Makefile
@@ -1,33 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) International Business Machines  Corp., 2007
+# Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
 
 top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
-
-LIBDIR			:= libclone
-
-FILTER_OUT_DIRS		:= $(LIBDIR)
-
-LIB			:= $(LIBDIR)/libclone.a
-
-LDLIBS			:= -ldl -lltp
-
-INSTALL_TARGETS		:= *.sh
-
-$(LIBDIR):
-	mkdir -p "$@"
-
-# Make the target the real lib so we don't have to deal with rebuilding this
-# every time the dependency is evaluated, like with PHONY rules.
-$(LIB): $(LIBDIR)
-	$(MAKE) -C $^ -f "$(abs_srcdir)/$(LIBDIR)/Makefile" all
-
-MAKE_DEPS		:= $(LIB)
-
-trunk-clean:: | lib-clean
-
-lib-clean:: $(LIBDIR)
-	$(MAKE) -C $^ -f "$(abs_srcdir)/$(LIBDIR)/Makefile" clean
-
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/containers/Makefile.inc b/testcases/kernel/containers/Makefile.inc
deleted file mode 100644
index 179809bc1..000000000
--- a/testcases/kernel/containers/Makefile.inc
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-#    kernel/containers testcase suite common definitions Makefile.
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
-#
-#    This program is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License along
-#    with this program; if not, write to the Free Software Foundation, Inc.,
-#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Ngie Cooper, July 2009
-#
-
-# DO NOT USE THIS FILE FOR containers / libclone!!!
-
-LIBDIR			:= ../libclone
-
-LIBS			:= $(LIBDIR)/libclone.a
-
-CPPFLAGS		+= -I$(abs_srcdir)/$(LIBDIR)
-
-LDFLAGS			+= -L$(abs_builddir)/$(LIBDIR)
-
-$(LIBDIR):
-	mkdir -p "$@"
-
-# Make the target the real lib so we don't have to deal with rebuilding this
-# every time the dependency is evaluated, like with PHONY rules.
-$(LIBS): $(LIBDIR)
-	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" all
-
-INSTALL_TARGETS		?= *.sh
-
-MAKE_DEPS		:= $(LIBS)
-
-# vim: syntax=make
diff --git a/testcases/kernel/containers/README b/testcases/kernel/containers/README
index c99cacd98..df909e526 100644
--- a/testcases/kernel/containers/README
+++ b/testcases/kernel/containers/README
@@ -44,7 +44,5 @@ posixmq/*
 	enabled in the kernel without SYSV IPC support.
 utsname/*
 	Contains all the testcases related to utsname tests.
-libclone/*
-	Contains the library API for clone() .
 netns/*
         Contains the testcases related to the network NS tests.
diff --git a/testcases/kernel/containers/libclone/Makefile b/testcases/kernel/containers/libclone/Makefile
deleted file mode 100644
index 13af52b67..000000000
--- a/testcases/kernel/containers/libclone/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2007                 ##
-##                                                                            ##
-## This program is free software;  you can redistribute it and#or modify      ##
-## it under the terms of the GNU General Public License as published by       ##
-## the Free Software Foundation; either version 2 of the License, or          ##
-## (at your option) any later version.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will be useful, but        ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
-## for more details.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-################################################################################
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/testcases.mk
-
-INTERNAL_LIB		:= libclone.a
-
-include $(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/kernel/containers/libclone/libclone.c b/testcases/kernel/containers/libclone/libclone.c
deleted file mode 100644
index db0d9b2a5..000000000
--- a/testcases/kernel/containers/libclone/libclone.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
-* Copyright (c) International Business Machines Corp., 2007
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
-* the GNU General Public License for more details.
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*
-***************************************************************************/
-#include "libclone.h"
-
-int do_clone_tests(unsigned long clone_flags,
-		   int (*fn1) (void *arg), void *arg1,
-		   int (*fn2) (void *arg), void *arg2)
-{
-	int ret;
-
-	ret = ltp_clone_quick(clone_flags | SIGCHLD, fn1, arg1);
-
-	if (ret == -1) {
-		return -1;
-	}
-	if (fn2)
-		ret = fn2(arg2);
-	else
-		ret = 0;
-
-	return ret;
-}
-
-int do_unshare_tests(unsigned long clone_flags,
-		     int (*fn1) (void *arg), void *arg1,
-		     int (*fn2) (void *arg), void *arg2)
-{
-	int pid, ret = 0;
-	int retpipe[2];
-	char buf[2];
-
-	if (pipe(retpipe) == -1) {
-		perror("pipe");
-		return -1;
-	}
-	pid = fork();
-	if (pid == -1) {
-		perror("fork");
-		close(retpipe[0]);
-		close(retpipe[1]);
-		return -1;
-	}
-	if (pid == 0) {
-		close(retpipe[0]);
-		ret = tst_syscall(SYS_unshare, clone_flags);
-		if (ret == -1) {
-			if (write(retpipe[1], "0", 2) < 0) {
-				perror("unshare:write(retpipe[1], ..)");
-			}
-			close(retpipe[1]);
-			exit(1);
-		} else {
-			if (write(retpipe[1], "1", 2) < 0) {
-				perror("unshare:write(retpipe[1], ..)");
-			}
-		}
-		close(retpipe[1]);
-		ret = fn1(arg1);
-		exit(ret);
-	} else {
-		close(retpipe[1]);
-		if (read(retpipe[0], &buf, 2) < 0) {
-			perror("unshare:read(retpipe[0], ..)");
-		}
-		close(retpipe[0]);
-		if (*buf == '0')
-			return -1;
-		if (fn2)
-			ret = fn2(arg2);
-	}
-
-	return ret;
-}
-
-int do_plain_tests(int (*fn1) (void *arg), void *arg1,
-		   int (*fn2) (void *arg), void *arg2)
-{
-	int ret = 0, pid;
-
-	pid = fork();
-	if (pid == -1) {
-		perror("fork");
-		return -1;
-	}
-	if (pid == 0)
-		exit(fn1(arg1));
-	if (fn2)
-		ret = fn2(arg2);
-	return ret;
-}
-
-int do_clone_unshare_test(int use_clone, unsigned long clone_flags,
-			  int (*fn1) (void *arg), void *arg1)
-{
-	switch (use_clone) {
-	case T_NONE:
-		return do_plain_tests(fn1, arg1, NULL, NULL);
-	case T_CLONE:
-		return do_clone_tests(clone_flags, fn1, arg1, NULL, NULL);
-	case T_UNSHARE:
-		return do_unshare_tests(clone_flags, fn1, arg1, NULL, NULL);
-	default:
-		printf("%s: bad use_clone option: %d\n", __FUNCTION__,
-		       use_clone);
-		return -1;
-	}
-}
-
-/*
- * Run fn1 in a unshared environmnent, and fn2 in the original context
- */
-int do_clone_unshare_tests(int use_clone, unsigned long clone_flags,
-			   int (*fn1) (void *arg), void *arg1,
-			   int (*fn2) (void *arg), void *arg2)
-{
-	switch (use_clone) {
-	case T_NONE:
-		return do_plain_tests(fn1, arg1, fn2, arg2);
-	case T_CLONE:
-		return do_clone_tests(clone_flags, fn1, arg1, fn2, arg2);
-	case T_UNSHARE:
-		return do_unshare_tests(clone_flags, fn1, arg1, fn2, arg2);
-	default:
-		printf("%s: bad use_clone option: %d\n", __FUNCTION__,
-		       use_clone);
-		return -1;
-	}
-}
diff --git a/testcases/kernel/containers/libclone/libclone.h b/testcases/kernel/containers/libclone/libclone.h
deleted file mode 100644
index e92fdca02..000000000
--- a/testcases/kernel/containers/libclone/libclone.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-* Copyright (c) International Business Machines Corp., 2007
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
-* the GNU General Public License for more details.
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*
-***************************************************************************/
-#ifndef __LIBCLONE_H
-#define __LIBCLONE_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <libgen.h>
-#include <sys/syscall.h>
-#include <signal.h>
-#include "lapi/syscalls.h"
-#include "test.h"
-#include "lapi/sched.h"
-
-#define T_UNSHARE 0
-#define T_CLONE 1
-#define T_NONE 2
-
-#ifndef SYS_unshare
-#ifdef __NR_unshare
-#define SYS_unshare __NR_unshare
-#elif __i386__
-#define SYS_unshare 310
-#elif __ia64__
-#define SYS_unshare 1296
-#elif __x86_64__
-#define SYS_unshare 272
-#elif __s390x__ || __s390__
-#define SYS_unshare 303
-#elif __powerpc__
-#define SYS_unshare 282
-#else
-#error "unshare not supported on this architecure."
-#endif
-#endif
-
-#ifndef __NR_unshare
-#define __NR_unshare SYS_unshare
-#endif
-
-/*
- * Run fn1 in a unshared environmnent, and fn2 in the original context
- * Fn2 may be NULL.
- */
-
-int do_clone_tests(unsigned long clone_flags,
-			int(*fn1)(void *arg), void *arg1,
-			int(*fn2)(void *arg), void *arg2);
-
-int do_unshare_tests(unsigned long clone_flags,
-			int (*fn1)(void *arg), void *arg1,
-			int (*fn2)(void *arg), void *arg2);
-
-int do_fork_tests(int (*fn1)(void *arg), void *arg1,
-			int (*fn2)(void *arg), void *arg2);
-
-int do_clone_unshare_test(int use_clone, unsigned long clone_flags,
-			int (*fn1)(void *arg), void *arg1);
-
-int do_clone_unshare_tests(int use_clone, unsigned long clone_flags,
-			int (*fn1)(void *arg), void *arg1,
-			int (*fn2)(void *arg), void *arg2);
-
-#endif
diff --git a/testcases/kernel/containers/netns/Makefile b/testcases/kernel/containers/netns/Makefile
index 3cc2b4ae7..a8edd31b8 100644
--- a/testcases/kernel/containers/netns/Makefile
+++ b/testcases/kernel/containers/netns/Makefile
@@ -2,12 +2,12 @@
 # Copyright (c) International Business Machines  Corp., 2008
 # Author: Veerendra <veeren@linux.vnet.ibm.com>
 # Copyright (c) 2015 Red Hat, Inc.
+# Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
 
 top_srcdir              ?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
 
-LDLIBS                  := -lclone -lltp
+INSTALL_TARGETS		:= *.sh
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/containers/pidns/Makefile b/testcases/kernel/containers/pidns/Makefile
index 5f8383c3c..b99df9f74 100644
--- a/testcases/kernel/containers/pidns/Makefile
+++ b/testcases/kernel/containers/pidns/Makefile
@@ -4,8 +4,7 @@
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
 
-LDLIBS			:= -lpthread -lrt -lclone $(LDLIBS)
+LDLIBS			:= -lpthread -lrt $(LDLIBS)
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/containers/pidns/pidns_helper.h b/testcases/kernel/containers/pidns/pidns_helper.h
deleted file mode 100644
index 3b356768f..000000000
--- a/testcases/kernel/containers/pidns/pidns_helper.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-* Copyright (c) International Business Machines Corp., 2007
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
-* the GNU General Public License for more details.
-*/
-
-#include "../libclone/libclone.h"
-#include "test.h"
-#include "safe_macros.h"
-
-static int dummy_child(void *v)
-{
-	(void) v;
-	return 0;
-}
-
-static int check_newpid(void)
-{
-	int pid, status;
-
-	pid = do_clone_unshare_test(T_CLONE, CLONE_NEWPID, dummy_child, NULL);
-	if (pid == -1)
-		tst_brkm(TCONF | TERRNO, NULL, "CLONE_NEWPID not supported");
-	SAFE_WAIT(NULL, &status);
-
-	return 0;
-}
diff --git a/testcases/kernel/containers/userns/Makefile b/testcases/kernel/containers/userns/Makefile
index 018ab000b..cc1d14604 100644
--- a/testcases/kernel/containers/userns/Makefile
+++ b/testcases/kernel/containers/userns/Makefile
@@ -19,7 +19,6 @@
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
 
 LDLIBS			:= $(LDLIBS) $(CAP_LIBS)
 
diff --git a/testcases/kernel/containers/utsname/Makefile b/testcases/kernel/containers/utsname/Makefile
index 9c0158c01..603a3cd6e 100644
--- a/testcases/kernel/containers/utsname/Makefile
+++ b/testcases/kernel/containers/utsname/Makefile
@@ -4,8 +4,7 @@
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
 
-LDLIBS			:= -lclone $(LDLIBS)
+LDLIBS			:= $(LDLIBS)
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
-- 
2.35.3



More information about the ltp mailing list