Skip to content

Commit

Permalink
profiler unit test update
Browse files Browse the repository at this point in the history
  • Loading branch information
tippmar-nr committed Sep 5, 2024
1 parent b801666 commit 5302237
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"\
<?xml version=\"1.0\"?>\
Expand All @@ -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"\
<?xml version=\"1.0\"?>\
Expand All @@ -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"\
<?xml version=\"1.0\"?>\
Expand All @@ -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"\
<?xml version=\"1.0\"?>\
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/Agent/NewRelic/Profiler/MethodRewriter/ISystemCalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 5302237

Please sign in to comment.