summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/threading/ThreadPriority/test1/ThreadPriority.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/threading/ThreadPriority/test1/ThreadPriority.cpp')
-rw-r--r--src/pal/tests/palsuite/threading/ThreadPriority/test1/ThreadPriority.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/threading/ThreadPriority/test1/ThreadPriority.cpp b/src/pal/tests/palsuite/threading/ThreadPriority/test1/ThreadPriority.cpp
new file mode 100644
index 0000000000..95bcdac52a
--- /dev/null
+++ b/src/pal/tests/palsuite/threading/ThreadPriority/test1/ThreadPriority.cpp
@@ -0,0 +1,83 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*=============================================================================
+**
+** Source: threadpriority.c
+**
+** Purpose: Test to ensure GetThreadPriority works properly.
+**
+** Dependencies: PAL_Initialize
+** PAL_Terminate
+** Fail
+** CreateThread
+** WaitForSingleObject
+** GetLastError
+** time()
+**
+
+**
+**===========================================================================*/
+#include <palsuite.h>
+
+/**
+ * CheckThreadPriority
+ *
+ * Helper function that checks the current thread priority
+ * against an expected value.
+ */
+static VOID CheckThreadPriority( HANDLE hThread, int expectedPriority )
+{
+ int priority;
+ DWORD dwError = 0;
+
+ /* get the current thread priority */
+ priority = GetThreadPriority( hThread );
+ if( priority == THREAD_PRIORITY_ERROR_RETURN )
+ {
+ /* GetThreadPriority call failed */
+ dwError = GetLastError();
+ Fail( "Unexpected GetThreadPriority() failure "
+ "with error %d\n", dwError );
+ }
+ else if( priority != expectedPriority )
+ {
+ /* unexpected thread priority detected */
+ Fail( "Unexpected initial thread priority value %d reported\n",
+ priority );
+ }
+}
+
+
+/**
+ * main
+ *
+ * executable entry point
+ */
+INT __cdecl main( INT argc, CHAR **argv )
+{
+
+ /* PAL initialization */
+ if( (PAL_Initialize(argc, argv)) != 0 )
+ {
+ return( FAIL );
+ }
+
+ /* set the thread priority of the main to the highest possible value
+ this will give the chance to the main thread to create all the
+ other threads */
+ if(!SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_NORMAL))
+ {
+ DWORD dwError;
+
+ dwError = GetLastError();
+ Fail( "Unexpected SetThreadPriority() failure with error %d\n",
+ dwError );
+ }
+
+ CheckThreadPriority( GetCurrentThread(), THREAD_PRIORITY_NORMAL );
+ //Add verification of timing out here..
+ PAL_Terminate();
+ return PASS;
+}