1 | /* $Id: bs3-cmn-TestFailed.c 59865 2016-02-29 10:27:24Z 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 | * @impl_callback_method{FNBS3STRFORMATOUTPUT,
|
---|
38 | * Used by Bs3TestFailedV and Bs3TestSkippedV.}
|
---|
39 | */
|
---|
40 | BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput(char ch, void BS3_FAR *pvUser)
|
---|
41 | {
|
---|
42 | bool *pfNewLine = (bool *)pvUser;
|
---|
43 |
|
---|
44 | /*
|
---|
45 | * VMMDev first.
|
---|
46 | */
|
---|
47 | if (BS3_DATA_NM(g_fbBs3VMMDevTesting))
|
---|
48 | ASMOutU8(VMMDEV_TESTING_IOPORT_DATA, ch);
|
---|
49 |
|
---|
50 | /*
|
---|
51 | * Console next.
|
---|
52 | */
|
---|
53 | if (ch != 0)
|
---|
54 | {
|
---|
55 | if (ch != '\n')
|
---|
56 | {
|
---|
57 | Bs3PrintChr(ch);
|
---|
58 | *pfNewLine = false;
|
---|
59 | }
|
---|
60 | else
|
---|
61 | {
|
---|
62 | Bs3PrintStr("\r\n");
|
---|
63 | *pfNewLine = true;
|
---|
64 | }
|
---|
65 | }
|
---|
66 | /* We're called with '\0' to indicate end-of-string. Supply trailing
|
---|
67 | newline if necessary. */
|
---|
68 | else if (!*pfNewLine)
|
---|
69 | Bs3PrintStr("\r\n");
|
---|
70 |
|
---|
71 | return 1;
|
---|
72 | }
|
---|
73 |
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Equivalent to RTTestIFailedV.
|
---|
77 | */
|
---|
78 | BS3_DECL(void) Bs3TestFailedV(const char *pszFormat, va_list va)
|
---|
79 | {
|
---|
80 | bool fNewLine;
|
---|
81 |
|
---|
82 | if (!++BS3_DATA_NM(g_cusBs3TestErrors))
|
---|
83 | BS3_DATA_NM(g_cusBs3TestErrors)++;
|
---|
84 |
|
---|
85 | if (BS3_DATA_NM(g_fbBs3VMMDevTesting))
|
---|
86 | ASMOutU32(VMMDEV_TESTING_IOPORT_CMD, VMMDEV_TESTING_CMD_FAILED);
|
---|
87 |
|
---|
88 | fNewLine = false;
|
---|
89 | Bs3StrFormatV(pszFormat, va, bs3TestFailedStrOutput, &fNewLine);
|
---|
90 | }
|
---|
91 |
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Equivalent to RTTestIFailedF.
|
---|
95 | */
|
---|
96 | BS3_DECL(void) Bs3TestFailedF(const char *pszFormat, ...)
|
---|
97 | {
|
---|
98 | va_list va;
|
---|
99 | va_start(va, pszFormat);
|
---|
100 | Bs3TestFailedV(pszFormat, va);
|
---|
101 | va_end(va);
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | /**
|
---|
106 | * Equivalent to RTTestIFailed.
|
---|
107 | */
|
---|
108 | BS3_DECL(void) Bs3TestFailed(const char *pszMessage)
|
---|
109 | {
|
---|
110 | Bs3TestFailedF("%s", pszMessage);
|
---|
111 | }
|
---|
112 |
|
---|