public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v5 1/3] lib: add tst_get_free_pids helper program
@ 2021-09-01 15:16 Krzysztof Kozlowski
  2021-09-01 15:16 ` [LTP] [PATCH v5 2/3] controllers/cpuacct: skip cpuacct_100_100 on small memory systems Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2021-09-01 15:16 UTC (permalink / raw)
  To: ltp

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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-09-02 16:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-01 15:16 [LTP] [PATCH v5 1/3] lib: add tst_get_free_pids helper program Krzysztof Kozlowski
2021-09-01 15:16 ` [LTP] [PATCH v5 2/3] controllers/cpuacct: skip cpuacct_100_100 on small memory systems Krzysztof Kozlowski
2021-09-01 18:14   ` Cyril Hrubis
2021-09-01 18:38     ` Petr Vorel
2021-09-02  8:06       ` Krzysztof Kozlowski
2021-09-02 12:02       ` Cyril Hrubis
2021-09-01 15:16 ` [LTP] [PATCH v5 3/3] controllers/cpuacct: fix rmdir failures on early test abort Krzysztof Kozlowski
2021-09-02  8:18   ` Petr Vorel
2021-09-02  8:24     ` Krzysztof Kozlowski
2021-09-02 16:00       ` Petr Vorel
2021-09-01 18:26 ` [LTP] [PATCH v5 1/3] lib: add tst_get_free_pids helper program Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox