public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] shell: add echo command check
@ 2024-05-28  9:56 mataotao
  0 siblings, 0 replies; 5+ messages in thread
From: mataotao @ 2024-05-28  9:56 UTC (permalink / raw)
  To: ltp; +Cc: mataotao

---
 runtest/commands                      |  1 +
 testcases/commands/echo/Makefile      | 11 +++++
 testcases/commands/echo/echo_tests.sh | 62 +++++++++++++++++++++++++++
 3 files changed, 74 insertions(+)
 create mode 100644 testcases/commands/echo/Makefile
 create mode 100644 testcases/commands/echo/echo_tests.sh

diff --git a/runtest/commands b/runtest/commands
index 5ec2c3b69..570b81262 100644
--- a/runtest/commands
+++ b/runtest/commands
@@ -12,6 +12,7 @@ gzip01_sh gzip_tests.sh
 cp01_sh cp_tests.sh
 ln01_sh ln_tests.sh
 mkdir01_sh mkdir_tests.sh
+echo_tests_sh echo_tests.sh
 mv01_sh mv_tests.sh
 du01_sh du01.sh
 df01_sh df01.sh
diff --git a/testcases/commands/echo/Makefile b/testcases/commands/echo/Makefile
new file mode 100644
index 000000000..20fbab421
--- /dev/null
+++ b/testcases/commands/echo/Makefile
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2024 UnionTech Ltd.
+# Author: Taotao Ma <mataotao@uniontech.com>
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+INSTALL_TARGETS		:= echo_tests.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/echo/echo_tests.sh b/testcases/commands/echo/echo_tests.sh
new file mode 100644
index 000000000..0223cbf5b
--- /dev/null
+++ b/testcases/commands/echo/echo_tests.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) Linux Test Project, 2024
+# Copyright (c) 2024 UnionTech Ltd.
+# Author: Taotao Ma <mataotao@uniontech.com>
+#
+# Test basic functionality of lsmod command.
+
+TST_CNT=4
+TST_TESTFUNC=do_test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="echo"
+. tst_test.sh
+
+echo_test()
+{
+    local echo_opt=$1
+    local echo_content=$2
+
+    local echo_cmd="echo $echo_opt $echo_content"
+
+    $echo_cmd > temp 2>&1
+    if [ $? -ne 0 ]; then
+        grep -q -E "unknown option|invalid option" temp
+        if [ $? -eq 0 ]; then
+            tst_res TCONF "$echo_cmd not supported."
+        else
+            tst_res TFAIL "$echo_cmd failed."
+        fi
+        return
+    fi
+
+    line=$(wc -l temp | awk '{print $1}')
+
+    if [ -z "$echo_opt" ];then
+        if [ "$line" -ne 1 ];then
+            tst_res TFAIL "$echo_cmd failed."
+            return
+        fi
+    else
+        if [ "$echo_opt" = "-e" ];then
+            if [ "$line" -ne 2 ];then
+                tst_res TFAIL "$echo_cmd failed."
+                return
+            fi
+        fi
+    fi
+
+    tst_res TPASS "echo passed with $echo_opt option."
+}
+
+do_test()
+{
+    case $1 in
+        1) echo_test "" "hello\nworld";;
+        2) echo_test "-e" "hello\nworld";;
+        3) echo_test "--help";;
+        4) echo_test "--version";;
+    esac
+}
+
+tst_run
\ No newline at end of file
-- 
2.20.1


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

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

* [LTP] [PATCH] shell: add echo command check
@ 2024-05-28 10:13 mataotao
  0 siblings, 0 replies; 5+ messages in thread
From: mataotao @ 2024-05-28 10:13 UTC (permalink / raw)
  To: ltp; +Cc: mataotao

---
 runtest/commands                      |  1 +
 testcases/commands/echo/Makefile      | 11 +++++
 testcases/commands/echo/echo_tests.sh | 62 +++++++++++++++++++++++++++
 3 files changed, 74 insertions(+)
 create mode 100644 testcases/commands/echo/Makefile
 create mode 100644 testcases/commands/echo/echo_tests.sh

