ReactOS 0.4.16-dev-401-g45b008d
CJournaledTestList Class Reference

#include <CJournaledTestList.h>

Inheritance diagram for CJournaledTestList:
Collaboration diagram for CJournaledTestList:

Public Member Functions

 CJournaledTestList (CTest *Test)
 
 ~CJournaledTestList ()
 
CTestInfoGetNextTestInfo ()
 
virtual CTestInfoGetNextTestInfo ()=0
 

Private Member Functions

void LoadJournalFile ()
 
void OpenJournal (DWORD DesiredAccess, bool CreateNew=false)
 
void SerializeIntoJournal (const string &String)
 
void SerializeIntoJournal (const wstring &String)
 
void UnserializeFromBuffer (char **Buffer, string &Output)
 
void UnserializeFromBuffer (char **Buffer, wstring &Output)
 
void UpdateJournal ()
 
void WriteInitialJournalFile ()
 

Private Attributes

HANDLE m_hJournal
 
size_t m_ListIterator
 
vector< CTestInfom_List
 
wstring m_JournalFile
 

Additional Inherited Members

- Protected Member Functions inherited from CTestList
 CTestList (CTest *Test)
 
- Protected Attributes inherited from CTestList
CTestm_Test
 

Detailed Description

Definition at line 8 of file CJournaledTestList.h.

Constructor & Destructor Documentation

◆ CJournaledTestList()

CJournaledTestList::CJournaledTestList ( CTest Test)

Constructs a CJournaledTestList object for an associated CTest-derived object.

Parameters
TestPointer to a CTest-derived object, for which this test list shall serve.

Definition at line 19 of file CJournaledTestList.cpp.

21{
22 WCHAR JournalFile[MAX_PATH];
23
25
26 /* Build the path to the journal file */
28 FATAL("SHGetFolderPathW failed\n");
29
30 m_JournalFile = JournalFile;
31 m_JournalFile += L"\\rosautotest\\";
32
33 /* Create the directory if necessary */
36
38
39 /* Check if the journal already exists */
42 else
44}
static const WCHAR szJournalFileName[]
#define NULL
Definition: types.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2589
#define S_OK
Definition: intsafe.h:52
#define FATAL(Message)
Definition: precomp.h:57
#define L(x)
Definition: ntvdm.h:50
@ SHGFP_TYPE_CURRENT
Definition: shlobj.h:2149
#define CSIDL_APPDATA
Definition: shlobj.h:2198
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ ~CJournaledTestList()

CJournaledTestList::~CJournaledTestList ( )

Destructs a CJournaledTestList object.

Definition at line 49 of file CJournaledTestList.cpp.

50{
53}
#define CloseHandle
Definition: compat.h:739

Member Function Documentation

◆ GetNextTestInfo()

CTestInfo * CJournaledTestList::GetNextTestInfo ( )
virtual

Interface to other classes for receiving information about the next test to be run.

Returns
A pointer to a CTestInfo object, which contains all available information about the next test. The caller needs to free that object.

Implements CTestList.

Definition at line 276 of file CJournaledTestList.cpp.

277{
278 CTestInfo* TestInfo;
279
280 /* Always jump to the next test here.
281 - If we're at the beginning of a new test list, the iterator will be set to 0.
282 - If we started with a loaded one, we assume that the test m_ListIterator is currently set
283 to crashed, so we move to the next test. */
285
286 /* Check whether the iterator would already exceed the number of stored elements */
287 if(m_ListIterator == m_List.size())
288 {
289 /* Delete the journal and return no pointer */
290 DeleteFileW(m_JournalFile.c_str());
291
292 TestInfo = NULL;
293 }
294 else
295 {
296 /* Update the journal with the current iterator and return the test information */
298
299 TestInfo = new CTestInfo(m_List[m_ListIterator]);
300 }
301
302 return TestInfo;
303}
vector< CTestInfo > m_List
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
size_type size() const
Definition: _vector.h:192

