TestMod_upload.cpp 1.8 KB

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