unix: Change to use new generic VFS sub-system in coverage build.
This patch includes a new module "uos_vfs" which can be used for testing the VFS syb-system.
This commit is contained in:
parent
6c23c7587f
commit
f1e04148a1
|
@ -143,6 +143,7 @@ SRC_C = \
|
|||
file.c \
|
||||
modmachine.c \
|
||||
modos.c \
|
||||
moduos_vfs.c \
|
||||
modtime.c \
|
||||
moduselect.c \
|
||||
alloc.c \
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Damien P. George
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extmod/vfs.h"
|
||||
#include "extmod/vfs_fat.h"
|
||||
|
||||
#if MICROPY_VFS
|
||||
|
||||
STATIC const mp_rom_map_elem_t uos_vfs_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos_vfs) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_sep), MP_ROM_QSTR(MP_QSTR__slash_) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&mp_vfs_mount_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&mp_vfs_umount_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vfs_open), MP_ROM_PTR(&mp_vfs_open_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&mp_vfs_chdir_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&mp_vfs_getcwd_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&mp_vfs_listdir_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&mp_vfs_mkdir_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&mp_vfs_remove_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_rename),MP_ROM_PTR(&mp_vfs_rename_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&mp_vfs_rmdir_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&mp_vfs_stat_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&mp_vfs_statvfs_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_unlink), MP_ROM_PTR(&mp_vfs_remove_obj) }, // unlink aliases to remove
|
||||
|
||||
#if MICROPY_VFS_FAT
|
||||
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
|
||||
#endif
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(uos_vfs_module_globals, uos_vfs_module_globals_table);
|
||||
|
||||
const mp_obj_module_t mp_module_uos_vfs = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&uos_vfs_module_globals,
|
||||
};
|
||||
|
||||
#endif // MICROPY_VFS
|
|
@ -164,6 +164,7 @@
|
|||
|
||||
extern const struct _mp_obj_module_t mp_module_machine;
|
||||
extern const struct _mp_obj_module_t mp_module_os;
|
||||
extern const struct _mp_obj_module_t mp_module_uos_vfs;
|
||||
extern const struct _mp_obj_module_t mp_module_uselect;
|
||||
extern const struct _mp_obj_module_t mp_module_time;
|
||||
extern const struct _mp_obj_module_t mp_module_termios;
|
||||
|
@ -171,6 +172,11 @@ extern const struct _mp_obj_module_t mp_module_socket;
|
|||
extern const struct _mp_obj_module_t mp_module_ffi;
|
||||
extern const struct _mp_obj_module_t mp_module_jni;
|
||||
|
||||
#if MICROPY_PY_UOS_VFS
|
||||
#define MICROPY_PY_UOS_VFS_DEF { MP_ROM_QSTR(MP_QSTR_uos_vfs), MP_ROM_PTR(&mp_module_uos_vfs) },
|
||||
#else
|
||||
#define MICROPY_PY_UOS_VFS_DEF
|
||||
#endif
|
||||
#if MICROPY_PY_FFI
|
||||
#define MICROPY_PY_FFI_DEF { MP_ROM_QSTR(MP_QSTR_ffi), MP_ROM_PTR(&mp_module_ffi) },
|
||||
#else
|
||||
|
@ -209,6 +215,7 @@ extern const struct _mp_obj_module_t mp_module_jni;
|
|||
MICROPY_PY_SOCKET_DEF \
|
||||
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&mp_module_machine) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_os) }, \
|
||||
MICROPY_PY_UOS_VFS_DEF \
|
||||
MICROPY_PY_USELECT_DEF \
|
||||
MICROPY_PY_TERMIOS_DEF \
|
||||
|
||||
|
|
|
@ -27,14 +27,15 @@
|
|||
// Default unix config while intended to be comprehensive, may still not enable
|
||||
// all the features, this config should enable more (testable) options.
|
||||
|
||||
#define MICROPY_VFS (1)
|
||||
#define MICROPY_PY_UOS_VFS (1)
|
||||
|
||||
#include <mpconfigport.h>
|
||||
|
||||
#define MICROPY_PY_BUILTINS_HELP (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
|
||||
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
|
||||
#define MICROPY_PY_IO_BUFFEREDWRITER (1)
|
||||
#undef MICROPY_FSUSERMOUNT
|
||||
#undef MICROPY_VFS_FAT
|
||||
#define MICROPY_FSUSERMOUNT (1)
|
||||
#define MICROPY_VFS_FAT (1)
|
||||
#define MICROPY_PY_FRAMEBUF (1)
|
||||
|
|
Loading…
Reference in New Issue