コード例 #1
0
bool UUnitTest::ValidateUnitTestSettings(bool bCDOCheck/*=false*/)
{
	bool bSuccess = true;

	// The unit test must specify some ExpectedResult values
	UNIT_ASSERT(ExpectedResult.Num() > 0);


	TArray<EUnitTestVerification> ExpectedResultList;

	ExpectedResult.GenerateValueArray(ExpectedResultList);

	// Unit tests should not expect unreliable results, without being marked as unreliable
	UNIT_ASSERT(!ExpectedResultList.Contains(EUnitTestVerification::VerifiedUnreliable) || bUnreliable);

	// Unit tests should never expect 'needs-update' as a valid unit test result
	// @todo JohnB: It might make sense to allow this in the future, if you want to mark unit tests as 'needs-update' before running,
	//				so that you can skip running those unit tests
	UNIT_ASSERT(!ExpectedResultList.Contains(EUnitTestVerification::VerifiedNeedsUpdate));


	// Every unit test must specify a timeout value
	UNIT_ASSERT(UnitTestTimeout > 0);

	return bSuccess;
}
コード例 #2
0
ファイル: doccodes_ut.cpp プロジェクト: Mirocow/balancer
    void TestBiblioName(docLanguage language) {
        const char* name = NameByLanguage(language);

        UNIT_ASSERT(name != NULL);
        UNIT_ASSERT(strlen(name) > 2);

        TestName(language, name);
    }
コード例 #3
0
ファイル: doccodes_ut.cpp プロジェクト: Mirocow/balancer
    void TestFullName(docLanguage language) {
        const char* name = FullNameByLanguage(language);
        UNIT_ASSERT(name != NULL);
        UNIT_ASSERT(strlen(name) == 0 || strlen(name) > 3);

        if (strlen(name))
            TestName(language, name);
    }
コード例 #4
0
ファイル: hash_ut.cpp プロジェクト: Mirocow/balancer
void THashTest::TestHSet2() {
    yhash_set<int, THash<int>, TEqualTo<int> > s;
    TPair<yhash_set<int, THash<int>, TEqualTo<int> >::iterator, bool> p = s.insert(42);
    UNIT_ASSERT(p.second);
    UNIT_ASSERT(*(p.first) == 42);

    p = s.insert(42);
    UNIT_ASSERT(!p.second);
}
コード例 #5
0
ファイル: doccodes_ut.cpp プロジェクト: Mirocow/balancer
    void TestIsoName(docLanguage language) {
        const char* name = IsoNameByLanguage(language);

        UNIT_ASSERT(name != NULL);
        UNIT_ASSERT(strlen(name) == 0 || strlen(name) == 2
            || !strcmp(name, "mis") || !strncmp(name, "bas-", 4));

        if (strlen(name))
            TestName(language, name);
    }
コード例 #6
0
ファイル: capture_ut.cpp プロジェクト: yandex/pire
	void MakeSlowCapturingTest(const char* regexp, const char* text, size_t position, bool ans, const ystring& captured = ystring(""), const Pire::Encoding& encoding = Pire::Encodings::Utf8())
	{
		Pire::SlowCapturingScanner sc = SlowCompile(regexp, position, encoding);
		SlowCapturingScanner::State st = RunRegexp(sc, text);
		SlowCapturingScanner::SingleState fin;
		bool ifCaptured = sc.GetCapture(st, fin);
		if (ans) {
			UNIT_ASSERT(ifCaptured);
			ystring answer(text, fin.GetBegin(), fin.GetEnd() - fin.GetBegin());
			UNIT_ASSERT_EQUAL(answer, captured);
		} else  {
			UNIT_ASSERT(!ifCaptured);
		}
	}
コード例 #7
0
ファイル: yexception_ut.cpp プロジェクト: Mirocow/balancer
        inline void TestVirtuality() {
            try {
                ythrow TFileError() << "1";
                UNIT_ASSERT(false);
            } catch (const TIoException&) {
            } catch (...) {
                UNIT_ASSERT(false);
            }

            try {
                ythrow TFileError() << 1;
                UNIT_ASSERT(false);
            } catch (const TSystemError&) {
            } catch (...) {
                UNIT_ASSERT(false);
            }

            try {
                ythrow TFileError() << '1';
                UNIT_ASSERT(false);
            } catch (const yexception&) {
            } catch (...) {
                UNIT_ASSERT(false);
            }

            try {
                ythrow TFileError() << 1.0;
                UNIT_ASSERT(false);
            } catch (const TFileError&) {
            } catch (...) {
                UNIT_ASSERT(false);
            }
        }
