test code
This commit is contained in:
		@@ -211,21 +211,73 @@ static bool test_neuhauser_kirchdorf(int step, double cost) {
 | 
			
		||||
    return 0;
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include <QProcess>
 | 
			
		||||
#include <QCoreApplication>
 | 
			
		||||
QString getCalculatorLibVersion() {
 | 
			
		||||
    static QString v;
 | 
			
		||||
    if (v.isEmpty()) {
 | 
			
		||||
        QProcess shell;
 | 
			
		||||
        QString command = QString("cat /proc/%1/maps | awk '{print $6;}' | grep 'libmobilisis_calc' | uniq").arg(QCoreApplication::applicationPid());
 | 
			
		||||
 | 
			
		||||
        shell.start("/bin/bash", {"-c", command});
 | 
			
		||||
        if ( shell.waitForFinished( 5000 )) {
 | 
			
		||||
            v = shell.readAllStandardOutput();
 | 
			
		||||
            // /usr/lib/libmobilisis_calc.so.2.3.99-18
 | 
			
		||||
            if (!v.isEmpty()) {
 | 
			
		||||
                QStringList vlst = v.trimmed().split("/", QString::SkipEmptyParts);
 | 
			
		||||
                if (vlst.size() > 0) {
 | 
			
		||||
                    vlst = vlst.last().split(".", QString::SkipEmptyParts);
 | 
			
		||||
                    if (vlst.size() > 4) {
 | 
			
		||||
                        v = QString("%1.%2.%3").arg(vlst[2]).arg(vlst[3]).arg(vlst[4]);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return v;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool isProductSupportedInCalculatorLib(QString const &product) {
 | 
			
		||||
    bool supported{false};
 | 
			
		||||
 | 
			
		||||
    QProcess shell;
 | 
			
		||||
    QString command = QString("cat /proc/%1/maps | awk '{print $6;}' | grep 'libmobilisis_calc' | uniq | xargs strings | grep %2").arg(QCoreApplication::applicationPid()).arg(product);
 | 
			
		||||
 | 
			
		||||
    shell.start("/bin/bash", {"-c", command});
 | 
			
		||||
    if ( shell.waitForFinished( 5000 )) {
 | 
			
		||||
        QString s = shell.readAllStandardOutput().trimmed();
 | 
			
		||||
        // /usr/lib/libmobilisis_calc.so.2.3.99-18
 | 
			
		||||
        if (!s.isEmpty() && (s == product)) {
 | 
			
		||||
            qCritical() << "product" << s << "supported";
 | 
			
		||||
            supported = true;
 | 
			
		||||
        } else {
 | 
			
		||||
            qCritical() << "product" << product << "not supported";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return supported;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main() {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    qCritical() << getCalculatorLibVersion();
 | 
			
		||||
    isProductSupportedInCalculatorLib("FREE_TICKET");
 | 
			
		||||
    return 0;
 | 
			
		||||
    //487     {
 | 
			
		||||
    //  488         "pra_payment_option_id": 1049,
 | 
			
		||||
    //  489         "pra_payment_unit_id": 84,
 | 
			
		||||
    //  490         "pra_price":"840"
 | 
			
		||||
    //>>491     }
 | 
			
		||||
 | 
			
		||||
    //for (int i = 1; i < 85; ++i) {
 | 
			
		||||
    //printf("{\n    \"\pra_payment_option_id\": 1049,\n    \"\pra_payment_unit_id\": %d,\n    \"pra_price\": %d\n},\n",
 | 
			
		||||
    //       i, i*10);
 | 
			
		||||
    //for (int i = 1; i < 346; ++i) {
 | 
			
		||||
    //printf("{\n    \"pun_id\": %i,\n    \"pun_duration\": %d\n},\n",
 | 
			
		||||
    //       i, 60 + i*4);
 | 
			
		||||
    //}
 | 
			
		||||
    //return 0;
 | 
			
		||||
    for (int i = 1; i < 361; ++i) {
 | 
			
		||||
    printf("{\n    \"pra_payment_option_id\": 1049,\n    \"pra_payment_unit_id\": %i,\n    \"pra_price\":%i\n},\n",
 | 
			
		||||
           i, i*10);
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
#if 0
 | 
			
		||||
    MessageHelper msgHelp;
 | 
			
		||||
    // msgHelp.createLoginMessageChunksToSend(0x02);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
QT += core
 | 
			
		||||
 | 
			
		||||
TEMPLATE = app
 | 
			
		||||
TARGET = main
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user