◆ LoadJournalFile()

void CJournaledTestList::LoadJournalFile ( )
private

Loads the existing journal file and sets all members to the values saved in that file.

Definition at line 195 of file CJournaledTestList.cpp.

196{
197 char* Buffer;
198 char* pBuffer;
199 char FileHeader[sizeof(szJournalHeader)];
201 DWORD RemainingSize;
202
203 StringOut("Loading journal file...\n\n");
204
206 RemainingSize = GetFileSize(m_hJournal, NULL);
207
208 /* Verify the header of the journal file */
209 ReadFile(m_hJournal, FileHeader, sizeof(szJournalHeader), &BytesRead, NULL);
210 RemainingSize -= BytesRead;
211
212 if(BytesRead != sizeof(szJournalHeader))
213 EXCEPTION("Journal file contains no header!\n");
214
215 if(strcmp(FileHeader, szJournalHeader))
216 EXCEPTION("Journal file has an unsupported header!\n");
217
218 /* Read the iterator */
220 RemainingSize -= BytesRead;
221
222 if(BytesRead != sizeof(m_ListIterator))
223 EXCEPTION("Journal file contains no m_ListIterator member!\n");
224
225 /* Read the rest of the file into a buffer */
226 Buffer = new char[RemainingSize];
227 pBuffer = Buffer;
228 ReadFile(m_hJournal, Buffer, RemainingSize, &BytesRead, NULL);
229
232
233 /* Now recreate the m_List vector out of that information */
234 while(*pBuffer)
235 {
236 CTestInfo TestInfo;
237
241
242 m_List.push_back(TestInfo);
243 }
244
245 delete[] Buffer;
246}
static const char szJournalHeader[]
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
Definition: bufpool.h:45
void UnserializeFromBuffer(char **Buffer, string &Output)
void OpenJournal(DWORD DesiredAccess, bool CreateNew=false)
wstring CommandLine
Definition: CTestInfo.h:11
string Module
Definition: CTestInfo.h:12
string Test
Definition: CTestInfo.h:13
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define GENERIC_READ
Definition: compat.h:135
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
unsigned long DWORD
Definition: ntddk_ex.h:95
string StringOut(const string &String, bool forcePrint=true)
Definition: tools.cpp:96
#define EXCEPTION(Message)
Definition: precomp.h:56
PVOID pBuffer
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:379
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

Referenced by CJournaledTestList().

◆ OpenJournal()

void CJournaledTestList::OpenJournal ( DWORD  DesiredAccess,
bool  CreateNew = false 
)
private

Opens the journal file through the CreateFileW API using the m_hJournal handle.

Parameters
DesiredAccessdwDesiredAccess parameter passed to CreateFileW
CreateNewtrue if the journal file shall be created, false if an existing one shall be opened

Definition at line 65 of file CJournaledTestList.cpp.

66{
68 m_JournalFile.c_str(),
70 0,
71 NULL,
72 (CreateNew ? CREATE_ALWAYS : OPEN_EXISTING),
74 NULL
75 );
76
78 FATAL("CreateFileW failed\n");
79}
#define OPEN_EXISTING
Definition: compat.h:775
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_FLAG_WRITE_THROUGH
Definition: disk.h:47
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658

Referenced by LoadJournalFile(), UpdateJournal(), and WriteInitialJournalFile().

◆ SerializeIntoJournal() [1/2]

void CJournaledTestList::SerializeIntoJournal ( const string String)
private

Serializes a std::string and writes it into the opened journal file.

Parameters
StringThe std::string to serialize
See also
UnserializeFromBuffer

Definition at line 90 of file CJournaledTestList.cpp.

91{
93 WriteFile(m_hJournal, String.c_str(), (ULONG)String.size() + 1, &BytesWritten, NULL);
95}
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960

Referenced by WriteInitialJournalFile().

◆ SerializeIntoJournal() [2/2]

void CJournaledTestList::SerializeIntoJournal ( const wstring &  String)
private

