From e62d696339124bd648a5c24bb058e11289ffdcbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Mar 2015 14:43:55 +0100 Subject: [PATCH] compressed_archive_test added --- .../compressed_archive_test.pro | 17 ++++ tests/compressed_archive_test/main.cpp | 82 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tests/compressed_archive_test/compressed_archive_test.pro create mode 100644 tests/compressed_archive_test/main.cpp diff --git a/tests/compressed_archive_test/compressed_archive_test.pro b/tests/compressed_archive_test/compressed_archive_test.pro new file mode 100644 index 00000000..8321a0ed --- /dev/null +++ b/tests/compressed_archive_test/compressed_archive_test.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +CONFIG += console + +SOURCES += \ + main.cpp \ + +win32 { + LIBS += -loleaut32 -lole32 + QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT + QMAKE_LFLAGS_RELEASE += /LTCG + CONFIG -= embed_manifest_exe +} + +include(../../compressed_archive/wrapper.pri) + + + diff --git a/tests/compressed_archive_test/main.cpp b/tests/compressed_archive_test/main.cpp new file mode 100644 index 00000000..db58740b --- /dev/null +++ b/tests/compressed_archive_test/main.cpp @@ -0,0 +1,82 @@ + +#include +#include +#include + +#include "compressed_archive.h" + +#include + +using namespace std; + + +//This program uses PROTOS Genome Test Suite c10-archive [0] for testing the CompressedArchive wrapper files support +//It tests the following formats: RAR, ZIP, TAR +//Arter downloading c10-archive-r1.iso, open it and full extract RAR_TAR.BZ2, ZIP_TAR.BZ2, TAR_TAR.BZ2 files into a folder +//This program takes the path to that folder as an argument +// +// [0] https://www.ee.oulu.fi/research/ouspg/PROTOS_Test-Suite_c10-archive#Download +// +int main(int argc, char *argv[]) +{ + if(argc < 2) + { + cout << "Usage: compressed_archive_test PATH" << endl; + return 0; + } + + QCoreApplication app(argc, argv); + + QString s(argv[1]); + + QStringList supportedFormats; + supportedFormats << "rar" << "zip" << "tar"; + + QElapsedTimer timer; + timer.start(); + + quint32 totalFiles = 0; + foreach (QString format, supportedFormats) { + QDir rootDir(s); + if(!rootDir.cd(format)) + { + cout << "Folder for format '" << format.toStdString() << "' not found" << endl; + continue; + } + rootDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); + + QFileInfoList files = rootDir.entryInfoList(); + quint32 totalFormat = 0; + quint32 errors = 0; + quint64 init = timer.elapsed(); + + foreach(QFileInfo fileInfo, files) + { + totalFiles++; + totalFormat++; + CompressedArchive archive(fileInfo.filePath()); + if(!archive.isValid()) + errors++; + else + { + int i = archive.getNumFiles(); + cerr << i; + cerr << archive.getFileNames().at(0).toStdString(); + } + } + quint64 end = timer.elapsed(); + + + cout << "Format '" << format.toStdString() <<"'" << endl; + cout << "Total files : " << totalFormat << endl; + cout << "Errors : " << errors << endl; + cout << "Elapsed time : " << (end - init) / 1000000 <<"s" << endl; + cout << endl; + } + + cout << endl; + cout << "Total time : " << timer.elapsed() / 1000000 <<"s" <