From 1f8ac5f2a45ccbedb0904f6ac938f94ea655c49a Mon Sep 17 00:00:00 2001
From: Jamie Anderson <jamieand@amazon.com>
Date: Wed, 3 Mar 2021 22:00:57 +0000
Subject: [PATCH] Skip builder tests that require root

Signed-off-by: Jamie Anderson <jamieand@amazon.com>
---
 builder/dockerfile/internals_test.go | 5 +++++
 builder/remotecontext/tarsum_test.go | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/builder/dockerfile/internals_test.go b/builder/dockerfile/internals_test.go
index 5353167..5a68a39 100644
--- a/builder/dockerfile/internals_test.go
+++ b/builder/dockerfile/internals_test.go
@@ -5,6 +5,7 @@ import (
 	"os"
 	"runtime"
 	"testing"
+	"github.com/docker/docker/testutil"
 
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types/backend"
@@ -23,6 +24,7 @@ import (
 )
 
 func TestEmptyDockerfile(t *testing.T) {
+	testutil.RequiresRoot(t)
 	contextDir, cleanup := createTestTempDir(t, "", "builder-dockerfile-test")
 	defer cleanup()
 
@@ -32,6 +34,7 @@ func TestEmptyDockerfile(t *testing.T) {
 }
 
 func TestSymlinkDockerfile(t *testing.T) {
+	testutil.RequiresRoot(t)
 	contextDir, cleanup := createTestTempDir(t, "", "builder-dockerfile-test")
 	defer cleanup()
 
@@ -47,6 +50,7 @@ func TestSymlinkDockerfile(t *testing.T) {
 }
 
 func TestDockerfileOutsideTheBuildContext(t *testing.T) {
+	testutil.RequiresRoot(t)
 	contextDir, cleanup := createTestTempDir(t, "", "builder-dockerfile-test")
 	defer cleanup()
 
@@ -59,6 +63,7 @@ func TestDockerfileOutsideTheBuildContext(t *testing.T) {
 }
 
 func TestNonExistingDockerfile(t *testing.T) {
+	testutil.RequiresRoot(t)
 	contextDir, cleanup := createTestTempDir(t, "", "builder-dockerfile-test")
 	defer cleanup()
 
diff --git a/builder/remotecontext/tarsum_test.go b/builder/remotecontext/tarsum_test.go
index c6a417d..93643a5 100644
--- a/builder/remotecontext/tarsum_test.go
+++ b/builder/remotecontext/tarsum_test.go
@@ -5,6 +5,7 @@ import (
 	"os"
 	"path/filepath"
 	"testing"
+	"github.com/docker/docker/testutil"
 
 	"github.com/docker/docker/builder"
 	"github.com/docker/docker/pkg/archive"
@@ -23,6 +24,7 @@ func init() {
 }
 
 func TestCloseRootDirectory(t *testing.T) {
+	testutil.RequiresRoot(t)
	contextDir, err := os.MkdirTemp("", "builder-tarsum-test")
 	defer os.RemoveAll(contextDir)
 	if err != nil {
@@ -44,6 +46,7 @@ func TestCloseRootDirectory(t *testing.T) {
 }
 
 func TestHashFile(t *testing.T) {
+	testutil.RequiresRoot(t)
 	contextDir, cleanup := createTestTempDir(t, "", "builder-tarsum-test")
 	defer cleanup()
 
@@ -69,6 +72,7 @@ func TestHashFile(t *testing.T) {
 }
 
 func TestHashSubdir(t *testing.T) {
+	testutil.RequiresRoot(t)
 	contextDir, cleanup := createTestTempDir(t, "", "builder-tarsum-test")
 	defer cleanup()
 
@@ -106,6 +110,7 @@ func TestHashSubdir(t *testing.T) {
 }
 
 func TestRemoveDirectory(t *testing.T) {
+	testutil.RequiresRoot(t)
 	contextDir, cleanup := createTestTempDir(t, "", "builder-tarsum-test")
 	defer cleanup()
 
-- 
2.25.0.24.gbc7a3d4

