From e3b63e777bf7cddee516ada883cfdd0cefb73dfa Mon Sep 17 00:00:00 2001 From: N2614 Date: Thu, 19 Jan 2012 11:08:07 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=97=E3=83=AA=E3=82=A4=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=83=BC=E3=83=AB=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB?= =?UTF-8?q?=E3=82=92=E3=83=AA=E3=82=B9=E3=83=88=E3=82=A2=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=81=A8=E3=81=93=E3=82=8D=E3=81=BE=E3=81=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@584 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../ConsoleRestore/BgsCommunicator.cpp | 8 +- .../sources/ConsoleRestore/BgsCommunicator.h | 6 +- .../BgsCommunicator/test_BgsCommunicator.cpp | 3 +- .../PreinstallImporter/OMakefile | 68 ++++++++++ .../test_PreinstallImporter.cpp | 118 ++++++++++++++++++ 5 files changed, 194 insertions(+), 9 deletions(-) create mode 100644 trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/OMakefile create mode 100644 trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/test_PreinstallImporter.cpp diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp index 6e87da2..3c33ab8 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.cpp @@ -265,7 +265,7 @@ bool BgsCommunicator::Execute(const void* buf, size_t size) return true; } -size_t BgsCommunicator::GetBodySize() +bool BgsCommunicator::GetBodySize(size_t* size) { //HTTPヘッダの情報読み出し s32 statusCode = 0; @@ -278,10 +278,10 @@ size_t BgsCommunicator::GetBodySize() u32 fieldLen = sizeof(headerFields); m_Result = m_HttpCon.GetHeaderField("Content-Length", headerFields, fieldLen, &fieldLen); //特定のヘッダフィールドをラベルから取得 COMMON_LOGGER_RETURN_FALSE_IF_FAILED(m_Result); - m_BodySize = std::strtol(headerFields, NULL, 10); - NN_LOG("---HTTP Content-Length = %d---\n", m_BodySize); + *size = std::strtol(headerFields, NULL, 10); + NN_LOG("---HTTP Content-Length = %d---\n", *size); - return m_BodySize; + return true; } bool BgsCommunicator::GetBody(u8 *buf, size_t size) diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.h b/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.h index 40bcc9d..209baa1 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.h +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/BgsCommunicator.h @@ -33,7 +33,8 @@ public: bool Execute(const void* buf, size_t size); //! @brief 通信結果のサイズを取得します - size_t GetBodySize(); + //! @param[out] 通信結果を取得するのに必要なバッファサイズ + bool GetBodySize(size_t* size); //! @brief 通信結果をバッファに書き込みます。正しく結果を取得するには GetBodySizeで取得したサイズのバッファが必要です。 //! @param[out] buf 通信結果を書き込むバッファ @@ -47,9 +48,6 @@ public: private: nn::Result m_Result; - //! @brief HTTPレスポンスのサイズ - size_t m_BodySize; - //Connectionインスタンス nn::http::Connection m_HttpCon; }; diff --git a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/BgsCommunicator/test_BgsCommunicator.cpp b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/BgsCommunicator/test_BgsCommunicator.cpp index 434ea62..256f232 100644 --- a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/BgsCommunicator/test_BgsCommunicator.cpp +++ b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/BgsCommunicator/test_BgsCommunicator.cpp @@ -124,7 +124,8 @@ void BgsCommunicatorTest::Exec() xml.Exec(17179924184, reinterpret_cast(const_cast("EJA20305940"))); comm.Execute(xml.GetData().c_str(), xml.GetData().size()); - size_t bufSize = comm.GetBodySize(); + size_t bufSize; + comm.GetBodySize(&bufSize); common::HeapManager heap(bufSize); void* buf = heap.GetAddr(); comm.GetBody(reinterpret_cast(buf), bufSize); diff --git a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/OMakefile b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/OMakefile new file mode 100644 index 0000000..607b84b --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/OMakefile @@ -0,0 +1,68 @@ +#!/usr/bin/env omake +#---------------------------------------------------------------------------- +# Project: Horizon +# File: OMakefile +# +# Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Rev$ +#---------------------------------------------------------------------------- +SUPPORTED_TARGETS = CTR-*.Process.MPCore.* + +include $(makePlatformDefsPath tests) + +SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir $(HORIZON_ROOT)/../CTR/SampleDemos/common/include) +INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) \ + ../../../common \ + ../../../ConsoleRestore \ + + + +TEST_COMMON_SOURCES[] = + ../../../ConsoleRestore/Shop.cpp + ../../../ConsoleRestore/XmlCreator.cpp + ../../../ConsoleRestore/SimpleXmlPreprocessor.cpp + ../../../ConsoleRestore/BgsCommunicator.cpp + ../../../ConsoleRestore/PreinstallImporter.cpp + ../../../common/Util.cpp + ../../../common/HeapManager.cpp + ../../../common/SdLogger.cpp + ../../../common/LogConsole.cpp + ../../../common/CommonLogger.cpp + ../../../common/SdMountManager.cpp + ../../../common/VersionDetect.cpp + ../../../common/HardwareStateManager.cpp + ../../../common/FileTransfer.cpp + ../../../common/SdReaderWriter.cpp + +CCFLAGS += -DCOMMON_LOGGER_DETAIL_ENABLE + +SOURCES_TEST[] = test_PreinstallImporter.cpp + +ROMFS_ROOT = ../../../common/romfiles + +TEST_ENVIRONMENT_PROCESSLIST = true +TEST_ENVIRONMENT_EMUMEM = true + +LIBS += libnn_test \ + libnn_mcu \ + libnn_ps \ + libnn_am \ + lib_demo \ + libnn_nim \ + libnn_xml_simple \ + +ROM_SPEC_FILE = ../../../ConsoleRestore/ConsoleRestore.rsf +DESCRIPTOR = $(HORIZON_ROOT)/resources/specfiles/private/RepairTool.desc + + +include $(makePlatformDefsPath build.tests) + + +tests: $(TEST_TARGETS) diff --git a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/test_PreinstallImporter.cpp b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/test_PreinstallImporter.cpp new file mode 100644 index 0000000..9f09fa1 --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/PreinstallImporter/test_PreinstallImporter.cpp @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: test_PreinstallImporter.cpp + + Copyright (C)2011 Nintendo Co., Ltd. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Rev$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "demo.h" + +#include "common_Types.h" +#include "CommonLogger.h" +#include "HeapManager.h" +#include "XmlCreator.h" +#include "BgsCommunicator.h" +#include "SimpleXmlPreprocessor.h" +#include "PreinstallImporter.h" + +using namespace nn::test; + +class PreinstallImporterTest : public Suite { +public: + virtual bool InitializeSuite(); + virtual void FinalizeSuite(); + + PreinstallImporterTest() { + TEST_ADD(PreinstallImporterTest::ListUp); + } +private: + void ListUp(); +}; + +namespace +{ + +const size_t s_GxHeapSize = 0x800000; + +} + +//------------------------------------------------------------------ +// Initialize/Finalize +//------------------------------------------------------------------ + +bool PreinstallImporterTest::InitializeSuite() +{ + // os の初期化 + nn::os::Initialize(); + + nn::fs::Initialize(); + + // amの初期化 + nn::am::InitializeForLocalImporter(); + + // cfgの初期化 + nn::cfg::init::Initialize(); + nn::cfg::system::Initialize(); + + // ヒープの確保 + common::InitializeHeap(); + common::HeapManager gxHeap(s_GxHeapSize); + + // RenderSystem の準備 + uptr heapForGx = reinterpret_cast(gxHeap.GetAddr()); + demo::RenderSystemDrawing renderSystem; + renderSystem.Initialize(heapForGx, s_GxHeapSize); + + // ログ描画の初期化 + common::Logger::GetLoggerInstance()->Initialize(common::CONSOLE_WIDTH, common::CONSOLE_HEIGHT, + common::CONSOLE_MAX_LINE, &renderSystem); + + return true; + +} + +void PreinstallImporterTest::FinalizeSuite() +{ +} + +//------------------------------------------------------------------ +// Test Functions +//------------------------------------------------------------------ + +void PreinstallImporterTest::ListUp() +{ + ConsoleRestore::PreinstallImporter importer; + + size_t num = 0; + nn::ProgramId list[256]; + NN_TEST_ASSERT_RESULT_SUCCESS( + importer.ListTitles(list, &num, 17179924184, reinterpret_cast(const_cast("EJA20305940")))); + + NN_LOG("Preinstalled num = %d\n", num); + for(u32 i = 0; i < num; i++) + { + NN_LOG("%016llx\n", list[i]); + } +} + +NN_TEST_DEFINE_MAIN(PreinstallImporterTest) + +/*---------------------------------------------------------------------------* + End of file + *---------------------------------------------------------------------------*/