diff mbox series

[v2,1/3] lib: add .min_cpus in tst_test struct

Message ID 20201204063305.6820-1-liwang@redhat.com
State Accepted
Headers show
Series [v2,1/3] lib: add .min_cpus in tst_test struct | expand

Commit Message

Li Wang Dec. 4, 2020, 6:33 a.m. UTC
As the name implies, this new field is mainly to set minimum numbers
of CPU for LTP testcase. If system online CPUs are less than .min_cpus,
test will be exit with TCONF.

Note: I wouldn't add more description in test-writing-guidelines.txt,
because it is easy to understand the usage from the name.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 include/tst_test.h | 3 +++
 lib/tst_test.c     | 3 +++
 2 files changed, 6 insertions(+)

Comments

Cyril Hrubis Dec. 7, 2020, 2:41 p.m. UTC | #1
Hi!
Pushed with two fixes, thanks.

> +	/* Minimum numbers of online CPU required by the test */
                      ^
		      number
> +	unsigned long min_cpus;
> +
>  	/*
>  	 * If set non-zero number of request_hugepages, test will try to reserve the
>  	 * expected number of hugepage for testing in setup phase. If system does not
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 535c0ff4c..c4e04eb4a 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -918,6 +918,9 @@ static void do_setup(int argc, char *argv[])
>  	if (tst_test->all_filesystems)
>  		tst_test->needs_device = 1;
>  
> +	if (tst_test->min_cpus > tst_ncpus())
                                   ^
				   Added (unsigned long) cast to silence
				   warnings.
> +		tst_brk(TCONF, "Test needs at least %lu CPUs online", tst_test->min_cpus);
> +
>  	if (tst_test->request_hugepages)
>  		tst_request_hugepages(tst_test->request_hugepages);
>  
> -- 
> 2.21.3
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
diff mbox series

Patch

diff --git a/include/tst_test.h b/include/tst_test.h
index c91d3f18a..b4fc4db47 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -157,6 +157,9 @@  struct tst_test {
 	 */
 	int all_filesystems:1;
 
+	/* Minimum numbers of online CPU required by the test */
+	unsigned long min_cpus;
+
 	/*
 	 * If set non-zero number of request_hugepages, test will try to reserve the
 	 * expected number of hugepage for testing in setup phase. If system does not
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 535c0ff4c..c4e04eb4a 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -918,6 +918,9 @@  static void do_setup(int argc, char *argv[])
 	if (tst_test->all_filesystems)
 		tst_test->needs_device = 1;
 
+	if (tst_test->min_cpus > tst_ncpus())
+		tst_brk(TCONF, "Test needs at least %lu CPUs online", tst_test->min_cpus);
+
 	if (tst_test->request_hugepages)
 		tst_request_hugepages(tst_test->request_hugepages);