summaryrefslogtreecommitdiff
path: root/0116-fix-bug-in-ci-test.patch
blob: 181fbc7f2a95a796139062c947f140cdc47bf441 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From c7cf33c432b3d9479b2fe365169d4b9a37cae8f7 Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Tue, 9 Jul 2024 12:30:01 +0000
Subject: [PATCH 116/121] fix bug in ci test

Signed-off-by: jikai <jikai11@huawei.com>
---
 CI/test_cases/container_cases/run.sh | 6 +++---
 CI/test_cases/helpers.sh             | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/CI/test_cases/container_cases/run.sh b/CI/test_cases/container_cases/run.sh
index 1bfd388b..ef04b547 100755
--- a/CI/test_cases/container_cases/run.sh
+++ b/CI/test_cases/container_cases/run.sh
@@ -26,9 +26,9 @@ source ../helpers.sh
 function do_test_t()
 {
     tid=`isula run --runtime $1 -tid --name hostname busybox`
-    chostname=`isula exec -it $tid hostname`
-    clean_hostname=$(echo "$hostname" | sed 's/[\x01-\x1F\x7F]//g')
-    fn_check_eq "${clean_hostname}" "${tid:0:12}" "default hostname is not id of container"
+    # should not use -it option, otherwise the hostname will containe special characters such as '$' or '\r'
+    hostname=`isula exec $tid hostname`
+    fn_check_eq "${hostname}" "${tid:0:12}" "default hostname is not id of container"
     isula exec -it hostname env | grep HOSTNAME
     fn_check_eq "$?" "0" "check HOSTNAME env failed"
     isula stop -t 0 $tid
diff --git a/CI/test_cases/helpers.sh b/CI/test_cases/helpers.sh
index c5eba8a2..0288b4ea 100755
--- a/CI/test_cases/helpers.sh
+++ b/CI/test_cases/helpers.sh
@@ -52,15 +52,16 @@ function cut_output_lines() {
     return $retval
 }
 
+# use string compare to check the result
 function fn_check_eq() {
-    if [[ "$1" -ne "$2" ]];then
+    if [ "x$1" != "x$2" ];then
         echo "$3"
         TC_RET_T=$(($TC_RET_T+1))
     fi
 }
 
 function fn_check_ne() {
-    if [[ "$1" -eq "$2" ]];then
+    if [[ "x$1" == "x$2" ]];then
         echo "$3"
         TC_RET_T=$(($TC_RET_T+1))
     fi
-- 
2.25.1