diff --git a/runtest/commands b/runtest/commands
index 5ec2c3b69..570b81262 100644
--- a/runtest/commands
+++ b/runtest/commands
@@ -12,6 +12,7 @@ gzip01_sh gzip_tests.sh
 cp01_sh cp_tests.sh
 ln01_sh ln_tests.sh
 mkdir01_sh mkdir_tests.sh
+echo_tests_sh echo_tests.sh
 mv01_sh mv_tests.sh
 du01_sh du01.sh
 df01_sh df01.sh
diff --git a/testcases/commands/echo/Makefile b/testcases/commands/echo/Makefile
new file mode 100644
index 000000000..20fbab421
--- /dev/null
+++ b/testcases/commands/echo/Makefile
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2024 UnionTech Ltd.
+# Author: Taotao Ma <mataotao@uniontech.com>
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+INSTALL_TARGETS		:= echo_tests.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/echo/echo_tests.sh b/testcases/commands/echo/echo_tests.sh
new file mode 100644
index 000000000..0223cbf5b
--- /dev/null
+++ b/testcases/commands/echo/echo_tests.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) Linux Test Project, 2024
+# Copyright (c) 2024 UnionTech Ltd.
+# Author: Taotao Ma <mataotao@uniontech.com>
+#
+# Test basic functionality of lsmod command.
+
+TST_CNT=4
+TST_TESTFUNC=do_test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="echo"
+. tst_test.sh
+
+echo_test()
+{
+    local echo_opt=$1
+    local echo_content=$2
+
+    local echo_cmd="echo $echo_opt $echo_content"
+
+    $echo_cmd > temp 2>&1
+    if [ $? -ne 0 ]; then
+        grep -q -E "unknown option|invalid option" temp
+        if [ $? -eq 0 ]; then
+            tst_res TCONF "$echo_cmd not supported."
+        else
+            tst_res TFAIL "$echo_cmd failed."
+        fi
+        return
+    fi
+
+    line=$(wc -l temp | awk '{print $1}')
+
+    if [ -z "$echo_opt" ];then
+        if [ "$line" -ne 1 ];then
+            tst_res TFAIL "$echo_cmd failed."
+            return
+        fi
+    else
+        if [ "$echo_opt" = "-e" ];then
+            if [ "$line" -ne 2 ];then
+                tst_res TFAIL "$echo_cmd failed."
+                return
+            fi
+        fi
+    fi
+
+    tst_res TPASS "echo passed with $echo_opt option."
+}
+
+do_test()
+{
+    case $1 in
+        1) echo_test "" "hello\nworld";;
+        2) echo_test "-e" "hello\nworld";;
+        3) echo_test "--help";;
+        4) echo_test "--version";;
+    esac
+}
+
+tst_run
\ No newline at end of file
-- 
2.20.1


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

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

