From 5302237ed6e55360cc8f6f66249a98a8be4a0557 Mon Sep 17 00:00:00 2001 From: Marty Tippin <120425148+tippmar-nr@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:34:10 -0500 Subject: [PATCH] profiler unit test update --- .../ConfigurationTest/ConfigurationTest.cpp | 17 ++++++++--------- .../Profiler/MethodRewriter/ISystemCalls.h | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Agent/NewRelic/Profiler/ConfigurationTest/ConfigurationTest.cpp b/src/Agent/NewRelic/Profiler/ConfigurationTest/ConfigurationTest.cpp index 3e0ea4c9d8..476d90fe58 100644 --- a/src/Agent/NewRelic/Profiler/ConfigurationTest/ConfigurationTest.cpp +++ b/src/Agent/NewRelic/Profiler/ConfigurationTest/ConfigurationTest.cpp @@ -73,7 +73,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te Assert::IsFalse(configuration.ShouldInstrument(L"foo.exe", L"", L"", L"", false)); } - TEST_METHOD(should_instrument_azure_function_functionsnethost_commandline) + TEST_METHOD(should_not_instrument_azure_function_app_pool_id_in_commandline) { std::wstring configurationXml(L"\ \ @@ -87,10 +87,10 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te Configuration configuration(configurationXml, _missingConfig, L"", systemCalls); - Assert::IsTrue(configuration.ShouldInstrument(L"w3wp.exe", L"", L"foo", L"FunctionsNetHost.exe blah blah blah", true)); + Assert::IsFalse(configuration.ShouldInstrument(L"w3wp.exe", L"", L"FooBarBaz", L"blah blah blah FooBarBaz blah blah blah", true)); } - TEST_METHOD(should_not_instrument_azure_function_app_pool_id_in_commandline) + TEST_METHOD(should_instrument_azure_function_fallback_to_app_pool_checking) { std::wstring configurationXml(L"\ \ @@ -104,10 +104,10 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te Configuration configuration(configurationXml, _missingConfig, L"", systemCalls); - Assert::IsFalse(configuration.ShouldInstrument(L"w3wp.exe", L"", L"FooBarBaz", L"blah blah blah FooBarBaz blah blah blah", true)); + Assert::IsTrue(configuration.ShouldInstrument(L"w3wp.exe", L"", L"foo", L"", true)); } - TEST_METHOD(should_instrument_azure_function_fallback_to_app_pool_checking) + TEST_METHOD(should_not_instrument_azure_function_func_exe_process_path) { std::wstring configurationXml(L"\ \ @@ -121,10 +121,10 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te Configuration configuration(configurationXml, _missingConfig, L"", systemCalls); - Assert::IsTrue(configuration.ShouldInstrument(L"w3wp.exe", L"", L"foo", L"", true)); + Assert::IsFalse(configuration.ShouldInstrument(L"func.exe", L"", L"FooBarBaz", L"blah blah blah FooBarBaz blah blah blah", true)); } - TEST_METHOD(should_not_instrument_azure_function_func_exe_process_path) + TEST_METHOD(should_instrument_azure_function_functionsnethost_exe_process_path) { std::wstring configurationXml(L"\ \ @@ -138,10 +138,9 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te Configuration configuration(configurationXml, _missingConfig, L"", systemCalls); - Assert::IsFalse(configuration.ShouldInstrument(L"func.exe", L"", L"FooBarBaz", L"blah blah blah FooBarBaz blah blah blah", true)); + Assert::IsFalse(configuration.ShouldInstrument(L"functionsnethost.exe", L"", L"FooBarBaz", L"blah blah blah FooBarBaz blah blah blah", true)); } - TEST_METHOD(instrument_process) { ProcessesPtr processes(new Processes()); diff --git a/src/Agent/NewRelic/Profiler/MethodRewriter/ISystemCalls.h b/src/Agent/NewRelic/Profiler/MethodRewriter/ISystemCalls.h index f80c1e30b9..9afd3bd155 100644 --- a/src/Agent/NewRelic/Profiler/MethodRewriter/ISystemCalls.h +++ b/src/Agent/NewRelic/Profiler/MethodRewriter/ISystemCalls.h @@ -91,7 +91,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter { { // Azure Functions sets the FUNCTIONS_WORKER_RUNTIME environment variable to "dotnet-isolated" when running in the .NET worker. auto functionsWorkerRuntime = TryGetEnvironmentVariable(_X("FUNCTIONS_WORKER_RUNTIME")); - return functionsWorkerRuntime != nullptr && functionsWorkerRuntime->length() > 0; + return functionsWorkerRuntime != nullptr && !functionsWorkerRuntime->empty(); } virtual bool IsAzureFunctionLogLevelOverrideEnabled() {