mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-12 22:10:54 -04:00
test(compat): legacy images built with --set-owner/--set-group
This commit is contained in:
parent
979ce8e964
commit
a65f883736
@ -24,7 +24,9 @@
|
|||||||
// TODO: this test should be autogenerated somehow...
|
// TODO: this test should be autogenerated somehow...
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <filesystem>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -52,9 +54,12 @@
|
|||||||
#include "test_logger.h"
|
#include "test_logger.h"
|
||||||
|
|
||||||
using namespace dwarfs;
|
using namespace dwarfs;
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
auto test_dir = fs::path(TEST_DATA_DIR).make_preferred();
|
||||||
|
|
||||||
char const* reference_v0_2 = R"(
|
char const* reference_v0_2 = R"(
|
||||||
{
|
{
|
||||||
"root": {
|
"root": {
|
||||||
@ -1241,3 +1246,38 @@ INSTANTIATE_TEST_SUITE_P(dwarfs_compat, rewrite,
|
|||||||
::testing::Combine(::testing::ValuesIn(versions),
|
::testing::Combine(::testing::ValuesIn(versions),
|
||||||
::testing::Bool(),
|
::testing::Bool(),
|
||||||
::testing::Bool()));
|
::testing::Bool()));
|
||||||
|
|
||||||
|
class set_uidgid_test : public testing::TestWithParam<char const*> {};
|
||||||
|
|
||||||
|
TEST_P(set_uidgid_test, read_legacy_image) {
|
||||||
|
auto image = test_dir / GetParam();
|
||||||
|
|
||||||
|
test::test_logger lgr;
|
||||||
|
filesystem_v2 fs(lgr, std::make_shared<mmap>(image));
|
||||||
|
|
||||||
|
ASSERT_EQ(0, fs.check(filesystem_check_level::FULL));
|
||||||
|
|
||||||
|
for (auto path : {"/dwarfs", "/dwarfs/version.h"}) {
|
||||||
|
auto v = fs.find(path);
|
||||||
|
ASSERT_TRUE(v) << path;
|
||||||
|
EXPECT_EQ(33333, v->getuid()) << path;
|
||||||
|
EXPECT_EQ(44444, v->getgid()) << path;
|
||||||
|
|
||||||
|
file_stat st;
|
||||||
|
EXPECT_EQ(0, fs.getattr(*v, &st)) << path;
|
||||||
|
EXPECT_EQ(33333, st.uid) << path;
|
||||||
|
EXPECT_EQ(44444, st.gid) << path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
std::array legacy_images{
|
||||||
|
"setuidgid-v0.4.1.dwarfs",
|
||||||
|
"setuidgid-v0.5.6.dwarfs",
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(dwarfs_compat, set_uidgid_test,
|
||||||
|
::testing::ValuesIn(legacy_images));
|
||||||
|
BIN
test/setuidgid-v0.4.1.dwarfs
Normal file
BIN
test/setuidgid-v0.4.1.dwarfs
Normal file
Binary file not shown.
BIN
test/setuidgid-v0.5.6.dwarfs
Normal file
BIN
test/setuidgid-v0.5.6.dwarfs
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user