@@ -85,19 +85,19 @@ func (c actionTests) actionExec(t *testing.T) {
85
85
user := e2e .CurrentUser (t )
86
86
87
87
// Create a temp testfile
88
- testdata , err := fs .MakeTmpDir (c .env .TestDir , "testdata" , 0755 )
88
+ testdata , err := fs .MakeTmpDir (c .env .TestDir , "testdata" , 0o755 )
89
89
if err != nil {
90
90
t .Fatal (err )
91
91
}
92
92
defer os .RemoveAll (testdata )
93
93
94
94
testdataTmp := filepath .Join (testdata , "tmp" )
95
- if err := os .Mkdir (testdataTmp , 0755 ); err != nil {
95
+ if err := os .Mkdir (testdataTmp , 0o755 ); err != nil {
96
96
t .Fatal (err )
97
97
}
98
98
99
99
// Create a temp testfile
100
- tmpfile , err := fs .MakeTmpFile (testdataTmp , "testSingularityExec." , 0644 )
100
+ tmpfile , err := fs .MakeTmpFile (testdataTmp , "testSingularityExec." , 0o644 )
101
101
if err != nil {
102
102
t .Fatal (err )
103
103
}
@@ -1085,19 +1085,19 @@ func (c actionTests) actionBinds(t *testing.T) {
1085
1085
}
1086
1086
})(t )
1087
1087
1088
- if err := fs .Mkdir (hostCanaryDir , 0777 ); err != nil {
1088
+ if err := fs .Mkdir (hostCanaryDir , 0o777 ); err != nil {
1089
1089
t .Fatalf ("failed to create canary_dir: %s" , err )
1090
1090
}
1091
1091
if err := fs .Touch (hostCanaryFile ); err != nil {
1092
1092
t .Fatalf ("failed to create canary_file: %s" , err )
1093
1093
}
1094
- if err := os .Chmod (hostCanaryFile , 0777 ); err != nil {
1094
+ if err := os .Chmod (hostCanaryFile , 0o777 ); err != nil {
1095
1095
t .Fatalf ("failed to apply permissions on canary_file: %s" , err )
1096
1096
}
1097
- if err := fs .Mkdir (hostHomeDir , 0777 ); err != nil {
1097
+ if err := fs .Mkdir (hostHomeDir , 0o777 ); err != nil {
1098
1098
t .Fatalf ("failed to create workspace home directory: %s" , err )
1099
1099
}
1100
- if err := fs .Mkdir (hostWorkDir , 0777 ); err != nil {
1100
+ if err := fs .Mkdir (hostWorkDir , 0o777 ); err != nil {
1101
1101
t .Fatalf ("failed to create workspace work directory: %s" , err )
1102
1102
}
1103
1103
}
@@ -1562,7 +1562,7 @@ func (c actionTests) fuseMount(t *testing.T) {
1562
1562
t .Errorf ("could not read ssh private key: %s" , err )
1563
1563
return
1564
1564
}
1565
- if err := ioutil .WriteFile (userPrivKey , content , 0600 ); err != nil {
1565
+ if err := ioutil .WriteFile (userPrivKey , content , 0o600 ); err != nil {
1566
1566
t .Errorf ("could not write ssh user private key: %s" , err )
1567
1567
return
1568
1568
}
@@ -1768,7 +1768,7 @@ func (c actionTests) bindImage(t *testing.T) {
1768
1768
if err != nil {
1769
1769
t .Fatal (err )
1770
1770
}
1771
- if err := os .Chmod (squashDir , 0755 ); err != nil {
1771
+ if err := os .Chmod (squashDir , 0o755 ); err != nil {
1772
1772
t .Fatal (err )
1773
1773
}
1774
1774
@@ -2073,7 +2073,6 @@ func (c actionTests) actionUmask(t *testing.T) {
2073
2073
e2e .ExpectOutput (e2e .ExactMatch , "0022" ),
2074
2074
),
2075
2075
)
2076
-
2077
2076
}
2078
2077
2079
2078
func (c actionTests ) actionNoMount (t * testing.T ) {
@@ -2192,6 +2191,62 @@ func (c actionTests) actionNoMount(t *testing.T) {
2192
2191
}
2193
2192
}
2194
2193
2194
+ // actionCompat checks that the --compat flag sets up the expected environment
2195
+ // for improved oci/docker compatibility
2196
+ func (c actionTests ) actionCompat (t * testing.T ) {
2197
+ e2e .EnsureImage (t , c .env )
2198
+
2199
+ type test struct {
2200
+ name string
2201
+ args []string
2202
+ exitCode int
2203
+ expect e2e.SingularityCmdResultOp
2204
+ }
2205
+
2206
+ tests := []test {
2207
+ {
2208
+ name : "containall" ,
2209
+ args : []string {"compat" , c .env .ImagePath , "sh" , "-c" , "ls -lah $HOME" },
2210
+ exitCode : 0 ,
2211
+ expect : e2e .ExpectOutput (e2e .ContainMatch , "total 0" ),
2212
+ },
2213
+ {
2214
+ name : "writable-tmpfs" ,
2215
+ args : []string {"compat" , c .env .ImagePath , "sh" , "-c" , "touch /test" },
2216
+ exitCode : 0 ,
2217
+ },
2218
+ {
2219
+ name : "no-init" ,
2220
+ args : []string {"compat" , c .env .ImagePath , "sh" , "-c" , "ps" },
2221
+ exitCode : 0 ,
2222
+ expect : e2e .ExpectOutput (e2e .UnwantedContainMatch , "sinit" ),
2223
+ },
2224
+ {
2225
+ name : "no-umask" ,
2226
+ args : []string {"compat" , c .env .ImagePath , "sh" , "-c" , "umask" },
2227
+ exitCode : 0 ,
2228
+ expect : e2e .ExpectOutput (e2e .ContainMatch , "0022" ),
2229
+ },
2230
+ }
2231
+
2232
+ oldUmask := syscall .Umask (0 )
2233
+ defer syscall .Umask (oldUmask )
2234
+
2235
+ for _ , tt := range tests {
2236
+ c .env .RunSingularity (
2237
+ t ,
2238
+ e2e .AsSubtest (tt .name ),
2239
+ e2e .WithProfile (e2e .UserProfile ),
2240
+ e2e .WithCommand ("exec" ),
2241
+ e2e .WithArgs (tt .args ... ),
2242
+ e2e .ExpectExit (
2243
+ tt .exitCode ,
2244
+ tt .expect ,
2245
+ ),
2246
+ )
2247
+ }
2248
+ }
2249
+
2195
2250
// E2ETests is the main func to trigger the test suite
2196
2251
func E2ETests (env e2e.TestEnv ) testhelper.Tests {
2197
2252
c := actionTests {
@@ -2232,6 +2287,7 @@ func E2ETests(env e2e.TestEnv) testhelper.Tests {
2232
2287
"bind image" : c .bindImage , // test bind image
2233
2288
"umask" : c .actionUmask , // test umask propagation
2234
2289
"no-mount" : c .actionNoMount , // test --no-mount
2290
+ "compat" : c .actionCompat , // test --compat
2235
2291
"invalidRemote" : np (c .invalidRemote ), // GHSA-5mv9-q7fq-9394
2236
2292
}
2237
2293
}
0 commit comments