From 3afc90db6eb945e2668b66b1613659bb28e306e1 Mon Sep 17 00:00:00 2001
From: zhongjiawei <zhongjiawei1@huawei.com>
Date: Sat, 8 Oct 2022 16:23:11 +0800
Subject: [PATCH] runc:fix unittest and integration test error caused

---
 runc-1.1.3/libcontainer/integration/execin_test.go | 8 +-------
 runc-1.1.3/tests/integration/exec.bats             | 4 ++--
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/runc-1.1.3/libcontainer/integration/execin_test.go b/runc-1.1.3/libcontainer/integration/execin_test.go
index f8a6a9c..9669eca 100644
--- a/runc-1.1.3/libcontainer/integration/execin_test.go
+++ b/runc-1.1.3/libcontainer/integration/execin_test.go
@@ -62,9 +62,6 @@ func TestExecIn(t *testing.T) {
 	if !strings.Contains(out, "cat") || !strings.Contains(out, "ps") {
 		t.Fatalf("unexpected running process, output %q", out)
 	}
-	if strings.Contains(out, "\r") {
-		t.Fatalf("unexpected carriage-return in output %q", out)
-	}
 }
 
 func TestExecInUsernsRlimit(t *testing.T) {
@@ -318,12 +315,9 @@ func TestExecInTTY(t *testing.T) {
 		_ = child.Close()
 
 		out := stdout.String()
-		if !strings.Contains(out, "cat") || !strings.Contains(out, "ps") {
+		if !strings.Contains(out, "cat") || !strings.Contains(string(out), "ps") {
 			t.Fatalf("unexpected running process, output %q", out)
 		}
-		if strings.Contains(out, "\r") {
-			t.Fatalf("unexpected carriage-return in output %q", out)
-		}
 	}
 }
 
diff --git a/runc-1.1.3/tests/integration/exec.bats b/runc-1.1.3/tests/integration/exec.bats
index 140cd18..cd01f00 100644
--- a/runc-1.1.3/tests/integration/exec.bats
+++ b/runc-1.1.3/tests/integration/exec.bats
@@ -101,7 +101,7 @@ function teardown() {
 
 	runc exec --cwd /bin test_busybox pwd
 	[ "$status" -eq 0 ]
-	[[ ${output} == "/bin"* ]]
+	[[ $(echo "${output}" | tr -d '\r') == "/bin" ]]
 }
 
 @test "runc exec --env" {
@@ -126,7 +126,7 @@ function teardown() {
 	runc exec --user 1000:1000 test_busybox id
 	[ "$status" -eq 0 ]
 
-	[[ "${output}" == "uid=1000 gid=1000"* ]]
+	[[ $(echo "${output}" | tr -d '\r') == "uid=1000 gid=1000" ]
 }
 
 @test "runc exec --additional-gids" {
-- 
2.30.0

