void cmd_output(const char* fmt, ...) { char text[4096]; char utf8[4096*2]; va_list vl; size_t sz; va_start(vl, fmt); sz = vsnprintf(text, sizeof(text), fmt, vl); va_end(vl); if(is_test_mode() && s_test_input == 0) { if(sz + s_out_len >= sizeof(s_out_messages)) { sz = sizeof(s_out_messages)/sizeof(s_out_messages[0]) - s_out_len - 1; } memcpy(s_out_messages + s_out_len, text, sz); s_out_len += sz; s_out_messages[s_out_len] = 0; } A2UTF8(text, utf8, sizeof(utf8)); log_text("%s", utf8); printf("%s", utf8); }
/** * read_fuse * * @param mask[out] - MDTP efuse value represented by a bitfield. * * @return - negative value for an error, 0 for success. */ static int read_fuse(uint8_t *mask) { if (is_test_mode()) return read_test_fuse(mask); else return read_QFPROM_fuse(mask); }
static char* get_cmd_line(GameContext* pGame, GameEventContext* pEvent, const char* prompt, char* buf, int len) { int mode; RESULT ret; if(is_test_mode()) { // contiue test proc mode = CMD_LINE_MODE_NORMAL; MSG_OUT("%s", prompt); ret = script_test_continue(s_out_messages,s_out_len, buf, len, &mode); if(R_SUCC == ret) { s_out_len = 0; s_out_messages[0] = 0; if(mode == CMD_LINE_MODE_SCRIPT) { if(R_SUCC != cmd_do_script(pGame, pEvent)) { s_test_mode = 0; buf[0] = 0; CMD_OUT(buf); script_test_error(); if(pGame->status != Status_None) { //longjmp(pContext->__jb__, R_EXIT); //pGame->status = Status_GameAbort; luaL_error(get_game_script(), "Run test error!"); } return buf; } } CMD_OUT(buf); return buf; } s_out_len = 0; s_out_messages[0] = 0; // 失败退出测试模式 s_test_mode = 0; buf[0] = 0; CMD_OUT(buf); if(R_CANCEL == ret) { // test finished } else if(pGame->status != Status_None) { //longjmp(pContext->__jb__, R_EXIT); //pGame->status = Status_GameAbort; luaL_error(get_game_script(), "Run test error!"); } return buf; } else { mode = CMD_LINE_MODE_NORMAL; return logic_wait_cmd(prompt, buf, len); } }