Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,98 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <source/Application.h>
#include <source/ApplicationParameters.h>
namespace PythonBindingsExample
{
//! This function returns the build system target name
AZStd::string_view GetBuildTargetName()
{
#if !defined (LY_CMAKE_TARGET)
#error "LY_CMAKE_TARGET must be defined in order to add this source file to a CMake executable target"
#endif
return AZStd::string_view{ LY_CMAKE_TARGET };
}
class PythonBindingsExampleTest
: public ::testing::Test
, public ::UnitTest::AllocatorsBase
{
public:
static void SetUpTestCase()
{
if (!AZ::AllocatorInstance<AZ::SystemAllocator>::IsReady())
{
AZ::AllocatorInstance<AZ::SystemAllocator>::Create();
}
s_application = AZStd::make_unique<PythonBindingsExample::Application>(nullptr, nullptr);
// The AZ::ComponentApplication constructor creates the settings registry
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization(
*AZ::SettingsRegistry::Get(), GetBuildTargetName());
s_application->SetUp();
}
static void TearDownTestCase()
{
s_application->TearDown();
s_application.reset();
if (AZ::AllocatorInstance<AZ::SystemAllocator>::IsReady())
{
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
}
}
static AZStd::unique_ptr<PythonBindingsExample::Application> s_application;
};
AZStd::unique_ptr<PythonBindingsExample::Application> PythonBindingsExampleTest::s_application;
TEST_F(PythonBindingsExampleTest, Application_Run_Fails)
{
EXPECT_FALSE(s_application->Run());
}
TEST_F(PythonBindingsExampleTest, Application_RunWithParameters_Works)
{
ApplicationParameters params;
EXPECT_TRUE(s_application->RunWithParameters(params));
}
TEST_F(PythonBindingsExampleTest, Application_ImportSys_Works)
{
ApplicationParameters params;
params.m_pythonStatement = "import sys";
EXPECT_TRUE(s_application->RunWithParameters(params));
}
TEST_F(PythonBindingsExampleTest, Application_ImportAzLmbr_Works)
{
ApplicationParameters params;
params.m_pythonStatement = "import azlmbr";
EXPECT_TRUE(s_application->RunWithParameters(params));
}
TEST_F(PythonBindingsExampleTest, Application_ImportAzLmbrPaths_Works)
{
ApplicationParameters params;
params.m_pythonStatement = "import azlmbr.paths; print (azlmbr.paths.engroot); print (azlmbr.paths.devroot)";
EXPECT_TRUE(s_application->RunWithParameters(params));
}
}
@@ -0,0 +1,44 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzFramework/Platform/PlatformDefaults.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzTest/AzTest.h>
#include <AzTest/Utils.h>
#include <AzTest/AzTest.h>
DECLARE_AZ_UNIT_TEST_MAIN();
int runDefaultRunner(int argc, char* argv[])
{
INVOKE_AZ_UNIT_TEST_MAIN(nullptr);
return 0;
}
int main(int argc, char* argv[])
{
// ran with no parameters?
if (argc == 1)
{
constexpr int defaultArgc = 2;
char unittest_arg[] = "--unittests"; // Conversion from string literal to char* is not allowed per ISO C++11
char* defaultArgv[defaultArgc] =
{
argv[0],
unittest_arg
};
return runDefaultRunner(defaultArgc, defaultArgv);
}
INVOKE_AZ_UNIT_TEST_MAIN(nullptr);
return 0;
}
@@ -0,0 +1,62 @@
@echo off
REM
REM All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
REM its licensors.
REM
REM For complete copyright and license terms please see the LICENSE at the root of this
REM distribution (the "License"). All use of this software is governed by the License,
REM or, if provided, by the license below or the license accompanying this file. Do not
REM remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM
PUSHD "%~dp0"
SET CWD="%~dp0"
SET EXEPATH141="../../../../Bin64vc141/PythonBindingsExample.exe"
SET EXEPATH142="../../../../Bin64vc142/PythonBindingsExample.exe"
SET EXEPATH=""
IF EXIST %EXEPATH141% (
SET EXEPATH=%EXEPATH141%
) ELSE (
IF EXIST %EXEPATH142% (
SET EXEPATH=%EXEPATH142%
) ELSE (
ECHO PythonBindingsExample.exe not found.
)
)
IF /I %EXEPATH% EQU "" (
ECHO [FAILED] Could not run tests since a build of PythonBindingsExample.exe is missing
GOTO exit_app
)
ECHO Testing basics of tool Python bindings in %CWD%
%EXEPATH% --file test_hello_tool.py
IF %ERRORLEVEL% EQU 0 (
ECHO [WORKED] test_hello_tool.py
) ELSE (
ECHO [FAILED] test_hello_tool.py with %ERRORLEVEL%
GOTO exit_app
)
%EXEPATH% --file test_framework.py --arg entity
IF %ERRORLEVEL% EQU 0 (
ECHO [WORKED] test_framework.py --arg entity
) ELSE (
ECHO [FAILED] test_framework.py --arg entity with %ERRORLEVEL%
GOTO exit_app
)
%EXEPATH% --file test_framework.py --arg math
IF %ERRORLEVEL% EQU 0 (
ECHO [WORKED] test_framework.py --arg math
) ELSE (
ECHO [FAILED] test_framework.py --arg math with %ERRORLEVEL%
GOTO exit_app
)
:exit_app
POPD
@@ -0,0 +1,50 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
print ('Testing framework Python bindings')
import azlmbr.entity as entity
import azlmbr.framework as framework
import azlmbr.math as math
def test_entity_api():
entityId = entity.EntityId()
if (entityId.IsValid is None):
print('entityId.IsValid is None')
framework.Terminate(1)
if (entityId.IsValid() is True):
print('entityId.IsValid() is True')
framework.Terminate(2)
def test_math_api():
if (math.Math_IsEven(3)):
framework.Terminate(1)
if (math.Math_IsClose(1.0,2.0)):
framework.Terminate(2)
if (math.Math_IsClose(2.0, math.Math_Sqrt(4.0)) is False):
framework.Terminate(3)
def main():
import sys
print("Starting framework test")
if (sys.argv[1] == 'entity'):
test_entity_api()
elif (sys.argv[1] == 'math'):
test_math_api()
else:
print('Unknown arg {}'.format(sys.argv[0]))
framework.Terminate(4)
if __name__ == "__main__":
main()
@@ -0,0 +1,12 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
import azlmbr
print ('Able to load azlmbr module.')