Skip to content
  • Loic Dachary's avatar
    a62d5198
    Unit tests for chain_xattr.cc · a62d5198
    Loic Dachary authored
    Create a new test file covering most (> 97%) of src/os/chain_xattr.{cc,h}
    lines of code. The following functions are tested:
    
    int chain_getxattr(const char *fn, const char *name, void *val, size_t size);
    int chain_fgetxattr(int fd, const char *name, void *val, size_t size);
    int chain_setxattr(const char *fn, const char *name, const void *val, size_t size);
    int chain_fsetxattr(int fd, const char *name, const void *val, size_t size);
    int chain_listxattr(const char *fn, char *names, size_t len);
    int chain_flistxattr(int fd, char *names, size_t len);
    int chain_removexattr(const char *fn, const char *name);
    int chain_fremovexattr(int fd, const char *name);
    
    The function translate_raw_name substitutes @@ into @. When the trailing
    character is a @, it breaks. However, such an occurence cannot be created by
    chain_setxattr because it always create pairs of @. Instead of silently
    breaking the loop, the function should probably return on error so that the
    caller can ignore it.
    
    The function chain_fgetxattr_len may return on error if fgetxattr
    returns on error. However, it is only called after another attr function
    returned success and the tests cannot create the conditions under which
    it would fail.
    
    The function chain_fsetxattr may leak attributes when used to override
    an existing attribute. This leak is not tested or fixed, it is just
    discussed in http://marc.info/?l=ceph-devel&m=136027076615853&w=4
    
    If the file system in which the tests are run does not support extended
    attributes, the tests are not run. The detection uses the same logic as
    the one implemented in FileStore::_detect_fs
    
    The output of the tests are silenced to reduce the output when testing
    assertions ( except for the dout_emergency function which cannot be
    controlled).
    a62d5198
    Unit tests for chain_xattr.cc
    Loic Dachary authored
    Create a new test file covering most (> 97%) of src/os/chain_xattr.{cc,h}
    lines of code. The following functions are tested:
    
    int chain_getxattr(const char *fn, const char *name, void *val, size_t size);
    int chain_fgetxattr(int fd, const char *name, void *val, size_t size);
    int chain_setxattr(const char *fn, const char *name, const void *val, size_t size);
    int chain_fsetxattr(int fd, const char *name, const void *val, size_t size);
    int chain_listxattr(const char *fn, char *names, size_t len);
    int chain_flistxattr(int fd, char *names, size_t len);
    int chain_removexattr(const char *fn, const char *name);
    int chain_fremovexattr(int fd, const char *name);
    
    The function translate_raw_name substitutes @@ into @. When the trailing
    character is a @, it breaks. However, such an occurence cannot be created by
    chain_setxattr because it always create pairs of @. Instead of silently
    breaking the loop, the function should probably return on error so that the
    caller can ignore it.
    
    The function chain_fgetxattr_len may return on error if fgetxattr
    returns on error. However, it is only called after another attr function
    returned success and the tests cannot create the conditions under which
    it would fail.
    
    The function chain_fsetxattr may leak attributes when used to override
    an existing attribute. This leak is not tested or fixed, it is just
    discussed in http://marc.info/?l=ceph-devel&m=136027076615853&w=4
    
    If the file system in which the tests are run does not support extended
    attributes, the tests are not run. The detection uses the same logic as
    the one implemented in FileStore::_detect_fs
    
    The output of the tests are silenced to reduce the output when testing
    assertions ( except for the dout_emergency function which cannot be
    controlled).
This project is licensed under the GNU Lesser General Public License v2.1 only. Learn more
Loading