VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TestFailed.c@ 66112

Last change on this file since 66112 was 64367, checked in by vboxsync, 8 years ago

ValidationKit/Bs3Kit: Doxygen

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: bs3-cmn-TestFailed.c 64367 2016-10-22 17:25:58Z vboxsync $ */
2/** @file
3 * BS3Kit - Bs3TestFailed, Bs3TestFailedF, Bs3TestFailedV.
4 */
5
6/*
7 * Copyright (C) 2007-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include "bs3kit-template-header.h"
32#include "bs3-cmn-test.h"
33#include <iprt/asm-amd64-x86.h>
34
35
36/**
37 * @callback_method_impl{FNBS3STRFORMATOUTPUT,
38 * Used by Bs3TestFailedV and Bs3TestSkippedV.}
39 */
40BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput(char ch, void BS3_FAR *pvUser)
41{
42 PBS3TESTFAILEDBUF pBuf = (PBS3TESTFAILEDBUF)pvUser;
43
44 /*
45 * VMMDev first. We postpone newline processing here so we can strip one
46 * trailing newline.
47 */
48 if (g_fbBs3VMMDevTesting)
49 {
50 if (pBuf->fNewLine && ch != '\0')
51 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, '\n');
52 pBuf->fNewLine = ch == '\n';
53 if (ch != '\n')
54 ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, ch);
55 }
56
57 /*
58 * Console next.
59 */
60 if (ch != '\0')
61 {
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';
74 }
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)
88 Bs3PrintChr('\n');
89
90 return ch != '\0';
91}
92
93
94/**
95 * Equivalent to RTTestIFailedV.
96 */
97#undef Bs3TestFailedV
98BS3_CMN_DEF(void, Bs3TestFailedV,(const char *pszFormat, va_list va))
99{
100 BS3TESTFAILEDBUF Buf;
101
102 if (!++g_cusBs3TestErrors)
103 g_cusBs3TestErrors++;
104
105 if (g_fbBs3VMMDevTesting)
106#if ARCH_BITS == 16
107 ASMOutU16(VMMDEV_TESTING_IOPORT_CMD, (uint16_t)VMMDEV_TESTING_CMD_FAILED);
108#else
109 ASMOutU32(VMMDEV_TESTING_IOPORT_CMD, VMMDEV_TESTING_CMD_FAILED);
110#endif
111
112 Buf.fNewLine = false;
113 Buf.cchBuf = 0;
114 Bs3StrFormatV(pszFormat, va, bs3TestFailedStrOutput, &Buf);
115}
116
117
118/**
119 * Equivalent to RTTestIFailedF.
120 */
121#undef Bs3TestFailedF
122BS3_CMN_DEF(void, Bs3TestFailedF,(const char *pszFormat, ...))
123{
124 va_list va;
125 va_start(va, pszFormat);
126 BS3_CMN_NM(Bs3TestFailedV)(pszFormat, va);
127 va_end(va);
128}
129
130
131/**
132 * Equivalent to RTTestIFailed.
133 */
134#undef Bs3TestFailed
135BS3_CMN_DEF(void, Bs3TestFailed,(const char *pszMessage))
136{
137 BS3_CMN_NM(Bs3TestFailedF)("%s", pszMessage);
138}
139
Note: See TracBrowser for help on using the repository browser.

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