Mercurial > trustbridge
annotate ui/tests/cinstprocesstest.cpp @ 382:124f08a85532
Rename instructions to choices
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 15 Apr 2014 17:46:16 +0200 |
parents | 5e4ae994a320 |
children | 17e1c8f37d72 |
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 |
313
f17226aa2e09
Temporary build fix for windows. Also Use putenv in test
Andre Heinecke <aheinecke@intevation.de>
parents:
306
diff
changeset
|
11 #include <stdlib.h> |
f17226aa2e09
Temporary build fix for windows. Also Use putenv in test
Andre Heinecke <aheinecke@intevation.de>
parents:
306
diff
changeset
|
12 |
294
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
13 #define CINST_PATH_CANDIDATES "../../cinst/cinst" << \ |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
14 "cinst" << "../../cinst/cinst.exe" << "cinst.exe"; |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
15 |
294
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
16 QProcess *CinstProcessTest::startCinstProcess(const QStringList& args) { |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
17 QStringList cinstCandidates; |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
18 cinstCandidates << CINST_PATH_CANDIDATES; |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
19 QString processPath; |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
20 foreach (const QString& candidate, cinstCandidates) { |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
21 QFileInfo fi(candidate); |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
22 if (fi.isExecutable()) { |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
23 processPath = candidate; |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
24 break; |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
25 } |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
26 } |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
27 |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
28 QProcess *installerProcess = new QProcess(); |
294
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
29 installerProcess->setArguments(args); |
d95fd88f6616
Prepare cinstprocesstest to be executed on Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
249
diff
changeset
|
30 installerProcess->setProgram(processPath); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
31 installerProcess->start(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
32 installerProcess->waitForStarted(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
33 return installerProcess; |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
34 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
36 #define VERIFY_PROC_DEBUG(x) \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
37 if (! x ) { \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
38 qDebug() << "Stdout:" << proc->readAllStandardOutput(); \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
39 qDebug() << "Stderr:" << proc->readAllStandardError(); \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
40 qDebug() << "Exit code: " << proc->exitCode(); \ |
305
4a3febc6d806
Some minor cleanups. Better debug output more Verify's
Andre Heinecke <andre.heinecke@intevation.de>
parents:
298
diff
changeset
|
41 qDebug() << "Exit status: " << proc->exitStatus(); \ |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
42 } \ |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
43 QVERIFY(x) |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
44 |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
45 void finishVerify(QProcess *proc, int exitCode) { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 proc->closeWriteChannel(); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 proc->waitForFinished(); |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
48 VERIFY_PROC_DEBUG(proc->exitStatus() == QProcess::NormalExit); |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
49 VERIFY_PROC_DEBUG(proc->exitCode() == exitCode); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
50 delete proc; |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
51 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
52 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
53 void CinstProcessTest::testValidInput() { |
295
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
54 QStringList args; |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
55 args << "list=" + validListFile.fileName(); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
56 |
295
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
57 QTemporaryFile instructions; |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
58 instructions.open(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
59 foreach (const Certificate &cert, validList.getCertificates()) { |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
60 instructions.write(cert.base64Line().toLatin1()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
61 instructions.write("\n"); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
62 } |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
63 instructions.close(); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
64 |
295
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
65 args << "instructions=" + instructions.fileName(); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
66 |
295
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
67 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
|
68 finishVerify(installerProcess, ERR_NO_ERROR); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
69 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
70 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
71 void CinstProcessTest::initTestCase() { |
295
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
72 QFile valid(":/list-valid-signed.txt"); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
73 valid.open(QIODevice::ReadOnly); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
74 validListFile.open(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
75 validListFile.write(valid.readAll()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
76 valid.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
77 validListFile.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
78 validList = CertificateList(validListFile.fileName().toLocal8Bit().data()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
79 |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
80 QVERIFY(validList.isValid()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
81 |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
82 QFile invalid(":/list-invalid-signed.txt"); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
83 invalid.open(QIODevice::ReadOnly); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
84 invalidListFile.open(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
85 invalidListFile.write(invalid.readAll()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
86 invalid.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
87 invalidListFile.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
88 invalidList = CertificateList(invalidListFile.fileName().toLocal8Bit().data()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
89 |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
90 QVERIFY(!invalidList.isValid()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
91 |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
92 QFile other(":/list-valid-other-signature.txt"); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
93 other.open(QIODevice::ReadOnly); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
94 otherListFile.open(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
95 otherListFile.write(other.readAll()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
96 other.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
97 otherListFile.close(); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
98 otherList = CertificateList(otherListFile.fileName().toLocal8Bit().data()); |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
99 |
02df89a275a6
Fix cinstprocesstest testValid with usage of arguments
Andre Heinecke <aheinecke@intevation.de>
parents:
294
diff
changeset
|
100 QVERIFY(!otherList.isValid()); |
306
9c5e6b142611
Set the home directory to a temporary location to avoid writing into real nss stores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
305
diff
changeset
|
101 |
9c5e6b142611
Set the home directory to a temporary location to avoid writing into real nss stores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
305
diff
changeset
|
102 /* Set HOME or APPDATA so that nss stores are not touched |
9c5e6b142611
Set the home directory to a temporary location to avoid writing into real nss stores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
305
diff
changeset
|
103 * see nsstest for the real test of that code */ |
9c5e6b142611
Set the home directory to a temporary location to avoid writing into real nss stores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
305
diff
changeset
|
104 #ifdef WIN32 |
313
f17226aa2e09
Temporary build fix for windows. Also Use putenv in test
Andre Heinecke <aheinecke@intevation.de>
parents:
306
diff
changeset
|
105 { |
314
5e4ae994a320
Make buffer size for fakeHome environment variable dynamic.
Andre Heinecke <aheinecke@intevation.de>
parents:
313
diff
changeset
|
106 char buf[fakeHome.path().toLocal8Bit().size() + 9]; |
5e4ae994a320
Make buffer size for fakeHome environment variable dynamic.
Andre Heinecke <aheinecke@intevation.de>
parents:
313
diff
changeset
|
107 snprintf(buf, fakeHome.path().toLocal8Bit().size() + 9, |
5e4ae994a320
Make buffer size for fakeHome environment variable dynamic.
Andre Heinecke <aheinecke@intevation.de>
parents:
313
diff
changeset
|
108 "APPDATA=%s",fakeHome.path().toLocal8Bit().constData()); |
313
f17226aa2e09
Temporary build fix for windows. Also Use putenv in test
Andre Heinecke <aheinecke@intevation.de>
parents:
306
diff
changeset
|
109 QVERIFY(_putenv (buf) != -1); |
f17226aa2e09
Temporary build fix for windows. Also Use putenv in test
Andre Heinecke <aheinecke@intevation.de>
parents:
306
diff
changeset
|
110 } |
306
9c5e6b142611
Set the home directory to a temporary location to avoid writing into real nss stores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
305
diff
changeset
|
111 #else |
9c5e6b142611
Set the home directory to a temporary location to avoid writing into real nss stores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
305
diff
changeset
|
112 QVERIFY(!setenv ("HOME", fakeHome.path().toLocal8Bit().constData(), 1)); |
9c5e6b142611
Set the home directory to a temporary location to avoid writing into real nss stores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
305
diff
changeset
|
113 #endif |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
114 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
115 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
116 void CinstProcessTest::testNoList() { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
117 /* No list */ |
296 | 118 QTemporaryFile emptyFile; |
119 emptyFile.open(); | |
120 emptyFile.close(); | |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
121 |
296 | 122 QStringList args; |
123 args << "list=" + emptyFile.fileName(); | |
124 | |
125 QTemporaryFile instructions; | |
126 instructions.open(); | |
249
6a7eb102716d
Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents:
159
diff
changeset
|
127 foreach (const Certificate &cert, validList.getCertificates()) { |
296 | 128 instructions.write(cert.base64Line().toLatin1()); |
129 instructions.write("\n"); | |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
130 } |
296 | 131 instructions.close(); |
132 | |
133 args << "instructions=" + instructions.fileName(); | |
134 | |
135 QProcess* installerProcess = startCinstProcess(args); | |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
136 finishVerify(installerProcess, ERR_INVALID_INPUT_NO_LIST); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
137 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
138 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
139 void CinstProcessTest::testGarbageInput() { |
298
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
140 QStringList args; |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
141 |
298
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
142 QString garbage = getRandomDataFile(21*1024*1024); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
143 args << "list=" + garbage; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
144 |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
145 QTemporaryFile instructions; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
146 instructions.open(); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
147 foreach (const Certificate &cert, validList.getCertificates()) { |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
148 instructions.write(cert.base64Line().toLatin1()); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
149 instructions.write("\n"); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
150 } |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
151 instructions.close(); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
152 |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
153 args << "instructions=" + instructions.fileName(); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
154 |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
155 QProcess* installerProcess = startCinstProcess(args); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
156 /* 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
|
157 finishVerify(installerProcess, ERR_INVALID_INPUT_NO_LIST); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
158 QVERIFY(QFile::remove(garbage)); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
159 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
160 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
161 void CinstProcessTest::testNoInput() { |
298
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
162 QStringList args; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
163 args << "list=foobazbuf"; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
164 args << "instructions=bazbuffoo"; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
165 QProcess* installerProcess; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
166 installerProcess = startCinstProcess(args); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
167 finishVerify(installerProcess, ERR_INVALID_INPUT_NO_LIST); |
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 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
170 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
171 void CinstProcessTest::testNoInstructions() { |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
172 /* No instructions */ |
298
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
173 QTemporaryFile emptyFile; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
174 emptyFile.open(); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
175 emptyFile.close(); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
176 |
298
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
177 QStringList args; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
178 args << "list=" + validListFile.fileName(); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
179 args << "instructions=" + emptyFile.fileName(); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
180 |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
181 QProcess* installerProcess = startCinstProcess(args); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
182 finishVerify(installerProcess, ERR_NO_INSTRUCTIONS); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
183 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
184 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
185 void CinstProcessTest::testInvalidInstruction() { |
298
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
186 QStringList args; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
187 args << "list=" + validListFile.fileName(); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
188 |
298
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
189 QTemporaryFile instructions; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
190 instructions.open(); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
191 foreach (const Certificate &cert, validList.getCertificates()) { |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
192 instructions.write(cert.base64Line().toLatin1()); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
193 instructions.write("\n"); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
194 } |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
195 instructions.write("I:ABCDEF\n"); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
196 instructions.close(); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
197 |
298
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
198 args << "instructions=" + instructions.fileName(); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
199 |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
200 QProcess* installerProcess = startCinstProcess(args); |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
201 |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
202 finishVerify(installerProcess, ERR_INVALID_INSTRUCTIONS); |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
203 } |
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
204 |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
205 void CinstProcessTest::testUninstall() { |
298
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
206 QStringList args; |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
207 args << "list=" + validListFile.fileName(); |
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
208 args << "instructions=uninstall"; |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
209 |
298
56507c3d5f1e
Adapt remaining cinstprocesstest to new arg pattern
Andre Heinecke <aheinecke@intevation.de>
parents:
296
diff
changeset
|
210 QProcess* installerProcess = startCinstProcess(args); |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
211 |
159
37c9653b8755
Rename NO_ERROR as NO_ERROR is already defined in windows.h
Andre Heinecke <aheinecke@intevation.de>
parents:
151
diff
changeset
|
212 finishVerify(installerProcess, ERR_NO_ERROR); |
151
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
213 } |
0df62decff90
Test if uninstall is handled as instruction
Andre Heinecke <aheinecke@intevation.de>
parents:
150
diff
changeset
|
214 |
100
8fa273791242
Add test for cinstprocess
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
215 QTEST_GUILESS_MAIN (CinstProcessTest); |