[LTP] [PATCH v5 1/3] lib: add tst_get_free_pids helper program
Krzysztof Kozlowski
krzysztof.kozlowski@canonical.com
Wed Sep 1 17:16:53 CEST 2021
Add a tst_get_free_pids helper program so shell code can get limit of
tasks/PIDs in the system without duplicating that code.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
Changes since v4:
1. Add SPDX
Changes since v3:
1. New patch
---
testcases/lib/.gitignore | 1 +
testcases/lib/Makefile | 2 +-
testcases/lib/tst_get_free_pids.c | 20 ++++++++++++++++++++
3 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 testcases/lib/tst_get_free_pids.c
diff --git a/testcases/lib/.gitignore b/testcases/lib/.gitignore
index a2e9f1ef0c08..5a0e8cba2ee7 100644
--- a/testcases/lib/.gitignore
+++ b/testcases/lib/.gitignore
@@ -2,6 +2,7 @@
/tst_checkpoint
/tst_device
/tst_getconf
+/tst_get_free_pids
/tst_get_median
/tst_get_unused_port
/tst_kvcmp
diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile
index 38813e640ab1..179b474795d3 100644
--- a/testcases/lib/Makefile
+++ b/testcases/lib/Makefile
@@ -11,6 +11,6 @@ INSTALL_TARGETS := *.sh
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_median tst_hexdump tst_get_free_pids
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/tst_get_free_pids.c b/testcases/lib/tst_get_free_pids.c
new file mode 100644
index 000000000000..d7b68c620614
--- /dev/null
+++ b/testcases/lib/tst_get_free_pids.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#define TST_NO_DEFAULT_MAIN
+#include <stdio.h>
+#include <tst_test.h>
+
+extern struct tst_test *tst_test;
+
+static struct tst_test test = {
+};
+
+int main(void)
+{
+ /* force messages to be printed from new library */
+ tst_test = &test;
+
+ printf("%i\n", tst_get_free_pids());
+
+ return 0;
+}
--
2.30.2
More information about the ltp
mailing list