TestMod_upload.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #include "mod_upload.h"
  2. #include "upload.h"
  3. #include "XZipZilb.h"
  4. #include "fileutil.h"
  5. //TEST_CASE_ENTITY_CLASS(CUploadEntity, "upload_create")
  6. //{
  7. // LOG_FUNCTION();
  8. //
  9. // struct list_head m_updir_list;//文件夹配置列表
  10. // INIT_LIST_HEAD(&m_updir_list);
  11. // CSimpleStringA checkStr = "";
  12. // CSmartPointer<IConfigInfo> spConfig;
  13. // this->GetFunction()->OpenConfig(Config_Software, spConfig);
  14. // ErrorCodeEnum Error = (ErrorCodeEnum)upload_create(&m_updir_list, this->GetFunction().GetRawPointer(), spConfig.GetRawPointer(), checkStr);
  15. // if (Error == Error_Succeed) {
  16. // Dbg("upload_create is success");
  17. // }
  18. // return Error;
  19. //}
  20. TEST_CASE_ENTITY_CLASS(CUploadEntity, "upload_fresh")
  21. {
  22. LOG_FUNCTION();
  23. struct list_head m_updir_list;//文件夹配置列表
  24. INIT_LIST_HEAD(&m_updir_list);
  25. CSimpleStringA checkStr = "";
  26. CSmartPointer<IConfigInfo> spConfig;
  27. this->GetFunction()->OpenConfig(Config_Software, spConfig);
  28. ErrorCodeEnum Error = (ErrorCodeEnum)upload_create(&m_updir_list, this->GetFunction().GetRawPointer(), spConfig.GetRawPointer(), checkStr);
  29. if (Error == Error_Succeed) {
  30. Dbg("upload_create is success");
  31. upload_fresh(&m_updir_list);
  32. }
  33. return Error;
  34. }
  35. #ifdef RVC_OS_WIN
  36. TEST_CASE_ENTITY_CLASS(CUploadEntity, "ZipData")
  37. {
  38. LOG_FUNCTION();
  39. string fileZipName = "c:\\testZip&650000000.zip";
  40. string destFile = "c:\\20201010.log";
  41. if (!ExistsFileA(destFile.c_str())) {
  42. FILE* f = fopen(destFile.c_str(), "wb");
  43. if (f != NULL) {
  44. string wStr = "test zip file";
  45. fwrite(wStr.c_str(), wStr.length(), 1, f);
  46. fclose(f);
  47. }
  48. else {
  49. Dbg("createFile fail");
  50. return Error_Exception;
  51. }
  52. }
  53. if (ZipData(fileZipName.c_str(), destFile.c_str())) {
  54. return Error_Succeed;
  55. }
  56. else {
  57. return Error_Exception;
  58. }
  59. }
  60. #else
  61. TEST_CASE_ENTITY_CLASS(CUploadEntity, "CreateZipFromFile")
  62. {
  63. LOG_FUNCTION();
  64. string fileZipName = "/opt/rvc/testZip&650000000.zip";
  65. string destFile = "/opt/rvc/20201010.log";
  66. if (!ExistsFileA(destFile.c_str())) {
  67. FILE* f = fopen(destFile.c_str(), "wb");
  68. if (f != NULL) {
  69. string wStr = "test zip file";
  70. fwrite(wStr.c_str(), wStr.length(), 1, f);
  71. fclose(f);
  72. }
  73. else {
  74. Dbg("createFile fail");
  75. return Error_Exception;
  76. }
  77. }
  78. if (CreateZipFromFile(destFile, fileZipName)) {
  79. return Error_Succeed;
  80. }
  81. else {
  82. return Error_Exception;
  83. }
  84. }
  85. #endif // RVC_OS_WIN