未验证 提交 3bb4ce43 编写于 作者: J Jan Kotas 提交者: GitHub

Delete low-value PAL test (#48932)

This partially reverts commit 77c939c9.

Fixes #48496
上级 51e25565
......@@ -32,13 +32,6 @@ if(FEATURE_EVENT_TRACE)
add_subdirectory(eventprovider)
endif(FEATURE_EVENT_TRACE)
if (CLR_CMAKE_TARGET_OSX OR (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ALPINE_LINUX))
set(PALSUITE_THREAD_NAME_SOURCES
threading/SetThreadDescription/test1/pthread_helpers.cpp
threading/SetThreadDescription/test1/test1.cpp
)
endif()
_add_executable(paltests
paltests.cpp
common/palsuite.cpp
......@@ -925,7 +918,7 @@ _add_executable(paltests
threading/WaitForSingleObject/WFSOSemaphoreTest/WFSOSemaphoreTest.cpp
threading/WaitForSingleObject/WFSOThreadTest/WFSOThreadTest.cpp
threading/YieldProcessor/test1/test1.cpp
${PALSUITE_THREAD_NAME_SOURCES}
)
add_dependencies(paltests coreclrpal)
......
......@@ -772,13 +772,11 @@ threading/ResetEvent/test2/paltest_resetevent_test2
threading/ResetEvent/test3/paltest_resetevent_test3
threading/ResetEvent/test4/paltest_resetevent_test4
threading/ResumeThread/test1/paltest_resumethread_test1
threading/SwitchToThread/test1/paltest_switchtothread_test1
threading/SetErrorMode/test1/paltest_seterrormode_test1
threading/SetEvent/test1/paltest_setevent_test1
threading/SetEvent/test2/paltest_setevent_test2
threading/SetEvent/test3/paltest_setevent_test3
threading/SetEvent/test4/paltest_setevent_test4
threading/SetThreadDescription/test1/paltest_setthreaddescription_test1
threading/SignalObjectAndWait/paltest_signalobjectandwaittest
threading/Sleep/test1/paltest_sleep_test1
threading/Sleep/test2/paltest_sleep_test2
......
......@@ -679,7 +679,6 @@ threading/SetEvent/test1/paltest_setevent_test1
threading/SetEvent/test2/paltest_setevent_test2
threading/SetEvent/test3/paltest_setevent_test3
threading/SetEvent/test4/paltest_setevent_test4
threading/SetThreadDescription/test1/paltest_setthreaddescription_test1
threading/SwitchToThread/test1/paltest_switchtothread_test1
threading/ThreadPriority/test1/paltest_threadpriority_test1
threading/WaitForMultipleObjects/test1/paltest_waitformultipleobjects_test1
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include <stdlib.h>
#include <pthread.h>
#define NAMELEN 256
char* GetThreadName()
{
char* threadName = (char*)malloc(sizeof(char) * NAMELEN);
pthread_t thread = pthread_self();
int rc = pthread_getname_np(thread, threadName, NAMELEN);
if (rc != 0)
{
free(threadName);
return NULL;
}
return threadName;
}
\ No newline at end of file
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
char* GetThreadName();
\ No newline at end of file
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*============================================================
**
** Source: test1.cpp
**
** Purpose: Test for SetThreadDescription. Create a thread, call
** SetThreadDescription, and then verify that the name of the thread
** matches what was set.
**
**=========================================================*/
#include <palsuite.h>
#include "pthread_helpers.hpp"
char * threadName;
char * expectedThreadName;
char * actualThreadName;
DWORD PALAPI SetThreadDescriptionTestThread(LPVOID lpParameter)
{
HANDLE palThread = GetCurrentThread();
WCHAR wideThreadName[256];
MultiByteToWideChar(CP_ACP, 0, threadName, strlen(threadName)+1, wideThreadName, 256);
SetThreadDescription(palThread, wideThreadName);
actualThreadName = GetThreadName();
return 0;
}
BOOL SetThreadDescriptionTest(char* name, char* expected)
{
BOOL bResult = FALSE;
LPSECURITY_ATTRIBUTES lpThreadAttributes = NULL;
DWORD dwStackSize = 0;
LPTHREAD_START_ROUTINE lpStartAddress = &SetThreadDescriptionTestThread;
LPVOID lpParameter = (LPVOID)SetThreadDescriptionTestThread;
DWORD dwCreationFlags = 0;
DWORD dwThreadId = 0;
threadName = name;
expectedThreadName = expected;
HANDLE hThread = CreateThread(lpThreadAttributes,
dwStackSize, lpStartAddress, lpParameter,
dwCreationFlags, &dwThreadId );
if (hThread != INVALID_HANDLE_VALUE)
{
WaitForSingleObject(hThread, INFINITE);
bResult = strcmp(actualThreadName, expectedThreadName) == 0;
}
else
{
Trace("Unable to create SetThreadDescription test thread");
}
return bResult;
}
BOOL SetThreadDescriptionTests()
{
if (!SetThreadDescriptionTest("Hello, World", "Hello, World"))
{
Trace("Setting thread name failed");
return FAIL;
}
// verify that thread name truncations works correctly on linux on macOS.
char * threadName = "aaaaaaa_15chars_aaaaaaa_31chars_aaaaaaaaaaaaaaaaaaaaaaa_63chars_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
char * expected;
#if defined(__APPLE__)
expected = "aaaaaaa_15chars_aaaaaaa_31chars_aaaaaaaaaaaaaaaaaaaaaaa_63chars";
#else
expected = "aaaaaaa_15chars";
#endif
if (!SetThreadDescriptionTest(threadName, expected))
{
return PASS;
}
return FAIL;
}
PALTEST(threading_SetThreadDescription_test1_paltest_setthreaddescription_test1, "threading/SetThreadDescription/test1/paltest_setthreaddescription_test1")
{
if (0 != (PAL_Initialize(argc, argv)))
{
return FAIL;
}
BOOL result = SetThreadDescriptionTests();
if(actualThreadName) free(actualThreadName);
if (!result)
{
Fail("Test Failed");
}
PAL_Terminate();
return PASS;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册