mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Add test for 640Mb M.O. image in AaruFormat V1.
This commit is contained in:
@@ -37,6 +37,7 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/hifd_v1.aif DESTINATION ${CMAKE_CURRE
|
|||||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/hifd.aif DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/hifd.aif DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/mo540_v1.aif DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/mo540_v1.aif DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/mo540.aif DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/mo540.aif DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||||
|
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/mo640_v1.aif DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||||
|
|
||||||
# Test executable (all unit tests)
|
# Test executable (all unit tests)
|
||||||
add_executable(tests_run crc64.cpp spamsum.cpp crc32.c crc32.h flac.cpp lzma.cpp sha256.cpp md5.cpp sha1.cpp open_image.cpp)
|
add_executable(tests_run crc64.cpp spamsum.cpp crc32.c crc32.h flac.cpp lzma.cpp sha256.cpp md5.cpp sha1.cpp open_image.cpp)
|
||||||
|
|||||||
BIN
tests/data/mo640_v1.aif
Executable file
BIN
tests/data/mo640_v1.aif
Executable file
Binary file not shown.
@@ -91,7 +91,7 @@ TEST_F(OpenImageFixture, open_mf2hd_v1)
|
|||||||
aaruf_crc64_final(ctx, &crc);
|
aaruf_crc64_final(ctx, &crc);
|
||||||
aaruf_crc64_free(ctx);
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
EXPECT_EQ(crc, 0x0439da56aa993cdf) << "Unexpected CRC64 for image data";
|
ASSERT_EQ(crc, 0x0439da56aa993cdf) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
// Close the image
|
// Close the image
|
||||||
const int32_t close_result = aaruf_close(context);
|
const int32_t close_result = aaruf_close(context);
|
||||||
@@ -149,7 +149,7 @@ TEST_F(OpenImageFixture, open_mf2hd_v2)
|
|||||||
aaruf_crc64_final(ctx, &crc);
|
aaruf_crc64_final(ctx, &crc);
|
||||||
aaruf_crc64_free(ctx);
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
EXPECT_EQ(crc, 0x0439da56aa993cdf) << "Unexpected CRC64 for image data";
|
ASSERT_EQ(crc, 0x0439da56aa993cdf) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
// Close the image
|
// Close the image
|
||||||
const int32_t close_result = aaruf_close(context);
|
const int32_t close_result = aaruf_close(context);
|
||||||
@@ -207,7 +207,7 @@ TEST_F(OpenImageFixture, open_floptical_v1)
|
|||||||
aaruf_crc64_final(ctx, &crc);
|
aaruf_crc64_final(ctx, &crc);
|
||||||
aaruf_crc64_free(ctx);
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
EXPECT_EQ(crc, 0x924451887b380a43) << "Unexpected CRC64 for image data";
|
ASSERT_EQ(crc, 0x924451887b380a43) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
// Close the image
|
// Close the image
|
||||||
const int32_t close_result = aaruf_close(context);
|
const int32_t close_result = aaruf_close(context);
|
||||||
@@ -265,7 +265,7 @@ TEST_F(OpenImageFixture, open_floptical_v2)
|
|||||||
aaruf_crc64_final(ctx, &crc);
|
aaruf_crc64_final(ctx, &crc);
|
||||||
aaruf_crc64_free(ctx);
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
EXPECT_EQ(crc, 0x924451887b380a43) << "Unexpected CRC64 for image data";
|
ASSERT_EQ(crc, 0x924451887b380a43) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
// Close the image
|
// Close the image
|
||||||
const int32_t close_result = aaruf_close(context);
|
const int32_t close_result = aaruf_close(context);
|
||||||
@@ -323,7 +323,7 @@ TEST_F(OpenImageFixture, open_gigamo_v1)
|
|||||||
aaruf_crc64_final(ctx, &crc);
|
aaruf_crc64_final(ctx, &crc);
|
||||||
aaruf_crc64_free(ctx);
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
EXPECT_EQ(crc, 0x96c05a76c6f7385b) << "Unexpected CRC64 for image data";
|
ASSERT_EQ(crc, 0x96c05a76c6f7385b) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
// Close the image
|
// Close the image
|
||||||
const int32_t close_result = aaruf_close(context);
|
const int32_t close_result = aaruf_close(context);
|
||||||
@@ -381,7 +381,7 @@ TEST_F(OpenImageFixture, open_gigamo_v2)
|
|||||||
aaruf_crc64_final(ctx, &crc);
|
aaruf_crc64_final(ctx, &crc);
|
||||||
aaruf_crc64_free(ctx);
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
EXPECT_EQ(crc, 0x96c05a76c6f7385b) << "Unexpected CRC64 for image data";
|
ASSERT_EQ(crc, 0x96c05a76c6f7385b) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
// Close the image
|
// Close the image
|
||||||
const int32_t close_result = aaruf_close(context);
|
const int32_t close_result = aaruf_close(context);
|
||||||
@@ -439,7 +439,7 @@ TEST_F(OpenImageFixture, open_hifd_v1)
|
|||||||
aaruf_crc64_final(ctx, &crc);
|
aaruf_crc64_final(ctx, &crc);
|
||||||
aaruf_crc64_free(ctx);
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
EXPECT_EQ(crc, 0xcf6865ab1977f144) << "Unexpected CRC64 for image data";
|
ASSERT_EQ(crc, 0xcf6865ab1977f144) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
// Close the image
|
// Close the image
|
||||||
const int32_t close_result = aaruf_close(context);
|
const int32_t close_result = aaruf_close(context);
|
||||||
@@ -497,7 +497,7 @@ TEST_F(OpenImageFixture, open_hifd_v2)
|
|||||||
aaruf_crc64_final(ctx, &crc);
|
aaruf_crc64_final(ctx, &crc);
|
||||||
aaruf_crc64_free(ctx);
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
EXPECT_EQ(crc, 0xcf6865ab1977f144) << "Unexpected CRC64 for image data";
|
ASSERT_EQ(crc, 0xcf6865ab1977f144) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
// Close the image
|
// Close the image
|
||||||
const int32_t close_result = aaruf_close(context);
|
const int32_t close_result = aaruf_close(context);
|
||||||
@@ -555,7 +555,7 @@ TEST_F(OpenImageFixture, open_mo540_v1)
|
|||||||
aaruf_crc64_final(ctx, &crc);
|
aaruf_crc64_final(ctx, &crc);
|
||||||
aaruf_crc64_free(ctx);
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
EXPECT_EQ(crc, 0xe50350dde624cd75) << "Unexpected CRC64 for image data";
|
ASSERT_EQ(crc, 0xe50350dde624cd75) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
// Close the image
|
// Close the image
|
||||||
const int32_t close_result = aaruf_close(context);
|
const int32_t close_result = aaruf_close(context);
|
||||||
@@ -613,7 +613,65 @@ TEST_F(OpenImageFixture, open_mo540_v2)
|
|||||||
aaruf_crc64_final(ctx, &crc);
|
aaruf_crc64_final(ctx, &crc);
|
||||||
aaruf_crc64_free(ctx);
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
EXPECT_EQ(crc, 0xe50350dde624cd75) << "Unexpected CRC64 for image data";
|
ASSERT_EQ(crc, 0xe50350dde624cd75) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
|
// Close the image
|
||||||
|
const int32_t close_result = aaruf_close(context);
|
||||||
|
EXPECT_EQ(close_result, AARUF_STATUS_OK) << "Failed to close image";
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(OpenImageFixture, open_mo640_v1)
|
||||||
|
{
|
||||||
|
char path[PATH_MAX];
|
||||||
|
char filename[PATH_MAX];
|
||||||
|
|
||||||
|
getcwd(path, PATH_MAX);
|
||||||
|
snprintf(filename, PATH_MAX, "%s/data/mo640_v1.aif", path);
|
||||||
|
|
||||||
|
// Attempt to open the image file
|
||||||
|
void *context = aaruf_open(filename);
|
||||||
|
|
||||||
|
// Verify that the file was successfully opened
|
||||||
|
ASSERT_NE(context, nullptr) << "Failed to open mo640_v1.aif";
|
||||||
|
|
||||||
|
// Get image info to verify it's a valid image
|
||||||
|
ImageInfo image_info;
|
||||||
|
const int32_t result = aaruf_get_image_info(context, &image_info);
|
||||||
|
|
||||||
|
ASSERT_EQ(result, AARUF_STATUS_OK) << "Failed to get image info";
|
||||||
|
|
||||||
|
// Basic sanity checks on the image info
|
||||||
|
ASSERT_EQ(image_info.HasPartitions, false) << "Image should not have partitions";
|
||||||
|
ASSERT_EQ(image_info.HasSessions, false) << "Image should not have sessions";
|
||||||
|
ASSERT_EQ(image_info.ImageSize, 8655) << "Unexpected image size";
|
||||||
|
ASSERT_EQ(image_info.Sectors, 310352) << "Unexpected number of sectors";
|
||||||
|
ASSERT_EQ(image_info.SectorSize, 2048) << "Unexpected sector size";
|
||||||
|
ASSERT_STREQ(image_info.Version, "1.0") << "Unexpected image version";
|
||||||
|
ASSERT_STREQ(image_info.Application, "Aaru") << "Unexpected application name";
|
||||||
|
ASSERT_STREQ(image_info.ApplicationVersion, "4.5") << "Unexpected application version";
|
||||||
|
ASSERT_EQ(image_info.CreationTime, 132285163973454137ULL) << "Unexpected creation time";
|
||||||
|
ASSERT_EQ(image_info.LastModificationTime, 132285166863805792ULL) << "Unexpected modification time";
|
||||||
|
ASSERT_EQ(image_info.MediaType, 646) << "Unexpected media type";
|
||||||
|
ASSERT_EQ(image_info.MetadataMediaType, 1) << "Unexpected metadata media type";
|
||||||
|
|
||||||
|
crc64_ctx *ctx = aaruf_crc64_init();
|
||||||
|
uint64_t crc = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < 310352; i++)
|
||||||
|
{
|
||||||
|
uint8_t buffer[2048];
|
||||||
|
uint32_t length = sizeof(buffer);
|
||||||
|
|
||||||
|
const int32_t read_result = aaruf_read_sector(context, i, false, buffer, &length);
|
||||||
|
EXPECT_EQ(read_result, AARUF_STATUS_OK) << "Failed to read sector " << i;
|
||||||
|
EXPECT_EQ(length, 2048U) << "Unexpected length for sector " << i;
|
||||||
|
aaruf_crc64_update(ctx, buffer, 2048);
|
||||||
|
}
|
||||||
|
|
||||||
|
aaruf_crc64_final(ctx, &crc);
|
||||||
|
aaruf_crc64_free(ctx);
|
||||||
|
|
||||||
|
ASSERT_EQ(crc, 0x6761926a7b8c1f54) << "Unexpected CRC64 for image data";
|
||||||
|
|
||||||
// Close the image
|
// Close the image
|
||||||
const int32_t close_result = aaruf_close(context);
|
const int32_t close_result = aaruf_close(context);
|
||||||
|
|||||||
Reference in New Issue
Block a user