コード例 #8
0
ファイル: iconv_ut.cpp プロジェクト: Mirocow/balancer
    void TestBig5() {
        UNIT_ASSERT(!NCodepagePrivate::NativeCodepage(CODES_BIG5));
        const char* UTF8 = "\xe5\xad\xb8\xe7\x94\x9f\xe7\xb8\xbd\xe4\xba\xba\xe6\x95\xb8\xe6\x99\xae\xe9\x80\x9a\xe7\x8f\xad";
        const char* BIG5 = "\xbe\xc7\xa5\xcd\xc1\x60\xa4\x48\xbc\xc6\xb4\xb6\xb3\x71\xaf\x5a";

        TestIconv(UTF8, BIG5, CODES_BIG5);
    }
コード例 #9
0
ファイル: tasks_ut.cpp プロジェクト: Mirocow/balancer
        inline void TestMtpTaskPool() {
            TMtpTasksPool pool;

            TMtpTasksPool::TMtpTaskFromPoolRef task = pool.Acquire();

            UNIT_ASSERT(task.Get() != 0);
        }
コード例 #10
0
ファイル: yexception_ut.cpp プロジェクト: Mirocow/balancer
 //! tests propagation of an exception through C code
 //! @note on some platforms, for example GCC on 32-bit Linux without -fexceptions option,
 //!       throwing an exception from a C++ callback through C code aborts program
 inline void TestMixedCode() {
     const int N = 26082009;
     try {
         TestCallback(&CallbackFun, N);
         UNIT_ASSERT(false);
     } catch (int i) {
         UNIT_ASSERT_VALUES_EQUAL(i, N);
     }
 }
コード例 #11
0
ファイル: ip_ut.cpp プロジェクト: Mirocow/balancer
void TSysIpTest::TestIpToString() {
    ui8 ipArr[][4] = {{192, 168, 0, 1}, {87, 255, 18, 167}, {255, 255, 0, 31}, {188, 225, 124, 255}};

    const char* ipStr[] = {"192.168.0.1", "87.255.18.167", "255.255.0.31", "188.225.124.255"};

    for (size_t i = 0; i < ARRAY_SIZE(ipStr); ++i) {
        UNIT_ASSERT(IpToString(*ReinterpretCast<TIpHost*>(&(ipArr[i]))) == ipStr[i]);
    }
}
コード例 #12
0
ファイル: ip_ut.cpp プロジェクト: Mirocow/balancer
void TSysIpTest::TestIpFromString() {
    const char* ipStr[] = {"192.168.0.1", "87.255.18.167", "255.255.0.31", "188.225.124.255"};
    ui8 ipArr[][4] = {{192, 168, 0, 1}, {87, 255, 18, 167}, {255, 255, 0, 31}, {188, 225, 124, 255}};

    for (size_t i = 0; i < ARRAY_SIZE(ipStr); ++i) {
        const ui32 ip = IpFromString(ipStr[i]);

        UNIT_ASSERT(memcmp(&ip, ipArr[i], sizeof(ui32)) == 0);
    }
}
コード例 #13
0
ファイル: yexception_ut.cpp プロジェクト: Mirocow/balancer
        inline void TestFormat1() {
            try {
                throw yexception() << 1 << " qw " << 12.1;
                UNIT_ASSERT(false);
            } catch (...) {
                const Stroka err = CurrentExceptionMessage();

                UNIT_ASSERT_VALUES_EQUAL(err, "1 qw 12.1");
            }
        }
コード例 #14
0
ファイル: yexception_ut.cpp プロジェクト: Mirocow/balancer
 inline void TestRaise1() {
     try {
         Throw2DontMove();
         UNIT_ASSERT(false);
     } catch (...) {
         Stroka err = CurrentExceptionMessage();
         char *ptr = err.begin();
         while ((ptr = strchr(ptr, '\\')) != 0)
             *ptr = '/';
         UNIT_ASSERT_VALUES_EQUAL(err, "util/generic/yexception_ut.cpp:8: 1 qw 12.1");
     }
 }
