VirtualBox

忽略:
時間撮記:
2016-4-11 下午07:08:38 (9 年 以前)
作者:
vboxsync
訊息:

bs3kit: updates :-)

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestFailed.c

    r60311 r60439  
    4040BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput(char ch, void BS3_FAR *pvUser)
    4141{
    42     bool *pfNewLine = (bool *)pvUser;
     42    PBS3TESTFAILEDBUF pBuf = (PBS3TESTFAILEDBUF)pvUser;
    4343
    4444    /*
     
    4848    if (g_fbBs3VMMDevTesting)
    4949    {
    50         if (*pfNewLine && ch != '\0')
     50        if (pBuf->fNewLine && ch != '\0')
    5151            ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, '\n');
     52        pBuf->fNewLine = ch == '\n';
    5253        if (ch != '\n')
    5354            ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, ch);
     
    5758     * Console next.
    5859     */
    59     if (ch != 0)
     60    if (ch != '\0')
    6061    {
    61         Bs3PrintChr(ch);
    62         *pfNewLine = ch == '\n';
     62        BS3_ASSERT(pBuf->cchBuf < RT_ELEMENTS(pBuf->achBuf));
     63        pBuf->achBuf[pBuf->cchBuf++] = ch;
     64
     65        /* Whether to flush the buffer.  We do line flushing here to avoid
     66           dropping too much info when the formatter crashes on bad input. */
     67        if (   pBuf->cchBuf < RT_ELEMENTS(pBuf->achBuf)
     68            && ch != '\n')
     69        {
     70            pBuf->fNewLine = false;
     71            return 1;
     72        }
     73        pBuf->fNewLine = '\n';
    6374    }
    64     /* We're called with '\0' to indicate end-of-string. Supply trailing
    65        newline if necessary. */
    66     else if (!*pfNewLine)
     75    /* Try fit missing newline into the buffer. */
     76    else if (!pBuf->fNewLine && pBuf->cchBuf < RT_ELEMENTS(pBuf->achBuf))
     77    {
     78        pBuf->fNewLine = true;
     79        pBuf->achBuf[pBuf->cchBuf++] = '\n';
     80    }
     81
     82    BS3_ASSERT(pBuf->cchBuf <= RT_ELEMENTS(pBuf->achBuf));
     83    Bs3PrintStrN(&pBuf->achBuf[0], pBuf->cchBuf);
     84    pBuf->cchBuf = 0;
     85
     86    /* In case we failed to add trailing new line, print one separately.  */
     87    if (!pBuf->fNewLine)
    6788        Bs3PrintChr('\n');
    6889
    69     return 1;
     90    return ch != '\0';
    7091}
    7192
     
    7697BS3_DECL(void) Bs3TestFailedV(const char *pszFormat, va_list va)
    7798{
    78     bool fNewLine;
     99    BS3TESTFAILEDBUF Buf;
    79100
    80101    if (!++g_cusBs3TestErrors)
     
    82103
    83104    if (g_fbBs3VMMDevTesting)
     105#if ARCH_BITS == 16
     106        ASMOutU16(VMMDEV_TESTING_IOPORT_CMD, (uint16_t)VMMDEV_TESTING_CMD_FAILED);
     107#else
    84108        ASMOutU32(VMMDEV_TESTING_IOPORT_CMD, VMMDEV_TESTING_CMD_FAILED);
     109#endif
    85110
    86     fNewLine = false;
    87     Bs3StrFormatV(pszFormat, va, bs3TestFailedStrOutput, &fNewLine);
     111    Buf.fNewLine = false;
     112    Buf.cchBuf   = 0;
     113    Bs3StrFormatV(pszFormat, va, bs3TestFailedStrOutput, &Buf);
    88114}
    89115
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette