CQtDeployer/tests/units/linux/striptest.cpp
2023-12-31 09:24:12 +01:00

87 lines
2.2 KiB
C++

//#
//# Copyright (C) 2020-2024 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#include "striptest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
StripTest::StripTest() {
}
StripTest::~StripTest() {
}
void StripTest::test() {
#ifdef Q_OS_UNIX
//for one lib
qint64 sizeBefor = generateLib("./test/binTargetDir/debugLib.so");
qint64 sizeAfter = 0;
FileManager *deploy = new FileManager();
QVERIFY(deploy->strip("./test/binTargetDir/debugLib.so"));
QFile testLib ("./test/binTargetDir/debugLib.so");
if (testLib.open(QIODevice::ReadOnly)) {
sizeAfter = testLib.size();
testLib.close();
}
deleteLib("./test/binTargetDir");
delete deploy;
QVERIFY(sizeBefor > sizeAfter);
//for folder
QStringList libList = {
("./test/binTargetDir/debugLib1.so"),
("./test/binTargetDir/debugLib2.so.1.2"),
("./test/binTargetDir/debugLib3.so.1"),
("./test/binTargetDir/debugLib4.so.1.0.0"),
("./test/binTargetDir/debugLib.dll"),
("./test/binTargetDir/debugLib1.dll")
};
QList<qint64> sizeBeforList = {};
for (const auto & i: libList) {
sizeBeforList.push_back(generateLib(i));
}
QList<qint64> sizeAfterList;
deploy = new FileManager();
QVERIFY(deploy->strip("./test/binTargetDir"));
for(const auto &i: libList) {
QFile testLib (i);
if (testLib.open(QIODevice::ReadOnly)) {
sizeAfterList.push_back(testLib.size());
testLib.close();
}
}
deleteLib("./test/binTargetDir");
QVERIFY(sizeBeforList.size() == sizeAfterList.size());
for (int i = 0; i < sizeAfterList.size(); ++i) {
QVERIFY2(sizeBeforList[i] > sizeAfterList[i],
QString("index %0, lib: %1 size befor:%2, sizeAfter:%3").
arg(i).arg(libList[i]).arg(sizeBeforList[i]).arg(sizeAfterList[i]).
toLatin1());
}
#endif
}