Serializes a std::wstring and writes it into the opened journal file.

Parameters
StringThe std::wstring to serialize
See also
UnserializeFromBuffer

Definition at line 106 of file CJournaledTestList.cpp.

107{
109 WriteFile(m_hJournal, String.c_str(), ((ULONG)String.size() + 1) * sizeof(WCHAR), &BytesWritten, NULL);
111}

◆ UnserializeFromBuffer() [1/2]

void CJournaledTestList::UnserializeFromBuffer ( char **  Buffer,
string Output 
)
private

Unserializes the next std::string from the journal buffer. The passed buffer pointer will point at the next element afterwards.

Parameters
BufferPointer to a pointer to a char array containing the journal buffer
OutputThe std::string to unserialize the value into.

Definition at line 124 of file CJournaledTestList.cpp.

Referenced by LoadJournalFile().

◆ UnserializeFromBuffer() [2/2]

void CJournaledTestList::UnserializeFromBuffer ( char **  Buffer,
wstring &  Output 
)
private

Unserializes the next std::wstring from the journal buffer. The passed buffer pointer will point at the next element afterwards.

Parameters
BufferPointer to a pointer to a char array containing the journal buffer
OutputThe std::wstring to unserialize the value into.

Definition at line 141 of file CJournaledTestList.cpp.

142{
143 Output = wstring((PWSTR)*Buffer);
144 *Buffer += (Output.size() + 1) * sizeof(WCHAR);
145}
uint16_t * PWSTR
Definition: typedefs.h:56

◆ UpdateJournal()

void CJournaledTestList::UpdateJournal ( )
private

Writes the current m_ListIterator value into the journal.

Definition at line 252 of file CJournaledTestList.cpp.

253{
255
257
258 /* Skip the header */
260
263
266}
#define SetFilePointer
Definition: compat.h:743
#define GENERIC_WRITE
Definition: nt_native.h:90
#define FILE_CURRENT
Definition: winbase.h:114

Referenced by GetNextTestInfo().

◆ WriteInitialJournalFile()

void CJournaledTestList::WriteInitialJournalFile ( )
private

Gets all tests to be run and writes an initial journal file with this information.

Definition at line 151 of file CJournaledTestList.cpp.

152{
153 char TerminatingNull = 0;
154 CTestInfo* TestInfo;
156
157 StringOut("Writing initial journal file...\n\n");
158
159 m_ListIterator = 0;
160
161 /* Store all command lines in the m_List vector */
162 while((TestInfo = m_Test->GetNextTestInfo()) != 0)
163 {
164 m_List.push_back(*TestInfo);
165 delete TestInfo;
166 }
167
168 /* Serialize the vector and the iterator into a file */
170
173
174 for(size_t i = 0; i < m_List.size(); i++)
175 {
176 SerializeIntoJournal(m_List[i].CommandLine);
179 }
180
181 WriteFile(m_hJournal, &TerminatingNull, sizeof(TerminatingNull), &BytesWritten, NULL);
183
186
187 /* m_ListIterator will be incremented before its first use */
189}
void SerializeIntoJournal(const string &String)
CTest * m_Test
Definition: CTestList.h:11
virtual CTestInfo * GetNextTestInfo()=0
__kernel_size_t size_t
Definition: linux.h:237
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by CJournaledTestList().

Member Data Documentation

◆ m_hJournal

◆ m_JournalFile

wstring CJournaledTestList::m_JournalFile
private

Definition at line 14 of file CJournaledTestList.h.

Referenced by CJournaledTestList(), GetNextTestInfo(), and OpenJournal().

◆ m_List

vector<CTestInfo> CJournaledTestList::m_List
private

Definition at line 13 of file CJournaledTestList.h.

Referenced by GetNextTestInfo(), LoadJournalFile(), and WriteInitialJournalFile().

◆ m_ListIterator

size_t CJournaledTestList::m_ListIterator
private

The documentation for this class was generated from the following files: