Changeset 925


Ignore:
Timestamp:
Aug 1, 2011, 1:20:02 PM (9 years ago)
Author:
Dmitry A. Kuminov
Message:

tests/process: Added stderr load test.

Location:
tests/process/process-sync
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/process/process-sync/process-sync-test.cmd

    r915 r925  
    2020  /* run */
    2121  '@del bigfile.txt.out 1>nul 2>nul'
    22   'process-sync.exe read bigfile.txt'
     22  'process-sync.exe read_out bigfile.txt'
    2323  /* compare results */
    2424  'comp bigfile.txt bigfile.txt.out < n'
     25  if (rc \= 0) then do
     26    say 'ERROR: rc = 'rc' (i = 'i')'
     27    signal done
     28  end
     29end
     30
     31do i = 1 to 100
     32  /* run */
     33  '@del bigfile.txt.err 1>nul 2>nul'
     34  'process-sync.exe read_err bigfile.txt'
     35  /* compare results */
     36  'comp bigfile.txt bigfile.txt.err < n'
    2537  if (rc \= 0) then do
    2638    say 'ERROR: rc = 'rc' (i = 'i')'
  • tests/process/process-sync/process-sync.cpp

    r914 r925  
    5757}
    5858
    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";
     59int 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;
    6668    QProcess p;
    6769    QFile f (aOutFile);
    6870
     71    p.setReadChannel (aToStdErr ? QProcess::StandardError :
     72                                  QProcess::StandardOutput);
     73
    6974    if (f.open (QIODevice::WriteOnly))
    7075    {
    7176        p.start ("child",
    72                  QStringList() << "1" << aFile,
     77                 QStringList() << (aToStdErr ? "2" : "1") << aFile,
    7378                 QIODevice::ReadOnly);
    7479
     
    207212    if (argc == 3)
    208213    {
    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)
    212219                return test_write(QLatin1String (argv [2]));
    213220        }
     
    225232    }
    226233
    227     printf ("Usage: testcase read|write <filename>\n"
     234    printf ("Usage: testcase read_out|read_err|write <filename>\n"
    228235            "       testcase sleep|hang\n");
    229236
Note: See TracChangeset for help on using the changeset viewer.