1 // Copyright 2016 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #pragma once 6 7 #include <dirent.h> 8 #include <errno.h> 9 #include <stdint.h> 10 #include <stdio.h> 11 #include <string.h> 12 #include <sys/types.h> 13 14 #include <zircon/compiler.h> 15 16 // Filesystem test utilities 17 18 __BEGIN_CDECLS; 19 20 #define ASSERT_STREAM_ALL(op, fd, buf, len) \ 21 ASSERT_EQ(op(fd, (buf), (len)), (ssize_t)(len), ""); 22 23 typedef struct expected_dirent { 24 bool seen; // Should be set to "false", used internally by checking function. 25 const char* d_name; 26 unsigned char d_type; 27 } expected_dirent_t; 28 29 bool fcheck_dir_contents(DIR* dir, expected_dirent_t* edirents, size_t len); 30 bool check_dir_contents(const char* dirname, expected_dirent_t* edirents, size_t len); 31 32 // Check the contents of a file are what we expect 33 bool check_file_contents(int fd, const uint8_t* buf, size_t length); 34 35 // Unmount and remount our filesystem, simulating a reboot 36 bool check_remount(void); 37 38 __END_CDECLS; 39