* [LTP] [PATCH 0/3] Move container utils to testcases/lib/
@ 2023-03-10 12:41 Petr Vorel
2023-03-10 12:41 ` [LTP] [PATCH 1/3] ns_exec.c: Rename to testcases/lib/tst_ns_exec.c Petr Vorel
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Petr Vorel @ 2023-03-10 12:41 UTC (permalink / raw)
To: ltp
Preparation for https://github.com/linux-test-project/ltp/issues/991.
NOTE: this patch conflicts with my other patch [1]
(touching testcases/lib/{Makefile,.gitignore}).
Kind regards,
Petr
[1] https://patchwork.ozlabs.org/project/ltp/patch/20230307145517.1359-2-pvorel@suse.cz/
Petr Vorel (3):
ns_exec.c: Rename to testcases/lib/tst_ns_exec.c
ns_create.c: Rename to testcases/lib/tst_ns_create.c
ns_ifmove.c: Rename to testcases/lib/tst_ns_ifmove.c
doc/namespaces-helper-tools.txt | 14 ++++++------
.../ns_common.h => include/tst_ns_common.h | 6 ++---
.../kernel/containers/netns/netns_lib.sh | 22 +++++++++----------
.../kernel/containers/netns/netns_sysfs.sh | 13 ++++++-----
testcases/kernel/containers/share/.gitignore | 3 ---
testcases/kernel/containers/share/Makefile | 22 -------------------
testcases/kernel/fs/fs_bind/fs_bind_lib.sh | 7 +++---
testcases/lib/.gitignore | 3 +++
testcases/lib/Makefile | 2 +-
testcases/lib/tst_net.sh | 16 +++++++-------
.../share/ns_create.c => lib/tst_ns_create.c} | 5 +++--
.../share/ns_exec.c => lib/tst_ns_exec.c} | 8 +++----
.../share/ns_ifmove.c => lib/tst_ns_ifmove.c} | 2 +-
13 files changed, 52 insertions(+), 71 deletions(-)
rename testcases/kernel/containers/share/ns_common.h => include/tst_ns_common.h (89%)
delete mode 100644 testcases/kernel/containers/share/.gitignore
delete mode 100644 testcases/kernel/containers/share/Makefile
rename testcases/{kernel/containers/share/ns_create.c => lib/tst_ns_create.c} (92%)
rename testcases/{kernel/containers/share/ns_exec.c => lib/tst_ns_exec.c} (91%)
rename testcases/{kernel/containers/share/ns_ifmove.c => lib/tst_ns_ifmove.c} (97%)
--
2.39.2
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 1/3] ns_exec.c: Rename to testcases/lib/tst_ns_exec.c
2023-03-10 12:41 [LTP] [PATCH 0/3] Move container utils to testcases/lib/ Petr Vorel
@ 2023-03-10 12:41 ` Petr Vorel
2023-03-10 12:41 ` [LTP] [PATCH 2/3] ns_create.c: Rename to testcases/lib/tst_ns_create.c Petr Vorel
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2023-03-10 12:41 UTC (permalink / raw)
To: ltp
It's not only a test, but also tool for tst_net.sh therefore better to
be in common tools directory.
Also move and rename common header to include/tst_ns_common.h.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
doc/namespaces-helper-tools.txt | 6 +++---
.../share/ns_common.h => include/tst_ns_common.h | 6 +++---
testcases/kernel/containers/netns/netns_lib.sh | 16 ++++++++--------
testcases/kernel/containers/netns/netns_sysfs.sh | 11 ++++++-----
testcases/kernel/containers/share/.gitignore | 1 -
testcases/kernel/containers/share/ns_create.c | 2 +-
testcases/kernel/fs/fs_bind/fs_bind_lib.sh | 5 +++--
testcases/lib/.gitignore | 1 +
testcases/lib/Makefile | 2 +-
testcases/lib/tst_net.sh | 12 ++++++------
.../share/ns_exec.c => lib/tst_ns_exec.c} | 8 ++++----
11 files changed, 36 insertions(+), 34 deletions(-)
rename testcases/kernel/containers/share/ns_common.h => include/tst_ns_common.h (89%)
rename testcases/{kernel/containers/share/ns_exec.c => lib/tst_ns_exec.c} (91%)
diff --git a/doc/namespaces-helper-tools.txt b/doc/namespaces-helper-tools.txt
index 81eec4d6c..e5a39657d 100644
--- a/doc/namespaces-helper-tools.txt
+++ b/doc/namespaces-helper-tools.txt
@@ -14,7 +14,7 @@ located in ltp/testcases/kernel/containers/share directory and include:
** PID of the daemonized child process is printed on the stdout
** the new namespace(s) is(are) maintained by the daemonized child process
** namespace(s) can be removed by killing the daemonized process
-* ns_exec
+* tst_ns_exec
** enters the namespace(s) of a process specified by a PID
** then executes the indicated program inside that namespace(s)
* ns_ifmove
@@ -39,13 +39,13 @@ myns=$(ns_create net,ipc)
ip link add veth0 type veth peer name veth1
# Executes command 'ip a' inside the namespace specified by PID in myns variable
-ns_exec $myns net,ipc ip a
+tst_ns_exec $myns net,ipc ip a
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
# Moves interface veth1 into the namespace specified by PID in myns variable
ns_ifmove veth1 $myns
-ns_exec $myns net,ipc ip a
+tst_ns_exec $myns net,ipc ip a
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
6: veth1: <BROADCAST> mtu 1500 qdisc noop state DOWN qlen 1000
diff --git a/testcases/kernel/containers/share/ns_common.h b/include/tst_ns_common.h
similarity index 89%
rename from testcases/kernel/containers/share/ns_common.h
rename to include/tst_ns_common.h
index 813cd3388..358db5141 100644
--- a/testcases/kernel/containers/share/ns_common.h
+++ b/include/tst_ns_common.h
@@ -3,8 +3,8 @@
* Copyright (c) Linux Test Project, 2015-2023
*/
-#ifndef __NS_COMMON_H__
-#define __NS_COMMON_H__
+#ifndef TST_NS_COMMON_H__
+#define TST_NS_COMMON_H__
#include <sched.h>
#include "lapi/sched.h"
@@ -39,4 +39,4 @@ static struct param *get_param(const char *name)
return NULL;
}
-#endif
+#endif /* TST_NS_COMMON_H__ */
diff --git a/testcases/kernel/containers/netns/netns_lib.sh b/testcases/kernel/containers/netns/netns_lib.sh
index 039631e9f..f5ce3b5e3 100755
--- a/testcases/kernel/containers/netns/netns_lib.sh
+++ b/testcases/kernel/containers/netns/netns_lib.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
-# Copyright (c) Linux Test Project, 2014-2021
+# Copyright (c) Linux Test Project, 2014-2023
# Copyright (c) 2015 Red Hat, Inc.
TST_NEEDS_ROOT=1
@@ -20,7 +20,7 @@ TST_NET_SKIP_VARIABLE_INIT=1
IPV4_NET16_UNUSED="10.23"
IPV6_NET32_UNUSED="fd00:23"
-# Set to "net" for ns_create/ns_exec as their options requires
+# Set to "net" for ns_create/tst_ns_exec as their options requires
# to specify a namespace type. Empty for ip command.
NS_TYPE=
@@ -28,7 +28,7 @@ NS_TYPE=
tping=
# Network namespaces handles for manipulating and executing commands inside
-# namespaces. For 'ns_exec' handles are PIDs of daemonized processes running
+# namespaces. For 'tst_ns_exec' handles are PIDs of daemonized processes running
# in namespaces.
NS_HANDLE0=
NS_HANDLE1=
@@ -40,7 +40,7 @@ NS_HANDLE1=
IFCONF_IN6_ARG=
# Program which will be used to enter and run other commands inside a network namespace.
-# (ns_exec|ip)
+# (tst_ns_exec|ip)
NS_EXEC="ip"
# Communication type between kernel and user space for basic setup: enabling and
@@ -54,7 +54,7 @@ do_cleanup=
netns_parse_args()
{
case $1 in
- e) NS_EXEC="ns_exec" ;;
+ e) NS_EXEC="tst_ns_exec" ;;
I) COMM_TYPE="ioctl"; tst_require_cmds ifconfig ;;
esac
}
@@ -63,7 +63,7 @@ netns_usage()
{
echo "usage: $0 [ -e ] [ -I ]"
echo "OPTIONS"
- echo "-e Use ns_exec instead of ip"
+ echo "-e Use tst_ns_exec instead of ip"
echo "-I Test ioctl (with ifconfig) instead of netlink (with ip)"
}
@@ -105,7 +105,7 @@ netns_cleanup()
fi
}
-# Sets up NS_EXEC to use 'ns_exec', creates two network namespaces and stores
+# Sets up NS_EXEC to use 'tst_ns_exec', creates two network namespaces and stores
# their handles into NS_HANDLE0 and NS_HANDLE1 variables (in this case handles
# are PIDs of daemonized processes running in these namespaces). Virtual
# ethernet device is then created for each namespace.
@@ -113,7 +113,7 @@ netns_ns_exec_setup()
{
local ret
- NS_EXEC="ns_exec"
+ NS_EXEC="tst_ns_exec"
NS_HANDLE0=$(ns_create $NS_TYPE)
if [ $? -eq 1 ]; then
diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh
index 34ef3b8ee..aca339bbf 100755
--- a/testcases/kernel/containers/netns/netns_sysfs.sh
+++ b/testcases/kernel/containers/netns/netns_sysfs.sh
@@ -2,6 +2,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) Köry Maincent <kory.maincent@bootlin.com> 2020
# Copyright (c) 2015 Red Hat, Inc.
+# Copyright (c) Linux Test Project, 2015-2023
#
# Tests that a separate network namespace cannot affect sysfs contents
# of the main namespace.
@@ -27,10 +28,10 @@ do_setup()
ip link add $DUMMYDEV_HOST type dummy || \
tst_brk TBROK "failed to add a new (host) dummy device"
- ns_exec $NS_HANDLE $NS_TYPE mount --make-rprivate /sys
- ns_exec $NS_HANDLE $NS_TYPE ip link add $DUMMYDEV type dummy || \
+ tst_ns_exec $NS_HANDLE $NS_TYPE mount --make-rprivate /sys
+ tst_ns_exec $NS_HANDLE $NS_TYPE ip link add $DUMMYDEV type dummy || \
tst_brk TBROK "failed to add a new dummy device"
- ns_exec $NS_HANDLE $NS_TYPE mount -t sysfs none /sys 2>/dev/null
+ tst_ns_exec $NS_HANDLE $NS_TYPE mount -t sysfs none /sys 2>/dev/null
}
do_cleanup()
@@ -42,8 +43,8 @@ do_cleanup()
do_test()
{
- EXPECT_PASS ns_exec $NS_HANDLE $NS_TYPE test -e /sys/class/net/$DUMMYDEV
- EXPECT_FAIL ns_exec $NS_HANDLE $NS_TYPE test -e /sys/class/net/$DUMMYDEV_HOST
+ EXPECT_PASS tst_ns_exec $NS_HANDLE $NS_TYPE test -e /sys/class/net/$DUMMYDEV
+ EXPECT_FAIL tst_ns_exec $NS_HANDLE $NS_TYPE test -e /sys/class/net/$DUMMYDEV_HOST
EXPECT_FAIL test -e /sys/class/net/$DUMMYDEV
}
diff --git a/testcases/kernel/containers/share/.gitignore b/testcases/kernel/containers/share/.gitignore
index 0d5ecf069..e490e86a6 100644
--- a/testcases/kernel/containers/share/.gitignore
+++ b/testcases/kernel/containers/share/.gitignore
@@ -1,3 +1,2 @@
/ns_ifmove
/ns_create
-/ns_exec
diff --git a/testcases/kernel/containers/share/ns_create.c b/testcases/kernel/containers/share/ns_create.c
index c2e05640c..09414b162 100644
--- a/testcases/kernel/containers/share/ns_create.c
+++ b/testcases/kernel/containers/share/ns_create.c
@@ -20,7 +20,7 @@
#include <stdio.h>
#include <string.h>
#include "tst_test.h"
-#include "ns_common.h"
+#include "tst_ns_common.h"
extern struct tst_test *tst_test;
diff --git a/testcases/kernel/fs/fs_bind/fs_bind_lib.sh b/testcases/kernel/fs/fs_bind/fs_bind_lib.sh
index 2dd9ef08f..2499ce68d 100644
--- a/testcases/kernel/fs/fs_bind/fs_bind_lib.sh
+++ b/testcases/kernel/fs/fs_bind/fs_bind_lib.sh
@@ -2,6 +2,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) International Business Machines Corp., 2005
# Copyright (c) 2021 Joerg Vehlow <joerg.vehlow@aox-tech.de>
+# Copyright (c) Linux Test Project, 2022-2023
# Based on work by: Avantika Mathur (mathurav@us.ibm.com)
TST_NEEDS_TMPDIR=1
@@ -109,7 +110,7 @@ fs_bind_check()
fi
if [ $use_ns -eq 1 ]; then
- output="$(ns_exec ${FS_BIND_MNTNS_PID} mnt diff -r "$PWD/$dir1" "$PWD/$dir2" 2> /dev/null)"
+ output="$(tst_ns_exec ${FS_BIND_MNTNS_PID} mnt diff -r "$PWD/$dir1" "$PWD/$dir2" 2> /dev/null)"
else
output="$(diff -r "$dir1" "$dir2" 2> /dev/null)"
fi
@@ -203,7 +204,7 @@ fs_bind_create_ns()
fs_bind_exec_ns()
{
[ -z "$FS_BIND_MNTNS_PID" ] && tst_brk TBROK "Namespace does not exist"
- EXPECT_PASS ns_exec $FS_BIND_MNTNS_PID mnt "$@"
+ EXPECT_PASS tst_ns_exec $FS_BIND_MNTNS_PID mnt "$@"
}
fs_bind_destroy_ns()
diff --git a/testcases/lib/.gitignore b/testcases/lib/.gitignore
index 34dea272d..318aa9fb7 100644
--- a/testcases/lib/.gitignore
+++ b/testcases/lib/.gitignore
@@ -11,6 +11,7 @@
/tst_net_iface_prefix
/tst_net_ip_prefix
/tst_net_vars
+/tst_ns_exec
/tst_random
/tst_rod
/tst_sleep
diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile
index f4f8c8524..e16a67c79 100644
--- a/testcases/lib/Makefile
+++ b/testcases/lib/Makefile
@@ -12,6 +12,6 @@ MAKE_TARGETS := tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\
tst_device tst_net_iface_prefix tst_net_ip_prefix tst_net_vars\
tst_getconf tst_supported_fs tst_check_drivers tst_get_unused_port\
tst_get_median tst_hexdump tst_get_free_pids tst_timeout_kill\
- tst_check_kconfigs tst_cgctl
+ tst_check_kconfigs tst_cgctl tst_ns_exec
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index fc64a588a..8c94d0f7b 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
-# Copyright (c) 2016-2022 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2016-2023 Petr Vorel <pvorel@suse.cz>
# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
[ -n "$TST_LIB_NET_LOADED" ] && return 0
@@ -115,7 +115,7 @@ init_ltp_netspace()
local pid
if [ ! -f /var/run/netns/ltp_ns -a -z "$LTP_NETNS" ]; then
- tst_require_cmds ip ns_create ns_exec ns_ifmove
+ tst_require_cmds ip ns_create tst_ns_exec ns_ifmove
tst_require_root
tst_require_drivers veth
@@ -123,10 +123,10 @@ init_ltp_netspace()
pid="$(ROD ns_create net,mnt)"
mkdir -p /var/run/netns
ROD ln -s /proc/$pid/ns/net /var/run/netns/ltp_ns
- ROD ns_exec $pid net,mnt mount --make-rprivate /sys
- ROD ns_exec $pid net,mnt mount -t sysfs none /sys
+ ROD tst_ns_exec $pid net,mnt mount --make-rprivate /sys
+ ROD tst_ns_exec $pid net,mnt mount -t sysfs none /sys
ROD ns_ifmove ltp_ns_veth1 $pid
- ROD ns_exec $pid net,mnt ip link set lo up
+ ROD tst_ns_exec $pid net,mnt ip link set lo up
elif [ -n "$LTP_NETNS" ]; then
tst_res_ TINFO "using not default LTP netns: '$LTP_NETNS'"
fi
@@ -135,7 +135,7 @@ init_ltp_netspace()
RHOST_IFACES="${RHOST_IFACES:-ltp_ns_veth1}"
pid="$(echo $(readlink /var/run/netns/ltp_ns) | cut -f3 -d'/')"
- export LTP_NETNS="${LTP_NETNS:-ns_exec $pid net,mnt}"
+ export LTP_NETNS="${LTP_NETNS:-tst_ns_exec $pid net,mnt}"
tst_restore_ipaddr
tst_restore_ipaddr rhost
diff --git a/testcases/kernel/containers/share/ns_exec.c b/testcases/lib/tst_ns_exec.c
similarity index 91%
rename from testcases/kernel/containers/share/ns_exec.c
rename to testcases/lib/tst_ns_exec.c
index b802bec9d..66a4e69d3 100644
--- a/testcases/kernel/containers/share/ns_exec.c
+++ b/testcases/lib/tst_ns_exec.c
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2015 Red Hat, Inc.
* Matus Marhefka <mmarhefk@redhat.com>
- * Copyright (c) Linux Test Project, 2015-2022
+ * Copyright (c) Linux Test Project, 2015-2023
* Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
*/
@@ -18,7 +18,7 @@
#include <stdio.h>
#include <sys/wait.h>
#include "tst_test.h"
-#include "ns_common.h"
+#include "tst_ns_common.h"
extern struct tst_test *tst_test;
@@ -33,7 +33,7 @@ static void print_help(void)
{
int i;
- printf("usage: ns_exec <NS_PID> <%s", params[0].name);
+ printf("usage: tst_ns_exec <NS_PID> <%s", params[0].name);
for (i = 1; params[i].name; i++)
printf("|,%s", params[i].name);
@@ -41,7 +41,7 @@ static void print_help(void)
printf("> <PROGRAM> [ARGS]\nSecond argument indicates the types"
" of a namespaces maintained by NS_PID\nand is specified"
" as a comma separated list.\n"
- "Example: ns_exec 1234 net,ipc ip a\n");
+ "Example: tst_ns_exec 1234 net,ipc ip a\n");
}
static void open_ns_fd(const char *pid, const char *ns)
--
2.39.2
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 2/3] ns_create.c: Rename to testcases/lib/tst_ns_create.c
2023-03-10 12:41 [LTP] [PATCH 0/3] Move container utils to testcases/lib/ Petr Vorel
2023-03-10 12:41 ` [LTP] [PATCH 1/3] ns_exec.c: Rename to testcases/lib/tst_ns_exec.c Petr Vorel
@ 2023-03-10 12:41 ` Petr Vorel
2023-03-10 12:41 ` [LTP] [PATCH 3/3] ns_ifmove.c: Rename to testcases/lib/tst_ns_ifmove.c Petr Vorel
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2023-03-10 12:41 UTC (permalink / raw)
To: ltp
It's not only a test, but also tool for tst_net.sh therefore better to
be in common tools directory.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
doc/namespaces-helper-tools.txt | 4 ++--
testcases/kernel/containers/netns/netns_lib.sh | 6 +++---
testcases/kernel/containers/netns/netns_sysfs.sh | 2 +-
testcases/kernel/containers/share/.gitignore | 1 -
testcases/kernel/fs/fs_bind/fs_bind_lib.sh | 2 +-
testcases/lib/.gitignore | 1 +
testcases/lib/Makefile | 2 +-
testcases/lib/tst_net.sh | 4 ++--
.../containers/share/ns_create.c => lib/tst_ns_create.c} | 3 ++-
9 files changed, 13 insertions(+), 12 deletions(-)
rename testcases/{kernel/containers/share/ns_create.c => lib/tst_ns_create.c} (94%)
diff --git a/doc/namespaces-helper-tools.txt b/doc/namespaces-helper-tools.txt
index e5a39657d..74d22593e 100644
--- a/doc/namespaces-helper-tools.txt
+++ b/doc/namespaces-helper-tools.txt
@@ -8,7 +8,7 @@ LTP namespaces helper tools
LTP provides helper tools for creating and working with namespaces. These are
located in ltp/testcases/kernel/containers/share directory and include:
-* ns_create
+* tst_ns_create
** creates a child process in the new specified namespace(s)
** child is then daemonized and is running in the background
** PID of the daemonized child process is printed on the stdout
@@ -34,7 +34,7 @@ The following code shows how test cases can use the namespaces helper tools:
-------------------------------------------------------------------------------
# Creates a new network and ipc namespace and stores the PID of the daemonized
# process inside that namespace into variable myns
-myns=$(ns_create net,ipc)
+myns=$(tst_ns_create net,ipc)
ip link add veth0 type veth peer name veth1
diff --git a/testcases/kernel/containers/netns/netns_lib.sh b/testcases/kernel/containers/netns/netns_lib.sh
index f5ce3b5e3..043127309 100755
--- a/testcases/kernel/containers/netns/netns_lib.sh
+++ b/testcases/kernel/containers/netns/netns_lib.sh
@@ -20,7 +20,7 @@ TST_NET_SKIP_VARIABLE_INIT=1
IPV4_NET16_UNUSED="10.23"
IPV6_NET32_UNUSED="fd00:23"
-# Set to "net" for ns_create/tst_ns_exec as their options requires
+# Set to "net" for tst_ns_create/tst_ns_exec as their options requires
# to specify a namespace type. Empty for ip command.
NS_TYPE=
@@ -115,13 +115,13 @@ netns_ns_exec_setup()
NS_EXEC="tst_ns_exec"
- NS_HANDLE0=$(ns_create $NS_TYPE)
+ NS_HANDLE0=$(tst_ns_create $NS_TYPE)
if [ $? -eq 1 ]; then
tst_res TINFO "$NS_HANDLE0"
tst_brk TBROK "unable to create a new network namespace"
fi
- NS_HANDLE1=$(ns_create $NS_TYPE)
+ NS_HANDLE1=$(tst_ns_create $NS_TYPE)
if [ $? -eq 1 ]; then
tst_res TINFO "$NS_HANDLE1"
tst_brk TBROK "unable to create a new network namespace"
diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh
index aca339bbf..814274fd0 100755
--- a/testcases/kernel/containers/netns/netns_sysfs.sh
+++ b/testcases/kernel/containers/netns/netns_sysfs.sh
@@ -19,7 +19,7 @@ do_setup()
DUMMYDEV_HOST="dummy_test0"
DUMMYDEV="dummy_test1"
- NS_HANDLE=$(ns_create $NS_TYPE)
+ NS_HANDLE=$(tst_ns_create $NS_TYPE)
if [ $? -eq 1 ]; then
tst_res TINFO "$NS_HANDLE"
tst_brk TBROK "unable to create a new network namespace"
diff --git a/testcases/kernel/containers/share/.gitignore b/testcases/kernel/containers/share/.gitignore
index e490e86a6..1c5bd4ba7 100644
--- a/testcases/kernel/containers/share/.gitignore
+++ b/testcases/kernel/containers/share/.gitignore
@@ -1,2 +1 @@
/ns_ifmove
-/ns_create
diff --git a/testcases/kernel/fs/fs_bind/fs_bind_lib.sh b/testcases/kernel/fs/fs_bind/fs_bind_lib.sh
index 2499ce68d..52190a7ca 100644
--- a/testcases/kernel/fs/fs_bind/fs_bind_lib.sh
+++ b/testcases/kernel/fs/fs_bind/fs_bind_lib.sh
@@ -198,7 +198,7 @@ _fs_bind_setup_test()
fs_bind_create_ns()
{
[ -n "$FS_BIND_MNTNS_PID" ] && tst_brk TBROK "Namespace exist already"
- FS_BIND_MNTNS_PID=$(ns_create mnt)
+ FS_BIND_MNTNS_PID=$(tst_ns_create mnt)
}
fs_bind_exec_ns()
diff --git a/testcases/lib/.gitignore b/testcases/lib/.gitignore
index 318aa9fb7..35c2b93ff 100644
--- a/testcases/lib/.gitignore
+++ b/testcases/lib/.gitignore
@@ -11,6 +11,7 @@
/tst_net_iface_prefix
/tst_net_ip_prefix
/tst_net_vars
+/tst_ns_create
/tst_ns_exec
/tst_random
/tst_rod
diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile
index e16a67c79..52d17c914 100644
--- a/testcases/lib/Makefile
+++ b/testcases/lib/Makefile
@@ -12,6 +12,6 @@ MAKE_TARGETS := tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\
tst_device tst_net_iface_prefix tst_net_ip_prefix tst_net_vars\
tst_getconf tst_supported_fs tst_check_drivers tst_get_unused_port\
tst_get_median tst_hexdump tst_get_free_pids tst_timeout_kill\
- tst_check_kconfigs tst_cgctl tst_ns_exec
+ tst_check_kconfigs tst_cgctl tst_ns_create tst_ns_exec
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index 8c94d0f7b..f4ec1a11d 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -115,12 +115,12 @@ init_ltp_netspace()
local pid
if [ ! -f /var/run/netns/ltp_ns -a -z "$LTP_NETNS" ]; then
- tst_require_cmds ip ns_create tst_ns_exec ns_ifmove
+ tst_require_cmds ip tst_ns_create tst_ns_exec ns_ifmove
tst_require_root
tst_require_drivers veth
ROD ip link add name ltp_ns_veth1 type veth peer name ltp_ns_veth2
- pid="$(ROD ns_create net,mnt)"
+ pid="$(ROD tst_ns_create net,mnt)"
mkdir -p /var/run/netns
ROD ln -s /proc/$pid/ns/net /var/run/netns/ltp_ns
ROD tst_ns_exec $pid net,mnt mount --make-rprivate /sys
diff --git a/testcases/kernel/containers/share/ns_create.c b/testcases/lib/tst_ns_create.c
similarity index 94%
rename from testcases/kernel/containers/share/ns_create.c
rename to testcases/lib/tst_ns_create.c
index 09414b162..1c6258cd1 100644
--- a/testcases/kernel/containers/share/ns_create.c
+++ b/testcases/lib/tst_ns_create.c
@@ -3,6 +3,7 @@
* Copyright (c) 2015 Red Hat, Inc.
* Matus Marhefka <mmarhefk@redhat.com>
* Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ * Copyright (c) Linux Test Project, 2020-2023
*/
/*\
@@ -32,7 +33,7 @@ static void print_help(void)
{
int i;
- printf("usage: ns_create <%s", params[0].name);
+ printf("usage: tst_ns_create <%s", params[0].name);
for (i = 1; params[i].name; i++)
printf("|,%s", params[i].name);
--
2.39.2
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 3/3] ns_ifmove.c: Rename to testcases/lib/tst_ns_ifmove.c
2023-03-10 12:41 [LTP] [PATCH 0/3] Move container utils to testcases/lib/ Petr Vorel
2023-03-10 12:41 ` [LTP] [PATCH 1/3] ns_exec.c: Rename to testcases/lib/tst_ns_exec.c Petr Vorel
2023-03-10 12:41 ` [LTP] [PATCH 2/3] ns_create.c: Rename to testcases/lib/tst_ns_create.c Petr Vorel
@ 2023-03-10 12:41 ` Petr Vorel
2023-03-10 12:42 ` [LTP] [PATCH 0/3] Move container utils to testcases/lib/ Petr Vorel
2023-03-13 15:06 ` Cyril Hrubis
4 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2023-03-10 12:41 UTC (permalink / raw)
To: ltp
It's not only a test, but also tool for tst_net.sh therefore better to
be in common tools directory.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
doc/namespaces-helper-tools.txt | 4 ++--
.../kernel/containers/netns/netns_lib.sh | 2 +-
testcases/kernel/containers/share/.gitignore | 1 -
testcases/kernel/containers/share/Makefile | 22 -------------------
testcases/lib/.gitignore | 1 +
testcases/lib/Makefile | 2 +-
testcases/lib/tst_net.sh | 4 ++--
.../share/ns_ifmove.c => lib/tst_ns_ifmove.c} | 2 +-
8 files changed, 8 insertions(+), 30 deletions(-)
delete mode 100644 testcases/kernel/containers/share/.gitignore
delete mode 100644 testcases/kernel/containers/share/Makefile
rename testcases/{kernel/containers/share/ns_ifmove.c => lib/tst_ns_ifmove.c} (97%)
diff --git a/doc/namespaces-helper-tools.txt b/doc/namespaces-helper-tools.txt
index 74d22593e..b911dd6cc 100644
--- a/doc/namespaces-helper-tools.txt
+++ b/doc/namespaces-helper-tools.txt
@@ -17,7 +17,7 @@ located in ltp/testcases/kernel/containers/share directory and include:
* tst_ns_exec
** enters the namespace(s) of a process specified by a PID
** then executes the indicated program inside that namespace(s)
-* ns_ifmove
+* tst_ns_ifmove
** moves a network interface to the namespace of a process specified by a PID
Purpose of these helper tools is the ability to execute test cases utilizing
@@ -44,7 +44,7 @@ tst_ns_exec $myns net,ipc ip a
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
# Moves interface veth1 into the namespace specified by PID in myns variable
-ns_ifmove veth1 $myns
+tst_ns_ifmove veth1 $myns
tst_ns_exec $myns net,ipc ip a
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
diff --git a/testcases/kernel/containers/netns/netns_lib.sh b/testcases/kernel/containers/netns/netns_lib.sh
index 043127309..f6977f729 100755
--- a/testcases/kernel/containers/netns/netns_lib.sh
+++ b/testcases/kernel/containers/netns/netns_lib.sh
@@ -130,7 +130,7 @@ netns_ns_exec_setup()
$NS_EXEC $NS_HANDLE0 $NS_TYPE ip link add veth0 type veth peer name veth1 || \
tst_brk TBROK "unable to create veth pair devices"
- $NS_EXEC $NS_HANDLE0 $NS_TYPE ns_ifmove veth1 $NS_HANDLE1
+ $NS_EXEC $NS_HANDLE0 $NS_TYPE tst_ns_ifmove veth1 $NS_HANDLE1
ret=$?
[ $ret -eq 0 ] && return
[ $ret -eq 32 ] && tst_brk TCONF "IFLA_NET_NS_PID not supported"
diff --git a/testcases/kernel/containers/share/.gitignore b/testcases/kernel/containers/share/.gitignore
deleted file mode 100644
index 1c5bd4ba7..000000000
--- a/testcases/kernel/containers/share/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/ns_ifmove
diff --git a/testcases/kernel/containers/share/Makefile b/testcases/kernel/containers/share/Makefile
deleted file mode 100644
index 962d6889d..000000000
--- a/testcases/kernel/containers/share/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (c) 2015 Red Hat, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of version 2 the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# 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, see <http://www.gnu.org/licenses/>.
-##############################################################################
-top_srcdir ?= ../../../..
-
-include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
-
-LDLIBS := -lltp
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/.gitignore b/testcases/lib/.gitignore
index 35c2b93ff..01048647a 100644
--- a/testcases/lib/.gitignore
+++ b/testcases/lib/.gitignore
@@ -13,6 +13,7 @@
/tst_net_vars
/tst_ns_create
/tst_ns_exec
+/tst_ns_ifmove
/tst_random
/tst_rod
/tst_sleep
diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile
index 52d17c914..e9d33892d 100644
--- a/testcases/lib/Makefile
+++ b/testcases/lib/Makefile
@@ -12,6 +12,6 @@ MAKE_TARGETS := tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\
tst_device tst_net_iface_prefix tst_net_ip_prefix tst_net_vars\
tst_getconf tst_supported_fs tst_check_drivers tst_get_unused_port\
tst_get_median tst_hexdump tst_get_free_pids tst_timeout_kill\
- tst_check_kconfigs tst_cgctl tst_ns_create tst_ns_exec
+ tst_check_kconfigs tst_cgctl tst_ns_create tst_ns_exec tst_ns_ifmove
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index f4ec1a11d..8be61da2d 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -115,7 +115,7 @@ init_ltp_netspace()
local pid
if [ ! -f /var/run/netns/ltp_ns -a -z "$LTP_NETNS" ]; then
- tst_require_cmds ip tst_ns_create tst_ns_exec ns_ifmove
+ tst_require_cmds ip tst_ns_create tst_ns_exec tst_ns_ifmove
tst_require_root
tst_require_drivers veth
@@ -125,7 +125,7 @@ init_ltp_netspace()
ROD ln -s /proc/$pid/ns/net /var/run/netns/ltp_ns
ROD tst_ns_exec $pid net,mnt mount --make-rprivate /sys
ROD tst_ns_exec $pid net,mnt mount -t sysfs none /sys
- ROD ns_ifmove ltp_ns_veth1 $pid
+ ROD tst_ns_ifmove ltp_ns_veth1 $pid
ROD tst_ns_exec $pid net,mnt ip link set lo up
elif [ -n "$LTP_NETNS" ]; then
tst_res_ TINFO "using not default LTP netns: '$LTP_NETNS'"
diff --git a/testcases/kernel/containers/share/ns_ifmove.c b/testcases/lib/tst_ns_ifmove.c
similarity index 97%
rename from testcases/kernel/containers/share/ns_ifmove.c
rename to testcases/lib/tst_ns_ifmove.c
index 60dda94d3..cbf6ac746 100644
--- a/testcases/kernel/containers/share/ns_ifmove.c
+++ b/testcases/lib/tst_ns_ifmove.c
@@ -58,7 +58,7 @@ int main(int argc, char **argv)
int intf_index, pid, rtnetlink_socket;
if (argc != 3) {
- printf("ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>\n");
+ printf("tst_ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>\n");
return 1;
}
--
2.39.2
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH 0/3] Move container utils to testcases/lib/
2023-03-10 12:41 [LTP] [PATCH 0/3] Move container utils to testcases/lib/ Petr Vorel
` (2 preceding siblings ...)
2023-03-10 12:41 ` [LTP] [PATCH 3/3] ns_ifmove.c: Rename to testcases/lib/tst_ns_ifmove.c Petr Vorel
@ 2023-03-10 12:42 ` Petr Vorel
2023-03-13 15:06 ` Cyril Hrubis
4 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2023-03-10 12:42 UTC (permalink / raw)
To: ltp
NOTE: this must be merged first:
https://patchwork.ozlabs.org/project/ltp/patch/20230309145917.26846-1-pvorel@suse.cz/
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH 0/3] Move container utils to testcases/lib/
2023-03-10 12:41 [LTP] [PATCH 0/3] Move container utils to testcases/lib/ Petr Vorel
` (3 preceding siblings ...)
2023-03-10 12:42 ` [LTP] [PATCH 0/3] Move container utils to testcases/lib/ Petr Vorel
@ 2023-03-13 15:06 ` Cyril Hrubis
2023-03-13 15:30 ` Petr Vorel
4 siblings, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2023-03-13 15:06 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> Preparation for https://github.com/linux-test-project/ltp/issues/991.
>
> NOTE: this patch conflicts with my other patch [1]
> (touching testcases/lib/{Makefile,.gitignore}).
>
> Kind regards,
> Petr
>
> [1] https://patchwork.ozlabs.org/project/ltp/patch/20230307145517.1359-2-pvorel@suse.cz/
>
>
> Petr Vorel (3):
> ns_exec.c: Rename to testcases/lib/tst_ns_exec.c
> ns_create.c: Rename to testcases/lib/tst_ns_create.c
> ns_ifmove.c: Rename to testcases/lib/tst_ns_ifmove.c
>
> doc/namespaces-helper-tools.txt | 14 ++++++------
> .../ns_common.h => include/tst_ns_common.h | 6 ++---
I'm not sure about moving this header into top level include, it would
probably make more sense to add it next to the C files that include it.
> .../kernel/containers/netns/netns_lib.sh | 22 +++++++++----------
> .../kernel/containers/netns/netns_sysfs.sh | 13 ++++++-----
> testcases/kernel/containers/share/.gitignore | 3 ---
> testcases/kernel/containers/share/Makefile | 22 -------------------
> testcases/kernel/fs/fs_bind/fs_bind_lib.sh | 7 +++---
> testcases/lib/.gitignore | 3 +++
> testcases/lib/Makefile | 2 +-
> testcases/lib/tst_net.sh | 16 +++++++-------
> .../share/ns_create.c => lib/tst_ns_create.c} | 5 +++--
> .../share/ns_exec.c => lib/tst_ns_exec.c} | 8 +++----
> .../share/ns_ifmove.c => lib/tst_ns_ifmove.c} | 2 +-
> 13 files changed, 52 insertions(+), 71 deletions(-)
> rename testcases/kernel/containers/share/ns_common.h => include/tst_ns_common.h (89%)
> delete mode 100644 testcases/kernel/containers/share/.gitignore
> delete mode 100644 testcases/kernel/containers/share/Makefile
> rename testcases/{kernel/containers/share/ns_create.c => lib/tst_ns_create.c} (92%)
> rename testcases/{kernel/containers/share/ns_exec.c => lib/tst_ns_exec.c} (91%)
> rename testcases/{kernel/containers/share/ns_ifmove.c => lib/tst_ns_ifmove.c} (97%)
>
> --
> 2.39.2
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH 0/3] Move container utils to testcases/lib/
2023-03-13 15:06 ` Cyril Hrubis
@ 2023-03-13 15:30 ` Petr Vorel
2023-03-23 9:22 ` Petr Vorel
0 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2023-03-13 15:30 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
> Hi!
> > Preparation for https://github.com/linux-test-project/ltp/issues/991.
> > NOTE: this patch conflicts with my other patch [1]
> > (touching testcases/lib/{Makefile,.gitignore}).
> > Kind regards,
> > Petr
> > [1] https://patchwork.ozlabs.org/project/ltp/patch/20230307145517.1359-2-pvorel@suse.cz/
> > Petr Vorel (3):
> > ns_exec.c: Rename to testcases/lib/tst_ns_exec.c
> > ns_create.c: Rename to testcases/lib/tst_ns_create.c
> > ns_ifmove.c: Rename to testcases/lib/tst_ns_ifmove.c
> > doc/namespaces-helper-tools.txt | 14 ++++++------
> > .../ns_common.h => include/tst_ns_common.h | 6 ++---
> I'm not sure about moving this header into top level include, it would
> probably make more sense to add it next to the C files that include it.
Sure, I'll put it there before merge (if it's the only thing to change).
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH 0/3] Move container utils to testcases/lib/
2023-03-13 15:30 ` Petr Vorel
@ 2023-03-23 9:22 ` Petr Vorel
0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2023-03-23 9:22 UTC (permalink / raw)
To: Cyril Hrubis, ltp
> > Hi!
> > > Preparation for https://github.com/linux-test-project/ltp/issues/991.
> > > NOTE: this patch conflicts with my other patch [1]
> > > (touching testcases/lib/{Makefile,.gitignore}).
> > > Kind regards,
> > > Petr
> > > [1] https://patchwork.ozlabs.org/project/ltp/patch/20230307145517.1359-2-pvorel@suse.cz/
> > > Petr Vorel (3):
> > > ns_exec.c: Rename to testcases/lib/tst_ns_exec.c
> > > ns_create.c: Rename to testcases/lib/tst_ns_create.c
> > > ns_ifmove.c: Rename to testcases/lib/tst_ns_ifmove.c
> > > doc/namespaces-helper-tools.txt | 14 ++++++------
> > > .../ns_common.h => include/tst_ns_common.h | 6 ++---
> > I'm not sure about moving this header into top level include, it would
> > probably make more sense to add it next to the C files that include it.
> Sure, I'll put it there before merge (if it's the only thing to change).
BTW having header in testcases/lib/ will require to move ns_create.c together
with ns_exec.c in single commit (squash these 2 commits). But that should not be
a big deal.
Kind regards,
Petr
> Kind regards,
> Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-03-23 9:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 12:41 [LTP] [PATCH 0/3] Move container utils to testcases/lib/ Petr Vorel
2023-03-10 12:41 ` [LTP] [PATCH 1/3] ns_exec.c: Rename to testcases/lib/tst_ns_exec.c Petr Vorel
2023-03-10 12:41 ` [LTP] [PATCH 2/3] ns_create.c: Rename to testcases/lib/tst_ns_create.c Petr Vorel
2023-03-10 12:41 ` [LTP] [PATCH 3/3] ns_ifmove.c: Rename to testcases/lib/tst_ns_ifmove.c Petr Vorel
2023-03-10 12:42 ` [LTP] [PATCH 0/3] Move container utils to testcases/lib/ Petr Vorel
2023-03-13 15:06 ` Cyril Hrubis
2023-03-13 15:30 ` Petr Vorel
2023-03-23 9:22 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).