All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v1 1/3] lib/tst_kconfig: Modify the return type of tst_kconfig_check function
@ 2022-01-04  6:57 Yang Xu
  2022-01-04  6:57 ` [LTP] [PATCH v1 2/3] shell: add kconfig parse api Yang Xu
  2022-01-04  6:57 ` [LTP] [PATCH v1 3/3] sysctl/sysctl02.sh: Use kconfig shell api Yang Xu
  0 siblings, 2 replies; 74+ messages in thread
From: Yang Xu @ 2022-01-04  6:57 UTC (permalink / raw)
  To: ltp

So this function can be used to detect whether the function succeeded in shell
api by its return value.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 include/tst_kconfig.h |  2 +-
 lib/tst_kconfig.c     | 21 ++++++++++++---------
 lib/tst_test.c        |  4 ++--
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h
index 1bb21fea8..050687c69 100644
--- a/include/tst_kconfig.h
+++ b/include/tst_kconfig.h
@@ -53,6 +53,6 @@ void tst_kconfig_read(struct tst_kconfig_var vars[], size_t vars_len);
  *
  * @param kconfigs NULL-terminated array of config strings needed for the testrun.
  */
-void tst_kconfig_check(const char *const kconfigs[]);
+int tst_kconfig_check(const char *const kconfigs[]);
 
 #endif	/* TST_KCONFIG_H__ */
diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
index d433b8cf6..dc7decff9 100644
--- a/lib/tst_kconfig.c
+++ b/lib/tst_kconfig.c
@@ -478,22 +478,26 @@ static void dump_vars(const struct tst_expr *expr)
 	}
 }
 
-void tst_kconfig_check(const char *const kconfigs[])
+int tst_kconfig_check(const char *const kconfigs[])
 {
 	size_t expr_cnt = array_len(kconfigs);
 	struct tst_expr *exprs[expr_cnt];
 	unsigned int i, var_cnt;
-	int abort_test = 0;
+	int ret = 0;
 
 	for (i = 0; i < expr_cnt; i++) {
 		exprs[i] = tst_bool_expr_parse(kconfigs[i]);
 
-		if (!exprs[i])
-			tst_brk(TBROK, "Invalid kconfig expression!");
+		if (!exprs[i]) {
+			tst_res(TWARN, "Invalid kconfig expression!");
+			return 1;
+		}
 	}
 
-	if (validate_vars(exprs, expr_cnt))
-		tst_brk(TBROK, "Invalid kconfig variables!");
+	if (validate_vars(exprs, expr_cnt)) {
+		tst_res(TWARN, "Invalid kconfig variables!");
+		return 1;
+	}
 
 	var_cnt = get_var_cnt(exprs, expr_cnt);
 	struct tst_kconfig_var vars[var_cnt];
@@ -506,7 +510,7 @@ void tst_kconfig_check(const char *const kconfigs[])
 		int val = tst_bool_expr_eval(exprs[i], map);
 
 		if (val != 1) {
-			abort_test = 1;
+			ret = 1;
 			tst_res(TINFO, "Constraint '%s' not satisfied!", kconfigs[i]);
 			dump_vars(exprs[i]);
 		}
@@ -519,8 +523,7 @@ void tst_kconfig_check(const char *const kconfigs[])
 			free(vars[i].val);
 	}
 
-	if (abort_test)
-		tst_brk(TCONF, "Aborting due to unsuitable kernel config, see above!");
+	return ret;
 }
 
 char tst_kconfig_get(const char *confname)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 23fc0ebf4..f0bf97743 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1016,8 +1016,8 @@ static void do_setup(int argc, char *argv[])
 	if (tst_test->tconf_msg)
 		tst_brk(TCONF, "%s", tst_test->tconf_msg);
 
-	if (tst_test->needs_kconfigs)
-		tst_kconfig_check(tst_test->needs_kconfigs);
+	if (tst_test->needs_kconfigs && tst_kconfig_check(tst_test->needs_kconfigs))
+		tst_brk(TCONF, "Aborting due to unsuitable kernel config, see above!");
 
 	assert_test_fn();
 
-- 
2.23.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2022-01-14  9:49 UTC | newest]

