Q_TESTLIB_EXPORT QStringList testFunctions;
Q_TESTLIB_EXPORT QStringList testTags;
-static void qPrintTestSlots()
+static void qPrintTestSlots(FILE *stream)
{
for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) {
QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i);
if (isValidSlot(sl))
- printf("%s\n", sl.signature());
+ fprintf(stream, "%s\n", sl.signature());
}
}
char *pEnd;
int l = (int)strtol(str, &pEnd, 10);
if (*pEnd != 0) {
- printf("Invalid numeric parameter: '%s'\n", str);
+ fprintf(stderr, "Invalid numeric parameter: '%s'\n", str);
exit(1);
}
return l;
if (qml) {
QTest::printAvailableFunctions = true;
} else {
- qPrintTestSlots();
+ qPrintTestSlots(stdout);
exit(0);
}
} else if(strcmp(argv[i], "-xunitxml") == 0){
QSignalDumper::startDump();
} else if (strcmp(argv[i], "-o") == 0) {
if (i + 1 >= argc) {
- printf("-o needs an extra parameter specifying the filename\n");
+ fprintf(stderr, "-o needs an extra parameter specifying the filename\n");
exit(1);
} else {
QTestLog::redirectOutput(argv[++i]);
}
} else if (strcmp(argv[i], "-eventdelay") == 0) {
if (i + 1 >= argc) {
- printf("-eventdelay needs an extra parameter to indicate the delay(ms)\n");
+ fprintf(stderr, "-eventdelay needs an extra parameter to indicate the delay(ms)\n");
exit(1);
} else {
QTest::eventDelay = qToInt(argv[++i]);
}
} else if (strcmp(argv[i], "-keydelay") == 0) {
if (i + 1 >= argc) {
- printf("-keydelay needs an extra parameter to indicate the delay(ms)\n");
+ fprintf(stderr, "-keydelay needs an extra parameter to indicate the delay(ms)\n");
exit(1);
} else {
QTest::keyDelay = qToInt(argv[++i]);
}
} else if (strcmp(argv[i], "-mousedelay") == 0) {
if (i + 1 >= argc) {
- printf("-mousedelay needs an extra parameter to indicate the delay(ms)\n");
+ fprintf(stderr, "-mousedelay needs an extra parameter to indicate the delay(ms)\n");
exit(1);
} else {
QTest::mouseDelay = qToInt(argv[++i]);
}
} else if (strcmp(argv[i], "-maxwarnings") == 0) {
if (i + 1 >= argc) {
- printf("-maxwarnings needs an extra parameter with the amount of warnings\n");
+ fprintf(stderr, "-maxwarnings needs an extra parameter with the amount of warnings\n");
exit(1);
} else {
QTestLog::setMaxWarnings(qToInt(argv[++i]));
if (QFileInfo(QDir::currentPath()).isWritable()) {
QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindParentProcess);
} else {
- printf("WARNING: Current directory not writable. Using the walltime measurer.\n");
+ fprintf(stderr, "WARNING: Current directory not writable. Using the walltime measurer.\n");
}
else {
- printf("WARNING: Valgrind not found or too old. Make sure it is installed and in your path. "
+ fprintf(stderr, "WARNING: Valgrind not found or too old. Make sure it is installed and in your path. "
"Using the walltime measurer.\n");
}
} else if (strcmp(argv[i], "-callgrindchild") == 0) { // "private" option
QTest::seed = longSeed;
}
if (!argumentOk) {
- printf("-seed needs an extra positive integer parameter to specify the seed\n");
+ fprintf(stderr, "-seed needs an extra positive integer parameter to specify the seed\n");
exit(1);
} else {
QTest::seedSet = true;
}
} else if (strcmp(argv[i], "-minimumvalue") == 0) {
if (i + 1 >= argc) {
- printf("-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n");
+ fprintf(stderr, "-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n");
exit(1);
} else {
QBenchmarkGlobalData::current->walltimeMinimum = qToInt(argv[++i]);
}
} else if (strcmp(argv[i], "-iterations") == 0) {
if (i + 1 >= argc) {
- printf("-iterations needs an extra parameter to indicate the number of iterations\n");
+ fprintf(stderr, "-iterations needs an extra parameter to indicate the number of iterations\n");
exit(1);
} else {
QBenchmarkGlobalData::current->iterationCount = qToInt(argv[++i]);
}
} else if (strcmp(argv[i], "-median") == 0) {
if (i + 1 >= argc) {
- printf("-median needs an extra parameter to indicate the number of median iterations\n");
+ fprintf(stderr, "-median needs an extra parameter to indicate the number of median iterations\n");
exit(1);
} else {
QBenchmarkGlobalData::current->medianIterationCount = qToInt(argv[++i]);
} else if (strcmp(argv[i], "-graphicssystem") == 0) {
// do nothing
if (i + 1 >= argc) {
- printf("-graphicssystem needs an extra parameter specifying the graphics system\n");
+ fprintf(stderr, "-graphicssystem needs an extra parameter specifying the graphics system\n");
exit(1);
} else {
++i;
}
} else if (argv[i][0] == '-') {
- printf("Unknown option: '%s'\n\n%s", argv[i], testOptions);
+ fprintf(stderr, "Unknown option: '%s'\n\n%s", argv[i], testOptions);
if (qml) {
- printf ("\nqmltest related options:\n"
- " -import : Specify an import directory.\n"
- " -input : Specify the root directory for test cases.\n"
- " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
- );
+ fprintf(stderr, "\nqmltest related options:\n"
+ " -import : Specify an import directory.\n"
+ " -input : Specify the root directory for test cases.\n"
+ " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
+ );
}
- printf("\n"
- " -help : This help\n");
+ fprintf(stderr, "\n"
+ " -help : This help\n");
exit(1);
} else if (qml) {
// We can't check the availability of test functions until
QTest::qt_snprintf(buf + off, qMin(512 - off, 3), "()"); // append "()"
int idx = QTest::currentTestObject->metaObject()->indexOfMethod(buf);
if (idx < 0 || !isValidSlot(QTest::currentTestObject->metaObject()->method(idx))) {
- printf("Unknown testfunction: '%s'\n", buf);
- printf("Available testfunctions:\n");
- qPrintTestSlots();
+ fprintf(stderr, "Unknown testfunction: '%s'\n", buf);
+ fprintf(stderr, "Available testfunctions:\n");
+ qPrintTestSlots(stderr);
exit(1);
}
testFuncs[testFuncCount].set(idx, data);
}
if (QTest::seedSet && !QTest::randomOrder) {
- printf("-seed requires -random\n");
+ fprintf(stderr, "-seed requires -random\n");
exit(1);
}
}
if (!*data)
data = 0;
else {
- printf("Unknown testdata for function %s: '%s'\n", slotName, data);
- printf("Function has no testdata.\n");
+ fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data);
+ fprintf(stderr, "Function has no testdata.\n");
return false;
}
}
}
if (data && !foundFunction) {
- printf("Unknown testdata for function %s: '%s'\n", slotName, data);
- printf("Available testdata:\n");
+ fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data);
+ fprintf(stderr, "Available testdata:\n");
for(int i = 0; i < table.dataCount(); ++i)
- printf("%s\n", table.testData(i)->dataTag());
+ fprintf(stderr, "%s\n", table.testData(i)->dataTag());
return false;
}