From 762ee52cfe9b1e3ab8733f711f2a2f044ede334d Mon Sep 17 00:00:00 2001 From: Cyril Hrubis Date: Mon, 4 Nov 2024 14:29:24 +0100 Subject: [PATCH] shell lib: Add example how to run C child Signed-off-by: Cyril Hrubis Reviewed-by: Petr Vorel Tested-by: Petr Vorel --- testcases/lib/run_tests.sh | 2 +- testcases/lib/tests/.gitignore | 1 + testcases/lib/tests/shell_c_child.c | 16 ++++++++++++++ testcases/lib/tests/shell_loader_c_child.sh | 24 +++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 testcases/lib/tests/shell_c_child.c create mode 100755 testcases/lib/tests/shell_loader_c_child.sh diff --git a/testcases/lib/run_tests.sh b/testcases/lib/run_tests.sh index 8ea615f968c..40d415e6c42 100755 --- a/testcases/lib/run_tests.sh +++ b/testcases/lib/run_tests.sh @@ -14,7 +14,7 @@ for i in shell_loader.sh shell_loader_all_filesystems.sh shell_loader_no_metadat shell_loader_wrong_metadata.sh shell_loader_invalid_metadata.sh\ shell_loader_supported_archs.sh shell_loader_filesystems.sh\ shell_loader_tcnt.sh shell_loader_kconfigs.sh shell_loader_tags.sh \ - shell_loader_invalid_block.sh; do + shell_loader_invalid_block.sh shell_loader_c_child.sh; do echo echo "*** Running $i ***" echo diff --git a/testcases/lib/tests/.gitignore b/testcases/lib/tests/.gitignore index da967c4d6fe..e9e163d13b7 100644 --- a/testcases/lib/tests/.gitignore +++ b/testcases/lib/tests/.gitignore @@ -4,3 +4,4 @@ shell_test03 shell_test04 shell_test05 shell_test06 +shell_c_child diff --git a/testcases/lib/tests/shell_c_child.c b/testcases/lib/tests/shell_c_child.c new file mode 100644 index 00000000000..fda5133a666 --- /dev/null +++ b/testcases/lib/tests/shell_c_child.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Shell test C child example. + */ + +#define TST_NO_DEFAULT_MAIN +#include "tst_test.h" + +int main(void) +{ + tst_reinit(); + + tst_res(TPASS, "C child works fine!"); + + return 0; +} diff --git a/testcases/lib/tests/shell_loader_c_child.sh b/testcases/lib/tests/shell_loader_c_child.sh new file mode 100755 index 00000000000..d190be6e247 --- /dev/null +++ b/testcases/lib/tests/shell_loader_c_child.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# --- +# doc +# +# [Description] +# +# This is an example how to run C child from shell. +# --- +# +# --- +# env +# { +# } +# --- + +. tst_loader.sh + +if [ -n "LTP_IPC_PATH" ]; then + tst_res TPASS "LTP_IPC_PATH=$LTP_IPC_PATH!" +fi + +tst_res TINFO "Running C child" +shell_c_child