TestThread.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "TestThread.h"
  2. #include <iostream>
  3. #include <Datei.h>
  4. #include "Test.h"
  5. using namespace Framework;
  6. TestThread::TestThread()
  7. : Thread()
  8. {
  9. abbruch = 0;
  10. start();
  11. }
  12. void TestThread::abbrechen()
  13. {
  14. abbruch = 1;
  15. }
  16. typedef Test *( *GetTest )( );
  17. void TestThread::thread()
  18. {
  19. Datei d;
  20. d.setDatei( "../Tests/bin" );
  21. RCArray< Text > *files = d.getDateiListe();
  22. int anz = files->getEintragAnzahl();
  23. for( int i = 0; i < anz; i++ )
  24. {
  25. Text *name = files->z( i );
  26. name->insert( 0, "../Tests/bin/" );
  27. HMODULE dll = LoadLibrary( name->getText() );
  28. if( !dll )
  29. std::cerr << "Failed to load Test: " << name->getText() << "\n";
  30. else
  31. {
  32. GetTest createTest = (GetTest)GetProcAddress( dll, "createTest" );
  33. if( !createTest )
  34. std::cerr << "Failed to load 'createTest' entry point: " << name->getText() << "\n";
  35. else
  36. {
  37. Test *t = createTest();
  38. t->init();
  39. while( 1 )
  40. {
  41. t->run();
  42. if( t->failed() )
  43. {
  44. std::cout << "retry or skip (r/s)?\n";
  45. int c;
  46. do
  47. {
  48. c = getchar();
  49. if( c == EOF )
  50. Sleep( 100 );
  51. if( abbruch )
  52. c = 's';
  53. } while( c == EOF );
  54. if( c == 's' )
  55. break;
  56. }
  57. else
  58. break;
  59. t->destroy();
  60. t = createTest();
  61. t->init();
  62. }
  63. if( !t->failed() )
  64. std::cout << "\r0xFF00FF00succsess\n\r0xFFFFFFFF";
  65. t->destroy();
  66. }
  67. FreeLibrary( dll );
  68. }
  69. if( abbruch )
  70. break;
  71. }
  72. files->release();
  73. std::cout << "\r0xFF00FF00tests finished";
  74. }