コード例 #15
0
ファイル: thread_ut.cpp プロジェクト: Mirocow/balancer
        inline void TestThreadId() {
            TIdTester tst;
            TThread thr(tst.DoRun, &tst);

            tst.Thr = &thr;

            thr.Start();
            thr.Join();

            UNIT_ASSERT_EQUAL(tst.Cur, tst.Real);
            UNIT_ASSERT(tst.Cur != 0);
        }
コード例 #16
0
ファイル: hash_ut.cpp プロジェクト: Mirocow/balancer
void THashTest::TestHMSet1() {
    hmset s;
    UNIT_ASSERT(s.count(star) == 0);
    s.insert(star);
    UNIT_ASSERT(s.count(star) == 1);
    s.insert(star);
    UNIT_ASSERT(s.count(star) == 2);
    hmset::iterator i = s.find(char(40));
    UNIT_ASSERT(i == s.end());

    i = s.find(star);
    UNIT_ASSERT(i != s.end());
    UNIT_ASSERT(*i == '*');
    UNIT_ASSERT(s.erase(star) == 2);
}
コード例 #17
0
void UUnitTest::TickIsComplete(float DeltaTime)
{
	// If the unit test was verified as success/fail (i.e. as completed), end it now
	if (!bCompleted && VerificationState != EUnitTestVerification::Unverified)
	{
		if (!bVerificationLogged)
		{
			if (VerificationState == EUnitTestVerification::VerifiedNotFixed)
			{
				UNIT_LOG(ELogType::StatusFailure, TEXT("Unit test verified as NOT FIXED"));
			}
			else if (VerificationState == EUnitTestVerification::VerifiedFixed)
			{
				UNIT_LOG(ELogType::StatusSuccess, TEXT("Unit test verified as FIXED"));
			}
			else if (VerificationState == EUnitTestVerification::VerifiedUnreliable)
			{
				UNIT_LOG(ELogType::StatusWarning, TEXT("Unit test verified as UNRELIABLE"));
			}
			else if (VerificationState == EUnitTestVerification::VerifiedNeedsUpdate)
			{
				UNIT_LOG(ELogType::StatusWarning | ELogType::StyleBold, TEXT("Unit test NEEDS UPDATE"));
			}
			else
			{
				// Don't forget to add new verification states
				UNIT_ASSERT(false);
			}

			bVerificationLogged = true;
		}

		if (!bDeveloperMode)
		{
			EndUnitTest();
		}
	}
}
コード例 #18
0
ファイル: iconv_ut.cpp プロジェクト: Mirocow/balancer
static void TestSurrogates(const char* str, const wchar16* wide, size_t wideSize) {
    size_t sSize = strlen(str);
    size_t wSize = sSize * 2;
    TArrayHolder<wchar16> w(new wchar16[wSize]);

    size_t read = 0;
    size_t written = 0;
    NICONVPrivate::RecodeToUnicode(CODES_UTF8, str, w.Get(), sSize, wSize, read, written);
    UNIT_ASSERT(read == sSize);
    UNIT_ASSERT(written == wideSize);
    UNIT_ASSERT(!memcmp(w.Get(), wide, wideSize));

    TArrayHolder<char> s(new char[sSize]);
    NICONVPrivate::RecodeFromUnicode(CODES_UTF8, w.Get(), s.Get(), wideSize, sSize, read, written);
    UNIT_ASSERT(read == wideSize);
    UNIT_ASSERT(written == sSize);
    UNIT_ASSERT(!memcmp(s.Get(), str, sSize));
}
コード例 #19
0
ファイル: hash_ut.cpp プロジェクト: Mirocow/balancer
void THashTest::TestInsertErase() {
    typedef yhash_map<Stroka, size_t, THash<Stroka>, TEqualTo<Stroka> > hmap;
    typedef hmap::value_type val_type;

    {
        hmap values;

        UNIT_ASSERT(values.insert(val_type("foo", 0)).second);
        UNIT_ASSERT(values.insert(val_type("bar", 0)).second);
        UNIT_ASSERT(values.insert(val_type("abc", 0)).second);

        UNIT_ASSERT(values.erase("foo") == 1);
        UNIT_ASSERT(values.erase("bar") == 1);
        UNIT_ASSERT(values.erase("abc") == 1);
    }

    {
        hmap values;

        UNIT_ASSERT(values.insert(val_type("foo", 0)).second);
        UNIT_ASSERT(values.insert(val_type("bar", 0)).second);
        UNIT_ASSERT(values.insert(val_type("abc", 0)).second);

        UNIT_ASSERT(values.erase("abc") == 1);
        UNIT_ASSERT(values.erase("bar") == 1);
        UNIT_ASSERT(values.erase("foo") == 1);
    }
}
コード例 #20
0
ファイル: hash_ut.cpp プロジェクト: Mirocow/balancer
void THashTest::TestHMap1() {
    typedef yhash_map<char, Stroka, THash<char>, TEqualTo<char> > maptype;
    maptype m;
    // Store mappings between roman numerals and decimals.
    m['l'] = "50";
    m['x'] = "20"; // Deliberate mistake.
    m['v'] = "5";
    m['i'] = "1";
    UNIT_ASSERT(!strcmp(m['x'].c_str(),"20"));
    m['x'] = "10"; // Correct mistake.
    UNIT_ASSERT(!strcmp(m['x'].c_str(),"10"));

    UNIT_ASSERT(!m.has('z'));
    UNIT_ASSERT(!strcmp(m['z'].c_str(),""));
    UNIT_ASSERT(m.has('z'));

    UNIT_ASSERT(m.count('z') == 1);
    TPair<maptype::iterator, bool> p = m.insert(TPair<const char, Stroka>('c', Stroka("100")));

    UNIT_ASSERT(p.second);

    p = m.insert(TPair<const char, Stroka>('c', Stroka("100")));
    UNIT_ASSERT(!p.second);

    //Some iterators compare check, really compile time checks
    maptype::iterator ite(m.begin());
    maptype::const_iterator cite(m.begin());
    cite = m.begin();
    maptype const& cm = m;
    cite = cm.begin();

    UNIT_ASSERT((maptype::const_iterator)ite == cite);
    UNIT_ASSERT(!((maptype::const_iterator)ite != cite));
    UNIT_ASSERT(cite == (maptype::const_iterator)ite);
    UNIT_ASSERT(!(cite != (maptype::const_iterator)ite));
}
コード例 #21
0
ファイル: doccodes_ut.cpp プロジェクト: Mirocow/balancer
 void TestWrongName(const char* name) {
     docLanguage reversed = LanguageByName(name);
     UNIT_ASSERT(reversed == LANG_UNK);
     docLanguage reversedStrict = LanguageByNameStrict(name);
     UNIT_ASSERT(reversedStrict == LANG_MAX);
 }