* [LTP] [PATCH] shell: add echo command check
@ 2024-06-24  7:17 mataotao
  2024-06-24  7:54 ` Li Wang
  0 siblings, 1 reply; 5+ messages in thread
From: mataotao @ 2024-06-24  7:17 UTC (permalink / raw)
  To: ltp; +Cc: mataotao

Signed-off-by: mataotao <mataotao@uniontech.com>
---
 runtest/commands                      |  1 +
 testcases/commands/echo/Makefile      | 11 +++++
 testcases/commands/echo/echo_tests.sh | 62 +++++++++++++++++++++++++++
 3 files changed, 74 insertions(+)
 create mode 100644 testcases/commands/echo/Makefile
 create mode 100644 testcases/commands/echo/echo_tests.sh

diff --git a/runtest/commands b/runtest/commands
index 5ec2c3b69..570b81262 100644
--- a/runtest/commands
+++ b/runtest/commands
@@ -12,6 +12,7 @@ gzip01_sh gzip_tests.sh
 cp01_sh cp_tests.sh
 ln01_sh ln_tests.sh
 mkdir01_sh mkdir_tests.sh
+echo_tests_sh echo_tests.sh
 mv01_sh mv_tests.sh
 du01_sh du01.sh
 df01_sh df01.sh
diff --git a/testcases/commands/echo/Makefile b/testcases/commands/echo/Makefile
new file mode 100644
index 000000000..20fbab421
--- /dev/null
+++ b/testcases/commands/echo/Makefile
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2024 UnionTech Ltd.
+# Author: Taotao Ma <mataotao@uniontech.com>
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+INSTALL_TARGETS		:= echo_tests.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/echo/echo_tests.sh b/testcases/commands/echo/echo_tests.sh
new file mode 100644
index 000000000..0223cbf5b
--- /dev/null
+++ b/testcases/commands/echo/echo_tests.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) Linux Test Project, 2024
+# Copyright (c) 2024 UnionTech Ltd.
+# Author: Taotao Ma <mataotao@uniontech.com>
+#
+# Test basic functionality of lsmod command.
+
+TST_CNT=4
+TST_TESTFUNC=do_test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="echo"
+. tst_test.sh
+
+echo_test()
+{
+    local echo_opt=$1
+    local echo_content=$2
+
+    local echo_cmd="echo $echo_opt $echo_content"
+
+    $echo_cmd > temp 2>&1
+    if [ $? -ne 0 ]; then
+        grep -q -E "unknown option|invalid option" temp
+        if [ $? -eq 0 ]; then
+            tst_res TCONF "$echo_cmd not supported."
+        else
+            tst_res TFAIL "$echo_cmd failed."
+        fi
+        return
+    fi
+
+    line=$(wc -l temp | awk '{print $1}')
+
+    if [ -z "$echo_opt" ];then
+        if [ "$line" -ne 1 ];then
+            tst_res TFAIL "$echo_cmd failed."
+            return
+        fi
+    else
+        if [ "$echo_opt" = "-e" ];then
+            if [ "$line" -ne 2 ];then
+                tst_res TFAIL "$echo_cmd failed."
+                return
+            fi
+        fi
+    fi
+
+    tst_res TPASS "echo passed with $echo_opt option."
+}
+
+do_test()
+{
+    case $1 in
+        1) echo_test "" "hello\nworld";;
+        2) echo_test "-e" "hello\nworld";;
+        3) echo_test "--help";;
+        4) echo_test "--version";;
+    esac
+}
+
+tst_run
\ No newline at end of file
-- 
2.20.1


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

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

* Re: [LTP] [PATCH] shell: add echo command check
  2024-06-24  7:17 [LTP] [PATCH] shell: add echo command check mataotao
@ 2024-06-24  7:54 ` Li Wang
  2024-07-10 15:32   ` Petr Vorel
  0 siblings, 1 reply; 5+ messages in thread
From: Li Wang @ 2024-06-24  7:54 UTC (permalink / raw)
  To: mataotao; +Cc: ltp

Hi Mataotao,

First, thank you for creating new tests for LTP.

But from what I know LTP now is mainly a face-to-Linux Kernel side test
suite,
rather than the userspace or command line test (it had some but slowly being
removed from the test suite).

'echo' is daily popular used but belongs to the coreutils package, it's not
the core
of kernel part. I guess maintainers have no passion for reviewing patch
like this:(.


-- 
Regards,
Li Wang

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

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

* Re: [LTP] [PATCH] shell: add echo command check
  2024-06-24  7:54 ` Li Wang
@ 2024-07-10 15:32   ` Petr Vorel
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2024-07-10 15:32 UTC (permalink / raw)
  To: Li Wang; +Cc: mataotao, ltp

Hi Mataotao,

> Hi Mataotao,

> First, thank you for creating new tests for LTP.

Thank you!

> But from what I know LTP now is mainly a face-to-Linux Kernel side test
> suite,
> rather than the userspace or command line test (it had some but slowly being
> removed from the test suite).

+1, these would be better placed in coreutils or the shell project you target.

> 'echo' is daily popular used but belongs to the coreutils package, it's not
> the core
Also, 'echo' is not only binary from coreutils, but also a shell builtin.
Moreover, 'echo' is known for various incompatibility across implementations
(printf is suggested to be used if compatibility is needed).

Kind regards,
Petr

> of kernel part. I guess maintainers have no passion for reviewing patch
> like this:(.

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

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

end of thread, other threads:[~2024-07-10 15:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-24  7:17 [LTP] [PATCH] shell: add echo command check mataotao
2024-06-24  7:54 ` Li Wang
2024-07-10 15:32   ` Petr Vorel
  -- strict thread matches above, loose matches on Subject: below --
2024-05-28 10:13 mataotao
2024-05-28  9:56 mataotao

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