Skip to content

Commit

Permalink
Fix Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
electroly committed Dec 13, 2023
1 parent 2e1ed56 commit de8668f
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 174 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ endif
# TEST_CMD: We run our unit test executable in "make test". For the Windows target, we use Wine since we cross-compile
# from Linux. This command is executed from the "bin" directory.
ifeq ($(TARGET_OS),win)
TEST_CMD=WINEPATH=/usr/$(ARCH)-w64-mingw32/bin wine64 test.exe
TEST_CMD=mkdir -p /tmp/tmbasic-wine && HOME=/tmp/tmbasic-wine WINEPATH=/usr/$(ARCH)-w64-mingw32/bin wine64 test.exe
else
TEST_CMD=./test
endif
Expand Down
6 changes: 0 additions & 6 deletions build/test/Dockerfile.wine

This file was deleted.

105 changes: 0 additions & 105 deletions build/test/test.sh

This file was deleted.

62 changes: 0 additions & 62 deletions src/test/CompressionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,65 +93,3 @@ TEST(MicrotarTest, Roundtrip) {
unlink("test1.txt");
unlink("test.tar");
}

// Use GNU tar to write an archive and then read it with microtar.
TEST(MicrotarTest, RoundtripWithGnuTar) {
std::array<char, 5000> data = { 0 };
for (size_t i = 0; i < data.size(); i++) {
data[i] = static_cast<char>(i % 256);
}

// Create directory "Folder Name".
// Write "Folder Name/test.dat" using C++ idioms
{
#ifdef _WIN32
mkdir("Folder Name");
#else
mkdir("Folder Name", 0777);
#endif
std::ofstream f("Folder Name/test.dat", std::ios::binary);
f.write(data.data(), data.size());
}

// Make test.tar using system tar
{
std::string cmd = "tar -cf test.tar 'Folder Name'";
ASSERT_EQ(0, system(cmd.c_str()));
}

// Read test.tar using microtar
{
mtar_t tar;
mtar_header_t h;

mtar_open(&tar, "test.tar", "r");

while ((mtar_read_header(&tar, &h)) != MTAR_ENULLRECORD) {
std::vector<char> buf(h.size);
mtar_read_data(&tar, buf.data(), h.size);

if (strcmp(h.name, "Folder Name/") == 0) {
// Skip directory
mtar_next(&tar);
continue;
}

// Verify name
ASSERT_EQ(std::string{ "Folder Name/test.dat" }, std::string{ h.name });

// Verify buf vs. data
for (size_t i = 0; i < data.size(); i++) {
ASSERT_EQ(data[i], buf[i]);
}

mtar_next(&tar);
}

mtar_close(&tar);
}

// Delete files.
unlink("test.tar");
unlink("Folder Name/test.dat");
rmdir("Folder Name");
}

0 comments on commit de8668f

Please sign in to comment.