Changeset 925 for tests/process/process-sync/process-sync.cpp
- Timestamp:
- Aug 1, 2011, 3:20:02 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/process/process-sync/process-sync.cpp
r914 r925 57 57 } 58 58 59 int test_read(const QString &aFile) 60 { 61 printf ("test_read: Read '%s' from child's stdout " 62 "and write it to '%s.out'\n", aFile.toLocal8Bit().constData(), 63 aFile.toLocal8Bit().constData()); 64 65 QString aOutFile = aFile + ".out"; 59 int test_read(const QString &aFile, bool aToStdErr) 60 { 61 const char *ext = aToStdErr ? "err" : "out"; 62 63 printf ("test_read: Read '%s' from child's std%s " 64 "and write it to '%s.%s'\n", aFile.toLocal8Bit().constData(), 65 ext, aFile.toLocal8Bit().constData(), ext); 66 67 QString aOutFile = aFile + "." + ext; 66 68 QProcess p; 67 69 QFile f (aOutFile); 68 70 71 p.setReadChannel (aToStdErr ? QProcess::StandardError : 72 QProcess::StandardOutput); 73 69 74 if (f.open (QIODevice::WriteOnly)) 70 75 { 71 76 p.start ("child", 72 QStringList() << "1"<< aFile,77 QStringList() << (aToStdErr ? "2" : "1") << aFile, 73 78 QIODevice::ReadOnly); 74 79 … … 207 212 if (argc == 3) 208 213 { 209 if (qstrcmp (argv [1], "read") == 0) 210 return test_read (QLatin1String (argv [2])); 211 if (qstrcmp (argv [1], "write") == 0) 214 if (qstrcmp (argv [1], "read_out") == 0) 215 return test_read (QLatin1String (argv [2]), false); 216 if (qstrcmp (argv [1], "read_err") == 0) 217 return test_read (QLatin1String (argv [2]), true); 218 if (qstrcmp (argv [1], "write") == 0) 212 219 return test_write(QLatin1String (argv [2])); 213 220 } … … 225 232 } 226 233 227 printf ("Usage: testcase read |write <filename>\n"234 printf ("Usage: testcase read_out|read_err|write <filename>\n" 228 235 " testcase sleep|hang\n"); 229 236
Note:
See TracChangeset
for help on using the changeset viewer.