void test_istream_base64_encoder(void) { unsigned int i; for (i = 0; i < N_ELEMENTS(tests); i++) { test_begin(t_strdup_printf("istream base64 decoder %u", i+1)); encode_test(tests[i].input, tests[i].chars_per_line, tests[i].crlf, tests[i].output); test_end(); } test_begin("istream base64 encoder seek"); test_istream_base64_encoder_seek(hello, "aGVs\r\nbG8g\r\nd29y\r\nbGQ="); test_end(); }
/** main: * * Arguments: * @argc * @argv * * Return: * 0 or -ve values * * Description: * main function * **/ int main(int argc, char* argv[]) { jpeg_test_input_t *p_test_input; int ret = 0; if (argc > 1) { p_test_input = calloc(2, sizeof(*p_test_input)); if (!p_test_input) { CDBG_ERROR("%s:%d] Error",__func__, __LINE__); goto exit; } memcpy(p_test_input, &jpeg_input[0], sizeof(*p_test_input)); ret = mm_jpeg_test_get_input(argc, argv, p_test_input); if (ret) { CDBG_ERROR("%s:%d] Error",__func__, __LINE__); goto exit; } } else { mm_jpeg_test_print_usage(); return 1; } ret = encode_test(p_test_input); exit: if (!ret) { fprintf(stderr, "%-25s\n", "Success!"); } else { fprintf(stderr, "%-25s\n", "Fail!"); } if (argc > 1) { if (p_test_input) { free(p_test_input); p_test_input = NULL; } } return ret; }
main(int argc, char *argv[]) #endif { int err, nargc, i, ret = 0; char *pargv[32] = {0}, *dbg_env; pthread_t sigtid; #ifdef COMMON_INIT vpu_versioninfo ver; #endif int ret_thr; #ifndef COMMON_INIT srand((unsigned)time(0)); /* init seed of rand() */ #endif dbg_env=getenv("VPU_TEST_DBG"); if (dbg_env) vpu_test_dbg_level = atoi(dbg_env); else vpu_test_dbg_level = 0; err = parse_main_args(argc, argv); if (err) { goto usage; } if (!instance) { goto usage; } info_msg("VPU test program built on %s %s\n", __DATE__, __TIME__); #ifndef _FSL_VTS_ sigemptyset(&sigset); sigaddset(&sigset, SIGINT); pthread_sigmask(SIG_BLOCK, &sigset, NULL); pthread_create(&sigtid, NULL, (void *)&signal_thread, NULL); #endif #ifdef COMMON_INIT err = vpu_Init(NULL); if (err) { err_msg("VPU Init Failure.\n"); return -1; } err = vpu_GetVersionInfo(&ver); if (err) { err_msg("Cannot get version info, err:%d\n", err); vpu_UnInit(); return -1; } info_msg("VPU firmware version: %d.%d.%d_r%d\n", ver.fw_major, ver.fw_minor, ver.fw_release, ver.fw_code); info_msg("VPU library version: %d.%d.%d\n", ver.lib_major, ver.lib_minor, ver.lib_release); #else // just to enable cpu_is_xx() to be used in command line parsing err = vpu_Init(NULL); if (err) { err_msg("VPU Init Failure.\n"); return -1; } vpu_UnInit(); #endif if (instance > 1) { for (i = 0; i < instance; i++) { #ifndef COMMON_INIT /* sleep roughly a frame interval to test multi-thread race especially vpu_Init/vpu_UnInit */ usleep((int)(rand()%ONE_FRAME_INTERV)); #endif if (using_config_file == 0) { get_arg(input_arg[i].line, &nargc, pargv); err = parse_args(nargc, pargv, i); if (err) { vpu_UnInit(); goto usage; } } if (check_params(&input_arg[i].cmd, input_arg[i].mode) == 0) { if (open_files(&input_arg[i].cmd) == 0) { if (input_arg[i].mode == DECODE) { pthread_create(&input_arg[i].tid, NULL, (void *)&decode_test, (void *)&input_arg[i].cmd); } else if (input_arg[i].mode == ENCODE) { pthread_create(&input_arg[i].tid, NULL, (void *)&encode_test, (void *)&input_arg[i].cmd); } } } } } else { if (using_config_file == 0) { get_arg(input_arg[0].line, &nargc, pargv); err = parse_args(nargc, pargv, 0); if (err) { vpu_UnInit(); goto usage; } } if (check_params(&input_arg[0].cmd, input_arg[0].mode) == 0) { if (open_files(&input_arg[0].cmd) == 0) { if (input_arg[0].mode == DECODE) { ret = decode_test(&input_arg[0].cmd); } else if (input_arg[0].mode == ENCODE) { ret = encode_test(&input_arg[0].cmd); } else if (input_arg[0].mode == TRANSCODE) { ret = transcode_test(&input_arg[0].cmd); } close_files(&input_arg[0].cmd); } else { ret = -1; } } else { ret = -1; } if (input_arg[0].mode == LOOPBACK) { encdec_test(&input_arg[0].cmd); } } if (instance > 1) { for (i = 0; i < instance; i++) { if (input_arg[i].tid != 0) { pthread_join(input_arg[i].tid, (void *)&ret_thr); if (ret_thr) ret = -1; close_files(&input_arg[i].cmd); } } } #ifdef COMMON_INIT vpu_UnInit(); #endif return ret; usage: info_msg("\n%s", usage); return -1; }