Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stress test for erofs #358

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ jobs:
- name: Unit Test
working-directory: ${{github.workspace}}/build
shell: bash
run: ctest -j8 --output-on-failure -C $BUILD_TYPE
run: sudo ctest -j8 --output-on-failure -C $BUILD_TYPE
29 changes: 29 additions & 0 deletions src/overlaybd/tar/erofs/erofs_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,35 @@ ssize_t ErofsFile::pread(void *buf, size_t count, off_t offset)
return read;
}

ssize_t ErofsFile::fgetxattr(const char *name, void *value, size_t size)
{
ssize_t value_size = 0;

value_size = erofs_getxattr(&file_private->inode, name, NULL, 0);
if (value_size < 0)
LOG_ERROR_RETURN(-1, size, "[erofs] fail to get xattr `", name);
if ((size_t)value_size > size)
LOG_ERROR_RETURN(-1, -1, "[erofs] buffer is too small to put xattr value of `", name);
return erofs_getxattr(&file_private->inode, name, (char*)value, value_size);
}

ssize_t ErofsFile::flistxattr(char *list, size_t size)
{
ssize_t kllen;

kllen = erofs_listxattr(&file_private->inode, NULL, 0);
if (kllen < 0)
LOG_ERROR_RETURN(-1, kllen, "[erofs] fail to list xattr");
if ((size_t)kllen > size)
LOG_ERROR_RETURN(-1, -1, "[erofs buffer size is too small to put xattrs");
if (erofs_listxattr(&file_private->inode, list, kllen) != kllen)
LOG_ERROR_RETURN(-1, -1, "[erofs] fail to list xattr");
return kllen;
}

EROFS_UNIMPLEMENTED_FUNC(int, ErofsFile, fsetxattr(const char *name, const void *value, size_t size, int flags), -EROFS_UNIMPLEMENTED)
EROFS_UNIMPLEMENTED_FUNC(int, ErofsFile, fremovexattr(const char *name), -EROFS_UNIMPLEMENTED)

// ErofsFileSystem
EROFS_UNIMPLEMENTED_FUNC(photon::fs::IFile*, ErofsFileSystem, open(const char *pathname, int flags, mode_t mode), NULL)
EROFS_UNIMPLEMENTED_FUNC(photon::fs::IFile*, ErofsFileSystem, creat(const char *pathname, mode_t mode), NULL)
Expand Down
6 changes: 5 additions & 1 deletion src/overlaybd/tar/erofs/erofs_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ class ErofsFileSystem: public photon::fs::IFileSystem {
friend class ErofsFile;
};

class ErofsFile: public photon::fs::VirtualReadOnlyFile {
class ErofsFile: public photon::fs::VirtualReadOnlyFile, public photon::fs::IFileXAttr {
public:
ErofsFile(ErofsFileSystem *fs);
~ErofsFile();
photon::fs::IFileSystem *filesystem();
int fstat(struct stat *buf);
int fiemap(struct photon::fs::fiemap *map);
ssize_t pread(void *buf, size_t count, off_t offset);
ssize_t fgetxattr(const char *name, void *value, size_t size);
ssize_t flistxattr(char *list, size_t size);
int fsetxattr(const char *name, const void *value, size_t size, int flags);
int fremovexattr(const char *name);
private:
ErofsFileSystem *fs;
struct ErofsFileInt;
Expand Down
29 changes: 23 additions & 6 deletions src/overlaybd/tar/erofs/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,34 @@ link_directories($ENV{GFLAGS}/lib)
include_directories($ENV{GTEST}/googletest/include)
link_directories($ENV{GTEST}/lib)

add_executable(erofs_test test.cpp)
target_include_directories(erofs_test PUBLIC ${PHOTON_INCLUDE_DIR})
target_link_libraries(erofs_test gtest gtest_main pthread photon_static
# erofs simple test
add_executable(erofs_simple_test erofs_simple.cpp)
target_include_directories(erofs_simple_test PUBLIC ${PHOTON_INCLUDE_DIR})
target_link_libraries(erofs_simple_test gtest gtest_main pthread photon_static
tar_lib lsmt_lib gzip_lib gzindex_lib checksum_lib overlaybd_image_lib)

target_include_directories(erofs_test PUBLIC
target_include_directories(erofs_simple_test PUBLIC
${PHOTON_INCLUDE_DIR}
${rapidjson_SOURCE_DIR}/include
)

add_test(
NAME erofs_test
COMMAND ${EXECUTABLE_OUTPUT_PATH}/erofs_test
NAME erofs_simple_test
COMMAND ${EXECUTABLE_OUTPUT_PATH}/erofs_simple_test
)

# erofs stress test
add_executable(erofs_stress_test erofs_stress.cpp erofs_stress_base.cpp)
target_include_directories(erofs_stress_test PUBLIC ${PHOTON_INCLUDE_DIR})
target_link_libraries(erofs_stress_test gtest gtest_main pthread photon_static
tar_lib lsmt_lib gzip_lib gzindex_lib checksum_lib overlaybd_image_lib)

target_include_directories(erofs_stress_test PUBLIC
${PHOTON_INCLUDE_DIR}
${rapidjson_SOURCE_DIR}/include
)

add_test(
NAME erofs_stress_test
COMMAND ${EXECUTABLE_OUTPUT_PATH}/erofs_stress_test
)
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
#include "../../../gzip/gz.h"
#include "../../../../tools/sha256file.h"
#include "../../../../tools/comm_func.h"

#include "../erofs_fs.h"

#define FILE_SIZE (2 * 1024 * 1024)
#define IMAGE_SIZE 512UL<<20

class ErofsTest : public ::testing::Test {
public:
static int inflate(std::string output_file, unsigned char *data, unsigned int size) {
Expand Down Expand Up @@ -841,7 +842,6 @@ class ErofsTestCleanIncremental: public ::testing::Test {
}
delete host_fs;
}

int traverse_fs(photon::fs::IFileSystem *fs, photon::fs::IFile *out) {
std::vector<string> items;

Expand Down
Loading