annotate ui/tests/cinstprocesstest.cpp @ 304:eecc06f714fd

Add first nsstest.
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 03 Apr 2014 14:29:49 +0200
parents 56507c3d5f1e
children 4a3febc6d806
rev   line source
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1 #include "cinstprocesstest.h"
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
2 #include "certificatelist.h"
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 #include "errorcodes.h"
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
4 #include "common.h"
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 #include <QDebug>
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7 #include <QDir>
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8 #include <QFile>
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9 #include <QProcess>
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
10
294
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
11 #define CINST_PATH_CANDIDATES "../../cinst/cinst" << \
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
12 "cinst" << "../../cinst/cinst.exe" << "cinst.exe";
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13
294
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
14 QProcess *CinstProcessTest::startCinstProcess(const QStringList& args) {
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
15 QStringList cinstCandidates;
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
16 cinstCandidates << CINST_PATH_CANDIDATES;
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
17 QString processPath;
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
18 foreach (const QString& candidate, cinstCandidates) {
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
19 QFileInfo fi(candidate);
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
20 if (fi.isExecutable()) {
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
21 processPath = candidate;
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
22 break;
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
23 }
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
24 }
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
25
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26 QProcess *installerProcess = new QProcess();
294
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
27 installerProcess->setArguments(args);
d95fd88f6616 Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
28 installerProcess->setProgram(processPath);
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29 installerProcess->start();
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30 installerProcess->waitForStarted();
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 return installerProcess;
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32 }
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33
151
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
34 #define VERIFY_PROC_DEBUG(x) \
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
35 if (! x ) { \
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
36 qDebug() << "Stdout:" << proc->readAllStandardOutput(); \
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
37 qDebug() << "Stderr:" << proc->readAllStandardError(); \
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
38 qDebug() << "Exit code: " << proc->exitCode(); \
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
39 } \
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
40 QVERIFY(x)
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
41
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42 void finishVerify(QProcess *proc, int exitCode) {
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 proc->closeWriteChannel();
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
44 proc->waitForFinished();
151
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
45 VERIFY_PROC_DEBUG(proc->exitStatus() == QProcess::NormalExit);
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
46 VERIFY_PROC_DEBUG(proc->exitCode() == exitCode);
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
47 delete proc;
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
48 }
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50 void CinstProcessTest::testValidInput() {
295
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
51 QStringList args;
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
52 args << "list=" + validListFile.fileName();
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53
295
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
54 QTemporaryFile instructions;
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
55 instructions.open();
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
56 foreach (const Certificate &cert, validList.getCertificates()) {
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
57 instructions.write(cert.base64Line().toLatin1());
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
58 instructions.write("\n");
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
59 }
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
60 instructions.close();
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
61
295
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
62 args << "instructions=" + instructions.fileName();
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
63
295
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
64 QProcess* installerProcess = startCinstProcess(args);
159
37c9653b8755 Rename NO_ERROR as NO_ERROR is already defined in windows.h
Andre Heinecke <aheinecke@intevation.de>
parents: 151
diff changeset
65 finishVerify(installerProcess, ERR_NO_ERROR);
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
66 }
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
67
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
68 void CinstProcessTest::initTestCase() {
295
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
69 QFile valid(":/list-valid-signed.txt");
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
70 valid.open(QIODevice::ReadOnly);
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
71 validListFile.open();
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
72 validListFile.write(valid.readAll());
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
73 valid.close();
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
74 validListFile.close();
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
75 validList = CertificateList(validListFile.fileName().toLocal8Bit().data());
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
76
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
77 QVERIFY(validList.isValid());
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
78
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
79 QFile invalid(":/list-invalid-signed.txt");
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
80 invalid.open(QIODevice::ReadOnly);
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
81 invalidListFile.open();
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
82 invalidListFile.write(invalid.readAll());
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
83 invalid.close();
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
84 invalidListFile.close();
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
85 invalidList = CertificateList(invalidListFile.fileName().toLocal8Bit().data());
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
86
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
87 QVERIFY(!invalidList.isValid());
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
88
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
89 QFile other(":/list-valid-other-signature.txt");
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
90 other.open(QIODevice::ReadOnly);
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
91 otherListFile.open();
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
92 otherListFile.write(other.readAll());
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
93 other.close();
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
94 otherListFile.close();
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
95 otherList = CertificateList(otherListFile.fileName().toLocal8Bit().data());
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
96
02df89a275a6 Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents: 294
diff changeset
97 QVERIFY(!otherList.isValid());
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
98 }
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
99
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
100 void CinstProcessTest::testNoList() {
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
101 /* No list */
296
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
102 QTemporaryFile emptyFile;
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
103 emptyFile.open();
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
104 emptyFile.close();
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
105
296
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
106 QStringList args;
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
107 args << "list=" + emptyFile.fileName();
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
108
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
109 QTemporaryFile instructions;
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
110 instructions.open();
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 159
diff changeset
111 foreach (const Certificate &cert, validList.getCertificates()) {
296
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
112 instructions.write(cert.base64Line().toLatin1());
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
113 instructions.write("\n");
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
114 }
296
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
115 instructions.close();
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
116
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
117 args << "instructions=" + instructions.fileName();
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
118
0b1453070561 Fix test no list
Andre Heinecke <aheinecke@intevation.de>
parents: 295
diff changeset
119 QProcess* installerProcess = startCinstProcess(args);
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
120 finishVerify(installerProcess, ERR_INVALID_INPUT_NO_LIST);
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
121 }
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
122
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
123 void CinstProcessTest::testGarbageInput() {
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
124 QStringList args;
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
125
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
126 QString garbage = getRandomDataFile(21*1024*1024);
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
127 args << "list=" + garbage;
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
128
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
129 QTemporaryFile instructions;
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
130 instructions.open();
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
131 foreach (const Certificate &cert, validList.getCertificates()) {
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
132 instructions.write(cert.base64Line().toLatin1());
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
133 instructions.write("\n");
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
134 }
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
135 instructions.close();
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
136
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
137 args << "instructions=" + instructions.fileName();
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
138
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
139 QProcess* installerProcess = startCinstProcess(args);
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
140 /* If the following failed there may be leftovers in /tmp */
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
141 finishVerify(installerProcess, ERR_INVALID_INPUT_NO_LIST);
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
142 QVERIFY(QFile::remove(garbage));
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
143 }
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
144
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
145 void CinstProcessTest::testNoInput() {
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
146 QStringList args;
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
147 args << "list=foobazbuf";
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
148 args << "instructions=bazbuffoo";
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
149 QProcess* installerProcess;
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
150 installerProcess = startCinstProcess(args);
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
151 finishVerify(installerProcess, ERR_INVALID_INPUT_NO_LIST);
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
152 }
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
153
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
154
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
155 void CinstProcessTest::testNoInstructions() {
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
156 /* No instructions */
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
157 QTemporaryFile emptyFile;
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
158 emptyFile.open();
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
159 emptyFile.close();
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
160
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
161 QStringList args;
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
162 args << "list=" + validListFile.fileName();
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
163 args << "instructions=" + emptyFile.fileName();
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
164
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
165 QProcess* installerProcess = startCinstProcess(args);
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
166 finishVerify(installerProcess, ERR_NO_INSTRUCTIONS);
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
167 }
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
168
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
169 void CinstProcessTest::testInvalidInstruction() {
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
170 QStringList args;
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
171 args << "list=" + validListFile.fileName();
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
172
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
173 QTemporaryFile instructions;
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
174 instructions.open();
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
175 foreach (const Certificate &cert, validList.getCertificates()) {
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
176 instructions.write(cert.base64Line().toLatin1());
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
177 instructions.write("\n");
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
178 }
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
179 instructions.write("I:ABCDEF\n");
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
180 instructions.close();
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
181
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
182 args << "instructions=" + instructions.fileName();
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
183
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
184 QProcess* installerProcess = startCinstProcess(args);
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
185
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
186 finishVerify(installerProcess, ERR_INVALID_INSTRUCTIONS);
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
187 }
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
188
151
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
189 void CinstProcessTest::testUninstall() {
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
190 QStringList args;
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
191 args << "list=" + validListFile.fileName();
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
192 args << "instructions=uninstall";
151
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
193
298
56507c3d5f1e Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents: 296
diff changeset
194 QProcess* installerProcess = startCinstProcess(args);
151
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
195
159
37c9653b8755 Rename NO_ERROR as NO_ERROR is already defined in windows.h
Andre Heinecke <aheinecke@intevation.de>
parents: 151
diff changeset
196 finishVerify(installerProcess, ERR_NO_ERROR);
151
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
197 }
0df62decff90 Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents: 150
diff changeset
198
100
8fa273791242 Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
199 QTEST_GUILESS_MAIN (CinstProcessTest);

http://wald.intevation.org/projects/trustbridge/