Skip to content

Commit

Permalink
Merge pull request #353 from salvete/main
Browse files Browse the repository at this point in the history
Add unit test for pax-header tar and clean up
  • Loading branch information
BigVan authored Nov 18, 2024
2 parents 2fed67e + 0fe569f commit 65f4fb2
Show file tree
Hide file tree
Showing 3 changed files with 353 additions and 43 deletions.
12 changes: 8 additions & 4 deletions src/overlaybd/tar/erofs/liberofs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ static int erofs_write_map_file(photon::fs::IFile *fout, uint64_t blksz, FILE *f
uint32_t nblocks, zeroedlen;
char *line = NULL;
size_t len = 0;
int cnt;
int cnt, err = 0;

if (fp == NULL) {
LOG_ERROR("unable to get upper.map, ignored");
Expand All @@ -597,6 +597,7 @@ static int erofs_write_map_file(photon::fs::IFile *fout, uint64_t blksz, FILE *f
cnt = sscanf(line, "%" PRIx64" %x%" PRIx64 "%u", &blkaddr, &nblocks, &toff, &zeroedlen);
if (cnt < 3) {
LOG_ERROR("Bad formatted map file.");
err = -EINVAL;
break;
}

Expand All @@ -608,12 +609,15 @@ static int erofs_write_map_file(photon::fs::IFile *fout, uint64_t blksz, FILE *f

int nwrite = fout->ioctl(LSMT::IFileRW::RemoteData, lba);
if ((unsigned) nwrite != lba.count) {
LOG_ERRNO_RETURN(0, -1, "failed to write lba");
LOG_ERROR("failed to write lba");
err = -EINVAL;
break;
}
}
free(line);
if (line)
free(line);

return 0;
return err;
}

static int erofs_close_sbi(struct erofs_sb_info *sbi, ErofsCache *cache)
Expand Down
7 changes: 6 additions & 1 deletion src/overlaybd/tar/erofs/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ 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
tar_lib lsmt_lib gzip_lib gzindex_lib checksum_lib)
tar_lib lsmt_lib gzip_lib gzindex_lib checksum_lib overlaybd_image_lib)

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

add_test(
NAME erofs_test
Expand Down
Loading

0 comments on commit 65f4fb2

Please sign in to comment.