Thread overview: 74+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-04  6:57 [LTP] [PATCH v1 1/3] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Yang Xu
2022-01-04  6:57 ` [LTP] [PATCH v1 2/3] shell: add kconfig parse api Yang Xu
2022-01-04 11:04   ` Petr Vorel
2022-01-05  7:15     ` xuyang2018.jy
2022-01-05 14:34       ` Petr Vorel
2022-01-06  5:59         ` xuyang2018.jy
2022-01-06  8:16           ` xuyang2018.jy
2022-01-06  9:25         ` [LTP] [PATCH v2 1/4] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Yang Xu
2022-01-06  9:25           ` [LTP] [PATCH v2 2/4] lib: Introduce LTP_KCONFIG_DISABLE environment variables Yang Xu
2022-01-06  9:49             ` Petr Vorel
2022-01-06  9:52             ` Petr Vorel
2022-01-06 11:07             ` Cyril Hrubis
2022-01-06 11:50               ` Petr Vorel
2022-01-06 13:59                 ` Cyril Hrubis
2022-01-06 17:41                   ` Petr Vorel
2022-01-07  2:00                   ` xuyang2018.jy
2022-01-06  9:25           ` [LTP] [PATCH v2 3/4] shell: add kconfig parse api Yang Xu
2022-01-06 10:40             ` Petr Vorel
2022-01-06 11:19             ` Cyril Hrubis
2022-01-07  3:54               ` Li Wang
2022-01-07  4:08                 ` xuyang2018.jy
2022-01-07  7:04                   ` Li Wang
2022-01-07  8:28                     ` xuyang2018.jy
2022-01-07  8:41                       ` Li Wang
2022-01-07  9:46                         ` Cyril Hrubis
2022-01-07  9:56                           ` xuyang2018.jy
2022-01-07  9:05                       ` Petr Vorel
2022-01-07  9:22                         ` xuyang2018.jy
2022-01-07 12:07                           ` Petr Vorel
2022-01-07  7:33                 ` Petr Vorel
2022-01-06  9:25           ` [LTP] [PATCH v2 4/4] sysctl/sysctl02.sh: Use kconfig shell api Yang Xu
2022-01-06 11:20             ` Cyril Hrubis
2022-01-10  1:49               ` [LTP] [PATCH v3 1/4] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Yang Xu
2022-01-10  1:49                 ` [LTP] [PATCH v3 2/4] lib: Introduce KCONFIG_SKIP_CHECK environment variable Yang Xu
2022-01-10  8:14                   ` Li Wang
2022-01-10 12:20                   ` Cyril Hrubis
2022-01-11  1:38                     ` xuyang2018.jy
2022-01-10  1:49                 ` [LTP] [PATCH v3 3/4] shell: add kconfig parse api Yang Xu
2022-01-10  8:26                   ` Li Wang
2022-01-10  8:46                     ` xuyang2018.jy
2022-01-10  9:13                       ` Li Wang
2022-01-10 13:43                   ` Cyril Hrubis
2022-01-11  5:29                     ` xuyang2018.jy
2022-01-11  6:10                     ` [LTP] [PATCH v4 1/5] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Yang Xu
2022-01-11  6:10                       ` [LTP] [PATCH v4 2/5] lib: Introduce KCONFIG_SKIP_CHECK environment variable Yang Xu
2022-01-13 11:09                         ` Petr Vorel
2022-01-14  5:36                           ` xuyang2018.jy
2022-01-11  6:10                       ` [LTP] [PATCH v4 3/5] shell: add kconfig parse api Yang Xu
2022-01-11  7:52                         ` Li Wang
2022-01-11  8:37                           ` xuyang2018.jy
2022-01-13  9:15                             ` xuyang2018.jy
2022-01-13  9:42                               ` Li Wang
2022-01-13 15:51                             ` Cyril Hrubis
2022-01-14  6:26                               ` xuyang2018.jy
2022-01-14  9:19                                 ` xuyang2018.jy
2022-01-14  9:49                                   ` Petr Vorel
2022-01-11  6:10                       ` [LTP] [PATCH v4 4/5] sysctl/sysctl02.sh: Use kconfig shell api Yang Xu
2022-01-13 10:53                         ` Petr Vorel
2022-01-13 16:06                           ` Petr Vorel
2022-01-13 15:54                         ` Cyril Hrubis
2022-01-11  6:10                       ` [LTP] [PATCH v4 5/5] runtest.sh: add test_kconfig.sh into ltp c test target Yang Xu
2022-01-13 11:25                         ` Petr Vorel
2022-01-13 15:54                         ` Cyril Hrubis
2022-01-10  1:49                 ` [LTP] [PATCH v3 4/4] sysctl/sysctl02.sh: Use kconfig shell api Yang Xu
2022-01-10  8:30                   ` Li Wang
2022-01-10 14:15                   ` Cyril Hrubis
2022-01-11  5:34                     ` xuyang2018.jy
2022-01-10  8:10                 ` [LTP] [PATCH v3 1/4] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Li Wang
2022-01-10 12:18                 ` Cyril Hrubis
2022-01-10  5:45               ` [LTP] [PATCH v2 4/4] sysctl/sysctl02.sh: Use kconfig shell api xuyang2018.jy
2022-01-06  9:54           ` [LTP] [PATCH v2 1/4] lib/tst_kconfig: Modify the return type of tst_kconfig_check function Petr Vorel
2022-01-06 10:57           ` Cyril Hrubis
2022-01-07  1:25             ` xuyang2018.jy
2022-01-04  6:57 ` [LTP] [PATCH v1 3/3] sysctl/sysctl02.sh: Use kconfig shell api Yang Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.