takephoto_test.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // +build ignore
  2. #include "takephoto.h"
  3. // 检查核心内存分配情况
  4. static char coreBuf[300*1024*1024] = { 0 };
  5. static void coreMemCheck(const char *filename, int line, const char *ptr, int size, void *lpParameter)
  6. {
  7. sw_log_info("filename:%s line:%d addr:%#p size:%dbytes", filename, line, ptr, size);
  8. }
  9. // 主函数入口, 测试拍照
  10. int main(int argc,char *argv[])
  11. {
  12. int ret = 0; unsigned long stime, wtime, etime;
  13. char filename[MAX_PATH_CHARS] = { 0 }; int timeout = 5*60;
  14. if(!sw_heap_init(coreBuf, sizeof(coreBuf), 4)) goto end_p;
  15. if(GetSysUsbfsMemCurrentSize() < 200) ret = SetSysUsbfsMemSize(200);
  16. if(0 != ret)
  17. {
  18. sw_log_error("Failed to set system usbfs's memory size, ret=%d!!", ret);
  19. goto end_p;
  20. }
  21. sw_log_info("Photo taking...");
  22. for(int i = 0; i < 9; i++)
  23. {
  24. sprintf(filename, "test%d.jpg", i+1);
  25. xgettickcount(&stime);
  26. ret = TakePhoto(IMG_TYPE_JPG, filename, timeout, NULL);
  27. xgettickcount(&etime);
  28. wtime = etime - stime;
  29. if(0 == ret) sw_log_info("+++ Take a photo: \"%s\", time: %lums +++", filename, wtime);
  30. else sw_log_error("+++ Failed to take a photo, ret=%d, time: %lums!! +++", ret, wtime);
  31. }
  32. end_p:
  33. sw_log_info("Memory leak check:");
  34. sw_heap_check(coreMemCheck, NULL); // 内存泄露检查
  35. sw_heap_exit();
  36. return 0;
  37. }