From a3d7fc99204f65e63b1686c5e78714627805e239 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Thu, 1 Jun 2023 16:40:23 +0800
Subject: [PATCH 15/15] add some exec test

Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
 CI/test_cases/container_cases/exec.sh      | 12 ++++++++++++
 CI/test_cases/container_cases/exec_runc.sh |  9 +++++++++
 2 files changed, 21 insertions(+)

diff --git a/CI/test_cases/container_cases/exec.sh b/CI/test_cases/container_cases/exec.sh
index 50a262b6..96ceb884 100755
--- a/CI/test_cases/container_cases/exec.sh
+++ b/CI/test_cases/container_cases/exec.sh
@@ -36,6 +36,18 @@ function exec_workdir()
     isula exec -ti --workdir /workdir cont_workdir pwd | grep "/workdir"
     [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - workdir is not /workdir failed" && ((ret++))
 
+    isula exec -ti cont_workdir sh -c "echo $HOME | grep '/root'"
+    [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - HOME env is not /root failed" && ((ret++))
+
+    isula exec -ti cont_workdir /bin/sh -c 'exit 1'
+    [[ $? -ne 1 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - exit code should be 1" && ((ret++))
+
+    isula exec -ti cont_workdir /bin/sh -c 'exit 2'
+    [[ $? -ne 2 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - exit code should be 2" && ((ret++))
+
+    isula exec -tid cont_workdir /bin/sh -c 'exit 2'
+    [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - exit code should be 0" && ((ret++))
+
     isula rm -f `isula ps -a -q`
 
     return ${ret}
diff --git a/CI/test_cases/container_cases/exec_runc.sh b/CI/test_cases/container_cases/exec_runc.sh
index ab394735..f963724e 100755
--- a/CI/test_cases/container_cases/exec_runc.sh
+++ b/CI/test_cases/container_cases/exec_runc.sh
@@ -44,6 +44,15 @@ function exec_runc_test()
     isula exec -it $container_name date
     [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to exec date" && ((ret++))
 
+    isula exec -ti $container_name /bin/sh -c 'exit 1'
+    [[ $? -ne 1 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - exit code should be 1" && ((ret++))
+
+    isula exec -ti $container_name /bin/sh -c 'exit 2'
+    [[ $? -ne 2 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - exit code should be 2" && ((ret++))
+
+    isula exec -tid $container_name /bin/sh -c 'exit 2'
+    [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - exit code should be 0" && ((ret++))
+
     ls /var/run/isulad/runc/${ID}/exec/
     ls /var/run/isulad/runc/${ID}/exec/ | wc -l | grep 0
     [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - residual dir after success exec" && ((ret++))
-- 
2.25.1