コード例 #22
0
ファイル: doccodes_ut.cpp プロジェクト: Mirocow/balancer
 void TestName(docLanguage language, const char* name) {
     docLanguage reversed = LanguageByName(name);
     UNIT_ASSERT(language == reversed);
     docLanguage reversedStrict = LanguageByNameStrict(name);
     UNIT_ASSERT(language == reversedStrict);
 }
コード例 #23
0
ファイル: hash_ut.cpp プロジェクト: Mirocow/balancer
void THashTest::TestHMMap1() {
    typedef yhash_multimap<char, int, THash<char>, TEqualTo<char> > mmap;
    mmap m;

    UNIT_ASSERT(m.count('X') == 0);
    m.insert(TPair<const char, int>('X', 10)); // Standard way.
    UNIT_ASSERT(m.count('X') == 1);

    m.insert(TPair<const char, int>('X', 20));  // jbuck: standard way
    UNIT_ASSERT(m.count('X') == 2);

    m.insert(TPair<const char, int>('Y', 32));  // jbuck: standard way
    mmap::iterator i = m.find('X'); // Find first match.

    UNIT_ASSERT((*i).first == 'X');
    UNIT_ASSERT((*i).second == 10);
    i++;
    UNIT_ASSERT((*i).first == 'X');
    UNIT_ASSERT((*i).second == 20);

    i = m.find('Y');
    UNIT_ASSERT((*i).first == 'Y');
    UNIT_ASSERT((*i).second == 32);

    i = m.find('Z');
    UNIT_ASSERT(i == m.end());

    size_t count = m.erase('X');
    UNIT_ASSERT(count == 2);

    //Some iterators compare check, really compile time checks
    mmap::iterator ite(m.begin());
    mmap::const_iterator cite(m.begin());

    UNIT_ASSERT((mmap::const_iterator)ite == cite);
    UNIT_ASSERT(!((mmap::const_iterator)ite != cite));
    UNIT_ASSERT(cite == (mmap::const_iterator)ite);
    UNIT_ASSERT(!(cite != (mmap::const_iterator)ite));

    typedef yhash_multimap<size_t, size_t> HMapType;
    HMapType hmap;

    //We fill the map to implicitely start a rehash.
    for (size_t counter = 0; counter < 3077; ++counter) {
        hmap.insert(HMapType::value_type(1, counter));
    }

    hmap.insert(HMapType::value_type(12325, 1));
    hmap.insert(HMapType::value_type(12325, 2));

    UNIT_ASSERT(hmap.count(12325) == 2);

    //At this point 23 goes to the same bucket as 12325, it used to reveal a bug.
    hmap.insert(HMapType::value_type(23, 0));

    UNIT_ASSERT(hmap.count(12325) == 2);
}
コード例 #24
0
ファイル: iconv_ut.cpp プロジェクト: Mirocow/balancer
static void TestIconv(const Stroka& utf8, const Stroka& other, ECharset enc) {
    Wtroka wide0 = CharToWide(utf8, CODES_UTF8);
    Wtroka wide1 = CharToWide(other, enc);

    UNIT_ASSERT(wide0 == wide1);

    Stroka temp = WideToChar(wide0, CODES_UTF8);
    UNIT_ASSERT(temp == utf8);

    temp = WideToChar(wide0, enc);
    UNIT_ASSERT(temp == other);

    temp = Recode(enc, CODES_UTF8, other);
    UNIT_ASSERT(temp == utf8);

    temp = Recode(CODES_UTF8, enc, utf8);
    UNIT_ASSERT(temp == other);

    size_t read = 0;
    size_t written = 0;

    RECODE_RESULT res = RecodeToUnicode(enc, other.c_str(), wide1.begin(), other.size(), wide1.size(), read, written);
    UNIT_ASSERT(res == RECODE_OK);
    UNIT_ASSERT(read == other.size());
    UNIT_ASSERT(written == wide1.size());
    UNIT_ASSERT(wide0 == wide1);

    res = RecodeFromUnicode(enc, wide0.c_str(), temp.begin(), wide0.size(), temp.size(), read, written);
    UNIT_ASSERT(res == RECODE_OK);
    UNIT_ASSERT(read == wide0.size());
    UNIT_ASSERT(written == other.size());
    UNIT_ASSERT(temp == other);
}
コード例 #25
0
TSharedPtr<SLogWindow> FLogWindowManager::CreateLogWindow(FString Title, ELogType ExpectedFilters, bool bStatusWindow)
{
	TSharedPtr<SLogWindow> ReturnVal = NULL;

	// Instead of searching for the first empty space, try to create log windows in a row pattern based upon the grid
	int FreeGridPos = FindFreeGridPos();
	bool bMinimizeWindow = false;


	// If there is a free position, create the log window
	if (FreeGridPos != INDEX_NONE)
	{
		LastLogWindowPos = FreeGridPos;
		FLogGridEntry& CurEntry = GridSpaces[FreeGridPos];

		ReturnVal =
				SNew(SLogWindow, Title, CurEntry.Left, CurEntry.Top, LogWidth, LogHeight)
				.bStatusWindow(bStatusWindow)
				.ExpectedFilters(ExpectedFilters);

		CurEntry.LogWindow = ReturnVal;
	}
	// If there isn't a free position, add to the overflow window array, and start the window minimized
	else
	{
		UNIT_ASSERT(GridSpaces.Num() > 0);

		// All minimized entries go into the first grid location
		FLogGridEntry& OverflowLoc = GridSpaces[0];

		ReturnVal =
				SNew(SLogWindow, Title, OverflowLoc.Left, OverflowLoc.Top, LogWidth, LogHeight)
				.bStatusWindow(bStatusWindow)
				.ExpectedFilters(ExpectedFilters);

		bMinimizeWindow = true;

		OverflowWindows.Add(ReturnVal);
	}


	if (ReturnVal.IsValid())
	{
#if TARGET_UE4_CL >= CL_DEPRECATEDEL
		OnWindowClosedDelegateHandles.Add(ReturnVal.Get(),
											ReturnVal->MultiOnWindowClosed.AddRaw(this, &FLogWindowManager::OnWindowClosed));
#else
		ReturnVal->MultiOnWindowClosed.AddRaw(this, &FLogWindowManager::OnWindowClosed);
#endif

		FSlateApplication::Get().AddWindow(ReturnVal.ToSharedRef());

		if (bMinimizeWindow)
		{
			ReturnVal->Minimize();
		}
		// Flash all newly focused windows, so it's clear the window is new (since it may take the place of an old window)
		else
		{
			ReturnVal->FlashWindow();
		}
	}

	return ReturnVal;
}
コード例 #26
0
ファイル: NUTActor.cpp プロジェクト: frobro98/UnrealSource
bool ANUTActor::NotifyControlMessage(UNetConnection* Connection, uint8 MessageType, FInBunch& Bunch)
{
	bool bHandledMessage = false;

	if (MessageType == NMT_NUTControl)
	{
		uint8 CmdType = 0;
		FString Command;
		FNetControlMessage<NMT_NUTControl>::Receive(Bunch, CmdType, Command);

		// Console command
		if (CmdType == ENUTControlCommand::Command_NoResult || CmdType == ENUTControlCommand::Command_SendResult)
		{
			UE_LOG(LogUnitTest, Log, TEXT("NMT_NUTControl: Executing command: %s"), *Command);

			FStringOutputDevice CmdResult;
			CmdResult.SetAutoEmitLineTerminator(true);

			bool bCmdSuccess = false;

			bCmdSuccess = GEngine->Exec(GetWorld(), *Command, CmdResult);

			UE_LOG(LogUnitTest, Log, TEXT("NMT_NUTControl: Command result: %s"), *CmdResult);


			bool bSendResult = CmdType == ENUTControlCommand::Command_SendResult;

			if (bSendResult)
			{
				uint8 ReturnCmdType = (bCmdSuccess ? ENUTControlCommand::CommandResult_Success :
										ENUTControlCommand::CommandResult_Failed);

				FNetControlMessage<NMT_NUTControl>::Send(Connection, ReturnCmdType, CmdResult);
			}
		}
		// Console command result
		else if (CmdType == ENUTControlCommand::CommandResult_Failed || CmdType == ENUTControlCommand::CommandResult_Success)
		{
			bool bCmdSuccess = CmdType == ENUTControlCommand::CommandResult_Success;

			if (bCmdSuccess)
			{
				UE_LOG(LogUnitTest, Log, TEXT("NMT_NUTControl: Got command result:"));
				UE_LOG(LogUnitTest, Log, TEXT("%s"), *Command);
			}
			else
			{
				UE_LOG(LogUnitTest, Log, TEXT("NMT_NUTControl: Failed to execute command"));
			}
		}
		// Ping request
		else if (CmdType == ENUTControlCommand::Ping)
		{
			uint8 TempCmdType = ENUTControlCommand::Pong;
			FString Dud;

			FNetControlMessage<NMT_NUTControl>::Send(Connection, TempCmdType, Dud);
		}
		// Pong reply - this should only be implemented by custom unit tests; hence the assert
		else if (CmdType == ENUTControlCommand::Pong)
		{
			UNIT_ASSERT(false);
		}
		// Custom implemented events, with the result triggered through 'NotifyEvent'
		else if (CmdType == ENUTControlCommand::WatchEvent)
		{
			// NOTE: Only the last NetConnection to request a WatchEvent, will receive notifications
			EventWatcher = Connection;

			// Watch for the end of seamless travel
			if (Command == TEXT("SeamlessTravelEnd"))
			{
				FCoreUObjectDelegates::PostLoadMap.AddStatic(&ANUTActor::NotifyPostLoadMap);
			}
		}
		// Event watch notification - should only be implemented by custom unit tests
		else if (CmdType == ENUTControlCommand::NotifyEvent)
		{
			UNIT_ASSERT(false);
		}
		// Create an actor instance (the 'summon' console command, doesn't work without a cheat manager)
		else if (CmdType == ENUTControlCommand::Summon)
		{
			const TCHAR* Cmd = *Command;
			FString SpawnClassName = FParse::Token(Cmd, false);
			bool bForceBeginPlay = FParse::Param(Cmd, TEXT("ForceBeginPlay"));

			// Hack specifically for getting the GameplayDebugger working - think the mainline code is broken
			bool bGameplayDebuggerHack = FParse::Param(Cmd, TEXT("GameplayDebuggerHack"));

			UClass* SpawnClass = FindObject<UClass>(NULL, *SpawnClassName);

			if (SpawnClass != NULL)
			{
				FActorSpawnParameters SpawnParms;
				SpawnParms.Owner = GetOwner();

				AActor* NewActor = GetWorld()->SpawnActor<AActor>(SpawnClass, SpawnParms);

				if (NewActor != NULL)
				{
					UE_LOG(LogUnitTest, Log, TEXT("Successfully summoned actor of class '%s'"), *SpawnClassName);

					if (bForceBeginPlay && !NewActor->HasActorBegunPlay())
					{
						UE_LOG(LogUnitTest, Log, TEXT("Forcing call to 'BeginPlay' on newly spawned actor."));

						NewActor->BeginPlay();
					}

					if (bGameplayDebuggerHack)
					{
						// Assign the LocalPlayerOwner property, to the PC owning this NUTActor, using reflection (to avoid dependency)
						UObjectProperty* LocalPlayerOwnerProp =
								FindField<UObjectProperty>(NewActor->GetClass(), TEXT("LocalPlayerOwner"));

						if (LocalPlayerOwnerProp != NULL)
						{
							LocalPlayerOwnerProp->SetObjectPropertyValue(
								LocalPlayerOwnerProp->ContainerPtrToValuePtr<UObject*>(NewActor), GetOwner());
						}
						else
						{
							UE_LOG(LogUnitTest, Log, TEXT("WARNING: Failed to find 'LocalPlayerOwner' property. Unit test broken."));
						}

						// Also hack-disable ticking, so that the replicator doesn't spawn a second replicator
						NewActor->SetActorTickEnabled(false);
					}
				}
				else
				{
					UE_LOG(LogUnitTest, Log, TEXT("SpawnActor failed for class '%s'"), *Command);
				}
			}
			else
			{
				UE_LOG(LogUnitTest, Log, TEXT("Could not find actor class '%s'"), *Command);
			}
		}
		// Suspend the game, until a resume request is received (used for giving time, to attach a debugger)
		else if (CmdType == ENUTControlCommand::SuspendProcess)
		{
			UE_LOG(LogUnitTest, Log, TEXT("Suspend start."));


			// Setup a named pipe, to monitor for the resume request
			FString ResumePipeName = FString::Printf(TEXT("%s%u"), NUT_SUSPEND_PIPE, FPlatformProcess::GetCurrentProcessId());
			FPlatformNamedPipe ResumePipe;
			bool bPipeCreated = ResumePipe.Create(ResumePipeName, true, false);

			if (bPipeCreated)
			{
				if (!ResumePipe.OpenConnection())
				{
					UE_LOG(LogUnitTest, Log, TEXT("WARNING: Failed to open pipe connection."));
				}
			}
			else
			{
				UE_LOG(LogUnitTest, Log, TEXT("WARNING: Failed to create resume pipe."));
			}



			// Spin/sleep (effectively suspended) until a resume request is received
			while (true)
			{
				if (bPipeCreated && ResumePipe.IsReadyForRW())
				{
					int32 ResumeVal = 0;

					if (ResumePipe.ReadInt32(ResumeVal) && !!ResumeVal)
					{
						UE_LOG(LogUnitTest, Log, TEXT("Got resume request."));
						break;
					}
				}


				FPlatformProcess::Sleep(1.0f);
			}


			ResumePipe.Destroy();

			UE_LOG(LogUnitTest, Log, TEXT("Suspend end."));
		}

		bHandledMessage = true;
	}

	return bHandledMessage;
}
コード例 #27
0
ファイル: info_ut.cpp プロジェクト: Mirocow/balancer
 inline void TestGetPageSize() {
     UNIT_ASSERT(NSystemInfo::GetPageSize() >= 4096);
 }
コード例 #28
0
ファイル: info_ut.cpp プロジェクト: Mirocow/balancer
 inline void TestNumberOfCpus() {
     UNIT_ASSERT(NSystemInfo::NumberOfCpus() > 0);
     UNIT_ASSERT_EQUAL(NSystemInfo::NumberOfCpus(), NSystemInfo::CachedNumberOfCpus());
 }