25
25
#include " absl/status/status.h"
26
26
#include " absl/strings/match.h"
27
27
#include " absl/strings/str_cat.h"
28
+ #include " absl/strings/string_view.h"
28
29
#include " sandboxed_api/testing.h"
29
30
#include " sandboxed_api/util/path.h"
30
31
#include " sandboxed_api/util/status_matchers.h"
@@ -183,7 +184,7 @@ TEST(MountTreeTest, TestMultipleInsertion) {
183
184
184
185
TEST (MountTreeTest, TestEvilNullByte) {
185
186
Mounts mounts;
186
- // create the filename with a null byte this way as g4 fix forces newlines
187
+ // Create the filename with a null byte this way as g4 fix forces newlines
187
188
// otherwise.
188
189
std::string filename = " /a/b" ;
189
190
filename[2 ] = ' \0 ' ;
@@ -214,20 +215,18 @@ TEST(MountTreeTest, TestMinimalDynamicBinary) {
214
215
215
216
TEST (MountTreeTest, TestList) {
216
217
struct TestCase {
217
- const char * path;
218
- const bool is_ro;
218
+ absl::string_view path;
219
+ bool is_ro;
219
220
};
220
- // clang-format off
221
221
constexpr TestCase kTestCases [] = {
222
222
// NOTE: Directories have a trailing '/'; files don't.
223
- {" /a/b" , true },
224
- {" /a/c/" , true },
225
- {" /a/c/d/e/f/g" , true },
226
- {" /h" , true },
227
- {" /i/j/k" , false },
228
- {" /i/l/" , false },
223
+ {" /a/b" , true }, // File
224
+ {" /a/c/" , true }, // Directory
225
+ {" /a/c/d/e/f/g" , true }, // File
226
+ {" /h" , true }, // File
227
+ {" /i/j/k" , false }, // File
228
+ {" /i/l/" , false }, // Directory
229
229
};
230
- // clang-format on
231
230
232
231
Mounts mounts;
233
232
@@ -254,30 +253,24 @@ TEST(MountTreeTest, TestList) {
254
253
std::vector<std::string> inside_entries;
255
254
mounts.RecursivelyListMounts (&outside_entries, &inside_entries);
256
255
257
- // clang-format off
258
- EXPECT_THAT (
259
- inside_entries,
260
- UnorderedElementsAreArray ({
261
- " R /a/b" ,
262
- " R /a/c/" ,
263
- " R /a/c/d/e/f/g" ,
264
- " R /h" ,
265
- " W /i/j/k" ,
266
- " W /i/l/" ,
267
- " /d" ,
268
- }));
269
- EXPECT_THAT (
270
- outside_entries,
271
- UnorderedElementsAreArray ({
272
- absl::StrCat (" /some/dir/" , " a/b" ),
273
- absl::StrCat (" /some/dir/" , " a/c/" ),
274
- absl::StrCat (" /some/dir/" , " a/c/d/e/f/g" ),
275
- absl::StrCat (" /some/dir/" , " h" ),
276
- absl::StrCat (" /some/dir/" , " i/j/k" ),
277
- absl::StrCat (" /some/dir/" , " i/l/" ),
278
- absl::StrCat (" tmpfs: size=" , 1024 *1024 ),
279
- }));
280
- // clang-format on
256
+ EXPECT_THAT (inside_entries, UnorderedElementsAreArray ({
257
+ " R /a/b" ,
258
+ " R /a/c/" ,
259
+ " R /a/c/d/e/f/g" ,
260
+ " R /h" ,
261
+ " W /i/j/k" ,
262
+ " W /i/l/" ,
263
+ " /d" ,
264
+ }));
265
+ EXPECT_THAT (outside_entries, UnorderedElementsAreArray ({
266
+ absl::StrCat (" /some/dir/" , " a/b" ),
267
+ absl::StrCat (" /some/dir/" , " a/c/" ),
268
+ absl::StrCat (" /some/dir/" , " a/c/d/e/f/g" ),
269
+ absl::StrCat (" /some/dir/" , " h" ),
270
+ absl::StrCat (" /some/dir/" , " i/j/k" ),
271
+ absl::StrCat (" /some/dir/" , " i/l/" ),
272
+ absl::StrCat (" tmpfs: size=" , 1024 * 1024 ),
273
+ }));
281
274
}
282
275
283
276
TEST (MountTreeTest, TestIsWritable) {
0 commit comments