annotate ui/tests/common.cpp @ 359:f6ce186cebc2

If DO_RELEASE_BUILD is set use pubkey-release and test with it This currently fails because polarssl rejects keys with a public exponent larger then 64 bit. With the following patch all tests pass. But this currently awaits upstream comment. https://polarssl.org/discussions/bug-report-issues/rsa-keys-with-large-public-exponents-are-rejected --- rsa.c.orig 2014-04-10 17:22:32.727290031 +0200 +++ rsa.c 2014-04-10 17:22:38.847410225 +0200 @@ -154,7 +154,7 @@ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED ); if( mpi_msb( &ctx->E ) < 2 || - mpi_msb( &ctx->E ) > 64 ) + mpi_msb( &ctx->E ) > POLARSSL_MPI_MAX_BITS ) return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED ); return( 0 );
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 10 Apr 2014 17:50:44 +0200
parents c05e126b0b9e
children 17e1c8f37d72
rev   line source
240
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1 #include <QString>
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
2 #include <QTemporaryFile>
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 #include <QDebug>
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
4 #include "common.h"
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 QString getRandomDataFile(size_t size, const QDir &inDir)
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7 {
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8 QTemporaryFile *tmpfile;
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9 if (inDir != QDir()) {
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
10 tmpfile = new QTemporaryFile(inDir.path() + "/downloadertest");
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
11 } else {
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12 tmpfile = new QTemporaryFile();
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13 }
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 tmpfile->setAutoRemove(false);
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15 tmpfile->open();
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 size_t bufsize = 1024 * 1024;
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17 if (bufsize > size) {
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18 bufsize = size;
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 }
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 char buf[bufsize];
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22 for (size_t i = 0; i < bufsize; i++) {
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23 buf[i] = (char) qrand() % 255;
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24 }
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26 size_t bytesWritten=0;
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
27 int retval = 0;
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28 do {
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29 size_t toWrite = size - bytesWritten;
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30 if (toWrite < bufsize) {
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 retval = tmpfile->write(buf, toWrite);
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32 } else {
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33 retval = tmpfile->write(buf, bufsize);
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 }
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 bytesWritten += retval;
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 } while (retval != -1 && bytesWritten < size);
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38 tmpfile->close();
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39 QString ret = tmpfile->fileName();
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40 delete tmpfile;
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 return ret;
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42 }

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