* [LTP] [PATCH 1/1] lib: Add ROD shell API test
@ 2022-07-27 15:16 Petr Vorel
2022-09-02 9:57 ` Richard Palethorpe
0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2022-07-27 15:16 UTC (permalink / raw)
To: ltp
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/newlib_tests/runtest.sh | 2 +-
lib/newlib_tests/shell/rod.sh | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
create mode 100755 lib/newlib_tests/shell/rod.sh
diff --git a/lib/newlib_tests/runtest.sh b/lib/newlib_tests/runtest.sh
index f136bcb88..5b75fe2c7 100755
--- a/lib/newlib_tests/runtest.sh
+++ b/lib/newlib_tests/runtest.sh
@@ -8,7 +8,7 @@ tst_fuzzy_sync03 test_zero_hugepage.sh test_kconfig.sh
test_children_cleanup.sh}"
LTP_SHELL_API_TESTS="${LTP_SHELL_API_TESTS:-shell/tst_check_driver.sh
-shell/tst_check_kconfig0[1-5].sh shell/net/*.sh}"
+shell/tst_check_kconfig0[1-5].sh shell/rod.sh shell/net/*.sh}"
cd $(dirname $0)
PATH="$PWD/../../testcases/lib/:$PATH"
diff --git a/lib/newlib_tests/shell/rod.sh b/lib/newlib_tests/shell/rod.sh
new file mode 100755
index 000000000..e05516d0b
--- /dev/null
+++ b/lib/newlib_tests/shell/rod.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
+
+TST_TESTFUNC="test"
+TST_NEEDS_TMPDIR=1
+TST_CNT=3
+
+test1()
+{
+ ROD cd /
+ EXPECT_PASS [ "$PWD" != "/" ]
+}
+
+test2()
+{
+ ROD echo foo > /nonexisting-file
+ tst_res TPASS "ROD redirecting without qoting continue on failure. NOTE: proper syntax needs to escape '>': ROD echo foo \> /nonexisting-file"
+ EXPECT_FAIL 'cat /nonexisting-file'
+}
+
+test3()
+{
+ ROD echo foo \> file
+ tst_res TPASS "ROD redirect quoting syntax works"
+ EXPECT_PASS '[ $(cat file) = foo ]'
+}
+
+. tst_test.sh
+tst_run
--
2.37.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 1/1] lib: Add ROD shell API test
2022-07-27 15:16 [LTP] [PATCH 1/1] lib: Add ROD shell API test Petr Vorel
@ 2022-09-02 9:57 ` Richard Palethorpe
2022-10-11 9:26 ` Richard Palethorpe
0 siblings, 1 reply; 3+ messages in thread
From: Richard Palethorpe @ 2022-09-02 9:57 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hello,
Petr Vorel <pvorel@suse.cz> writes:
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> lib/newlib_tests/runtest.sh | 2 +-
> lib/newlib_tests/shell/rod.sh | 30 ++++++++++++++++++++++++++++++
> 2 files changed, 31 insertions(+), 1 deletion(-)
> create mode 100755 lib/newlib_tests/shell/rod.sh
>
> diff --git a/lib/newlib_tests/runtest.sh b/lib/newlib_tests/runtest.sh
> index f136bcb88..5b75fe2c7 100755
> --- a/lib/newlib_tests/runtest.sh
> +++ b/lib/newlib_tests/runtest.sh
> @@ -8,7 +8,7 @@ tst_fuzzy_sync03 test_zero_hugepage.sh test_kconfig.sh
> test_children_cleanup.sh}"
>
> LTP_SHELL_API_TESTS="${LTP_SHELL_API_TESTS:-shell/tst_check_driver.sh
> -shell/tst_check_kconfig0[1-5].sh shell/net/*.sh}"
> +shell/tst_check_kconfig0[1-5].sh shell/rod.sh shell/net/*.sh}"
>
> cd $(dirname $0)
> PATH="$PWD/../../testcases/lib/:$PATH"
> diff --git a/lib/newlib_tests/shell/rod.sh b/lib/newlib_tests/shell/rod.sh
> new file mode 100755
> index 000000000..e05516d0b
> --- /dev/null
> +++ b/lib/newlib_tests/shell/rod.sh
> @@ -0,0 +1,30 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
> +
> +TST_TESTFUNC="test"
> +TST_NEEDS_TMPDIR=1
> +TST_CNT=3
> +
> +test1()
> +{
> + ROD cd /
> + EXPECT_PASS [ "$PWD" != "/" ]
> +}
> +
> +test2()
> +{
> + ROD echo foo > /nonexisting-file
If we are running as root then this will succeed?
I suppose we don't usually run the lib tests as root, but wouldn't it be
better to create a file and write protect it, then try redirecting to it?
> + tst_res TPASS "ROD redirecting without qoting continue on failure. NOTE: proper syntax needs to escape '>': ROD echo foo \> /nonexisting-file"
> + EXPECT_FAIL 'cat /nonexisting-file'
> +}
> +
> +test3()
> +{
> + ROD echo foo \> file
> + tst_res TPASS "ROD redirect quoting syntax works"
> + EXPECT_PASS '[ $(cat file) = foo ]'
> +}
> +
> +. tst_test.sh
> +tst_run
> --
> 2.37.1
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 1/1] lib: Add ROD shell API test
2022-09-02 9:57 ` Richard Palethorpe
@ 2022-10-11 9:26 ` Richard Palethorpe
0 siblings, 0 replies; 3+ messages in thread
From: Richard Palethorpe @ 2022-10-11 9:26 UTC (permalink / raw)
To: rpalethorpe; +Cc: ltp
Hello,
Richard Palethorpe <rpalethorpe@suse.de> writes:
> Hello,
>
> Petr Vorel <pvorel@suse.cz> writes:
>
>> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>> ---
>> lib/newlib_tests/runtest.sh | 2 +-
>> lib/newlib_tests/shell/rod.sh | 30 ++++++++++++++++++++++++++++++
>> 2 files changed, 31 insertions(+), 1 deletion(-)
>> create mode 100755 lib/newlib_tests/shell/rod.sh
>>
>> diff --git a/lib/newlib_tests/runtest.sh b/lib/newlib_tests/runtest.sh
>> index f136bcb88..5b75fe2c7 100755
>> --- a/lib/newlib_tests/runtest.sh
>> +++ b/lib/newlib_tests/runtest.sh
>> @@ -8,7 +8,7 @@ tst_fuzzy_sync03 test_zero_hugepage.sh test_kconfig.sh
>> test_children_cleanup.sh}"
>>
>> LTP_SHELL_API_TESTS="${LTP_SHELL_API_TESTS:-shell/tst_check_driver.sh
>> -shell/tst_check_kconfig0[1-5].sh shell/net/*.sh}"
>> +shell/tst_check_kconfig0[1-5].sh shell/rod.sh shell/net/*.sh}"
>>
>> cd $(dirname $0)
>> PATH="$PWD/../../testcases/lib/:$PATH"
>> diff --git a/lib/newlib_tests/shell/rod.sh b/lib/newlib_tests/shell/rod.sh
>> new file mode 100755
>> index 000000000..e05516d0b
>> --- /dev/null
>> +++ b/lib/newlib_tests/shell/rod.sh
>> @@ -0,0 +1,30 @@
>> +#!/bin/sh
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> +# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
>> +
>> +TST_TESTFUNC="test"
>> +TST_NEEDS_TMPDIR=1
>> +TST_CNT=3
>> +
>> +test1()
>> +{
>> + ROD cd /
>> + EXPECT_PASS [ "$PWD" != "/" ]
>> +}
>> +
>> +test2()
>> +{
>> + ROD echo foo > /nonexisting-file
>
> If we are running as root then this will succeed?
>
> I suppose we don't usually run the lib tests as root, but wouldn't it be
> better to create a file and write protect it, then try redirecting to
> it?
Marking as "changes requested", to remove it from the queue.
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-11 9:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 15:16 [LTP] [PATCH 1/1] lib: Add ROD shell API test Petr Vorel
2022-09-02 9:57 ` Richard Palethorpe
2022-10-11 9:26 ` Richard Palethorpe
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.