From 6815aec33caedaacba3b392ee5a2e5088fdf1faa Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 21 Nov 2023 10:24:26 +0800
Subject: [PATCH 22/65] add update restart policy test

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
 CI/test_cases/container_cases/update.sh | 26 +++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/CI/test_cases/container_cases/update.sh b/CI/test_cases/container_cases/update.sh
index d379acc2..29543e7c 100755
--- a/CI/test_cases/container_cases/update.sh
+++ b/CI/test_cases/container_cases/update.sh
@@ -138,6 +138,27 @@ function do_test_t()
     return $TC_RET_T
 }
 
+function test_autoremove_restartpolicy()
+{
+    containername=test_update2
+    containerid=`isula run -itd --runtime $1 --rm --name $containername busybox`
+    fn_check_eq "$?" "0" "run failed"
+
+    isula update --restart always $containerid
+    fn_check_ne "$?" "0" "update should fail"
+
+    isula update --restart nooooooooooo $containerid
+    fn_check_ne "$?" "0" "update should fail"
+
+    isula update --restart no $containerid
+    fn_check_eq "$?" "0" "update restart policy no failed"
+
+    isula rm -f $containername
+    fn_check_eq "$?" "0" "rm failed"
+
+    return $TC_RET_T
+}
+
 function do_test_t1()
 {
     containername=test_update1
@@ -173,6 +194,11 @@ do
         let "ret=$ret + 1"
     fi
 
+    test_autoremove_restartpolicy $element
+    if [ $? -ne 0 ];then
+        let "ret=$ret + 1"
+    fi
+
     if [ -f "/sys/fs/cgroup/memory/memory.memsw.usage_in_bytes" ];then
         do_test_t1 $element
         if [ $? -ne 0 ];then
-- 
2.42.0

