Test command parser.
286{
289 CHAR FilePath[MAX_PATH] = {0};
290 UINT32 FailedTokenNum = 0;
291 UINT32 FailedTokenPosition = 0;
292
293
294
295
296
298 {
299
300
301
302 cout << "[-] Could not find the test case files" << endl;
304 }
305
306
307
308
310
311
312
313
314 cout << "Perform testing test cases with parsed file:" << endl;
315
316
317
318
319 for (
const auto &
TestCase : TestCases)
320 {
321 TestNum++;
322
323
324
325
327
328
329
330
333 TestCaseArray,
334 &FailedTokenNum,
335 &FailedTokenPosition))
336 {
337 cout << "[+] Test number " << TestNum << " Passed " << endl;
338 }
339 else
340 {
341
342
343
344 OverallResult =
FALSE;
345
346
347
348
349 cout << "\n============================================================" << endl;
350 cout << "\n********************* " << endl;
351 cout << "*** Error details *** " << endl;
352 cout << "********************* " << endl;
353 cout << "\nParsed tokens from HyperDbg main command parser:\n"
354 << endl;
355
356
357
358
360
361 cout << "\n============================================================" << endl;
362
363 cout << "\nThe parsed command and tokens (From file):" << endl;
365
366 cout << "\n[-] Test number " << TestNum << " Failed " << endl;
367 cout << "============================================================\n"
368 << endl;
369
370 break;
371 }
372
373
374
375
377 }
378
379 return OverallResult;
380}
#define COMMAND_PARSER_TEST_CASES_FILE
Test cases file name for command parser.
Definition Definition.h:70
IMPORT_EXPORT_LIBHYPERDBG VOID hyperdbg_u_test_command_parser_show_tokens(CHAR *command)
Parse and show tokens for the command (used for testing purposes).
Definition export.cpp:237
IMPORT_EXPORT_LIBHYPERDBG BOOLEAN hyperdbg_u_test_command_parser(CHAR *command, UINT32 number_of_tokens, CHAR **tokens_list, UINT32 *failed_token_num, UINT32 *failed_token_position)
Parse the command (used for testing purposes).
Definition export.cpp:220
IMPORT_EXPORT_LIBHYPERDBG BOOLEAN hyperdbg_u_setup_path_for_filename(const CHAR *filename, CHAR *file_location, UINT32 buffer_len, BOOLEAN check_file_existence)
Setip the path for the filename.
Definition export.cpp:725
std::vector< std::pair< std::string, std::vector< std::string > > > ParseTestCases(const std::string &Filename)
Parse the test cases from the file.
Definition test-parser.cpp:78
VOID FreeTestCaseArray(CHAR_PTR_PTR TestCaseArray, SIZE_T Size)
Free the memory allocated for the test case array.
Definition test-parser.cpp:55
CHAR_PTR_PTR CreateTestCaseArray(const std::vector< std::string > &TestCases)
Create an array of strings from a vector of strings.
Definition test-parser.cpp:23
VOID ShowParsedCommandAndTokens(const std::pair< std::string, std::vector< std::string > > &TestCase, UINT32 FailedTokenNum, UINT32 FailedTokenPosition)
Show parsed command and tokens.
Definition test-parser.cpp:214