// +build ignore #include "takephoto.h" // 检查核心内存分配情况 static char coreBuf[300*1024*1024] = { 0 }; static void coreMemCheck(const char *filename, int line, const char *ptr, int size, void *lpParameter) { sw_log_info("filename:%s line:%d addr:%#p size:%dbytes", filename, line, ptr, size); } // 主函数入口, 测试拍照 int main(int argc,char *argv[]) { int ret = 0; unsigned long stime, wtime, etime; char filename[MAX_PATH_CHARS] = { 0 }; int timeout = 5*60; if(!sw_heap_init(coreBuf, sizeof(coreBuf), 4)) goto end_p; if(GetSysUsbfsMemCurrentSize() < 200) ret = SetSysUsbfsMemSize(200); if(0 != ret) { sw_log_error("Failed to set system usbfs's memory size, ret=%d!!", ret); goto end_p; } sw_log_info("Photo taking..."); for(int i = 0; i < 9; i++) { sprintf(filename, "./test%d.jpg", i+1); xgettickcount(&stime); ret = TakePhoto(IMG_TYPE_JPG, filename, timeout, NULL); xgettickcount(&etime); wtime = etime - stime; if(0 == ret) sw_log_info("+++ Take a photo: \"%s\", time: %lums +++", filename, wtime); else sw_log_error("+++ Failed to take a photo, ret=%d, time: %lums!! +++", ret, wtime); } end_p: sw_log_info("Memory leak check:"); sw_heap_check(coreMemCheck, NULL); // 内存泄露检查 sw_heap_exit(); return 0; }